Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pte): expose data-attributes on PTE Text + Object blocks #6641

Merged
merged 2 commits into from
May 14, 2024
Merged

Conversation

robinpyon
Copy link
Contributor

@robinpyon robinpyon commented May 13, 2024

Description

This tiny PR adds data attributes to PTE text + object blocks, as well as their children which have styles applied in JS (via innerPaddingProps)

These have been added in order for Create to be able to safely target and override styles applied on these elements without resorting to sketchy CSS selectors.

There's definitely a greater question of how we could look to render <PortableTextInput> in a style-agnostic fashion in future. For now, this is very much a short term solve.

What to review

Nothing – this doesn't impact the studio...

Questions

.. but does lead to some interesting questions!

  • When it comes to exposing arbitrary (non-test) data-attributes, is there a convention we should use to denote certain attributes as protected and in use externally?
    • E.g. I could easily see a future where someone searches for instances of these data attrs, finds none within the studio and then marks them for deletion.
    • If there isn't an existing convention, is it worth just attaching inline comments to these?
  • As above, how customisable should PTE and all rendered output be? Perhaps a convention could be made where if we are applying styles-in-js, that we provide a data-attr / escape hatch for users to override these externally.
    Nothing that needs to be actioned any time soon, but perhaps worth formalising eventually (especially as we start to see more PTE usage within the studio outside of document forms)

Testing

N/A

Notes for release

N/A

Copy link

vercel bot commented May 13, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
performance-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 14, 2024 8:30am
test-next-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 14, 2024 8:30am
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 14, 2024 8:30am
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview May 14, 2024 8:30am

Copy link
Contributor

No changes to documentation

@robinpyon robinpyon marked this pull request as ready for review May 13, 2024 17:26
@robinpyon robinpyon requested a review from a team as a code owner May 13, 2024 17:26
@robinpyon robinpyon requested a review from ninaandal May 13, 2024 17:26
Copy link
Contributor

github-actions bot commented May 13, 2024

Component Testing Report Updated May 14, 2024 8:35 AM (UTC)

File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 35s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 6s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 26s 6 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 31s 11 7 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 14s 6 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 36s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 3s 15 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 5s 18 0 0
formBuilder/inputs/PortableText/PresenceCursors.spec.tsx ✅ Passed (Inspect) 7s 3 9 0
formBuilder/inputs/PortableText/RangeDecoration.spec.tsx ✅ Passed (Inspect) 20s 9 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 14s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 21s 9 0 0

RitaDias
RitaDias previously approved these changes May 14, 2024
Copy link
Contributor

@RitaDias RitaDias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi 👋
Thanks for doing this! ✨

Questions

.. but does lead to some interesting questions!

  • When it comes to exposing arbitrary (non-test) data-attributes, is there a convention we should use to denote certain attributes as protected and in use externally?

    • E.g. I could easily see a future where someone searches for instances of these data attrs, finds none within the studio and then marks them for deletion.
    • If there isn't an existing convention, is it worth just attaching inline comments to these?
  • As above, how customisable should PTE and all rendered output be? Perhaps a convention could be made where if we are applying styles-in-js, that we provide a data-attr / escape hatch for users to override these externally.
    Nothing that needs to be actioned any time soon, but perhaps worth formalising eventually (especially as we start to see more PTE usage within the studio outside of document forms)

I am ok with approving this though your questions are valid. I am not sure what is the best forum for this 🤔 maybe this is something that should be brought up with you joining the weekly sync or maybe I can bring it up? I'm not sure! @jtpetty would that be the right course of action?

@robinpyon
Copy link
Contributor Author

Thanks @RitaDias – just added inline comments until we have more guidance here

Copy link
Contributor

@RitaDias RitaDias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@robinpyon robinpyon added this pull request to the merge queue May 14, 2024
Merged via the queue into next with commit 4062c29 May 14, 2024
39 checks passed
@robinpyon robinpyon deleted the crx-616 branch May 14, 2024 09:46
ricokahler pushed a commit that referenced this pull request May 14, 2024
* feat: expose data attributes on PTE text block components

* feat: expose data attributes on PTE default block object component
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants