fix: update reboot file to conditionally use logical properties or physical properties#3281
fix: update reboot file to conditionally use logical properties or physical properties#3281LinKCoding wants to merge 4 commits intomainfrom
Conversation
|
View your CI Pipeline Execution ↗ for commit 5d144e5 ☁️ Nx Cloud last updated this comment at |
|
View your CI Pipeline Execution ↗ for commit 15db791 ☁️ Nx Cloud last updated this comment at |
|
| margin-top: 0; | ||
| margin-bottom: ${theme.spacing[16]}; | ||
| ${useLogicalProperties ? 'margin-block-start' : 'margin-top'}: 0; | ||
| ${useLogicalProperties ? 'margin-block-end' : 'margin-bottom'}: 1rem; |
There was a problem hiding this comment.
TS gets really fincky about how it parses these strings. Sometimes ${theme.space[x]} throws an error, sometimes it doesn't
Opted to convert to rem to just keep everything consistent
There was a problem hiding this comment.
weird, any idea what the cause of that flakiness is? smells like a canary to me.
| export const StaticLight: Story = { | ||
| render: () => ( | ||
| <Background bg="white"> | ||
| <p>Test test</p> |
There was a problem hiding this comment.
This is just to allow for inspecting when useLogicalProperties is false, then the rendered CSS is physical (margin-top and margin-bottom) and when it's true it'll render margin-inline-start and margin-inline-end
I will remove after approval
|
📬 Published Alpha Packages: |
|
🚀 Styleguide deploy preview ready! Preview URL: https://69b31905c5f3ba5af2d16064--gamut-preview.netlify.app |
sh0ji
left a comment
There was a problem hiding this comment.
nice, this will work well. my requested change is to keep the semantics of theme consistent.
| margin-top: 0; | ||
| margin-bottom: ${theme.spacing[16]}; | ||
| ${useLogicalProperties ? 'margin-block-start' : 'margin-top'}: 0; | ||
| ${useLogicalProperties ? 'margin-block-end' : 'margin-bottom'}: 1rem; |
There was a problem hiding this comment.
weird, any idea what the cause of that flakiness is? smells like a canary to me.
| // Merge useLogicalProperties into theme so variance can access it via props.theme. | ||
| const themeWithLogicalProperties = useMemo( | ||
| () => ({ ...theme, useLogicalProperties }), | ||
| [theme, useLogicalProperties] | ||
| ); | ||
|
|
||
| const globals = shouldInsertGlobals && ( | ||
| <> | ||
| <Typography theme={theme} /> | ||
| <Reboot theme={theme} /> | ||
| <Typography theme={themeWithLogicalProperties} /> | ||
| <Reboot theme={themeWithLogicalProperties} /> |
There was a problem hiding this comment.
I'm a bit wary of changing the shape of theme like this since it's already a well-defined concept in Gamut.
I can think of two options off the top of my head to resolve this but don't feel like you have to use either. My main concern is semantic consistency for our props and I'm sure there are other options here.
- add
useLogicalPropertiesto the Typography & Reboot props. For instance:
<Reboot theme={theme} logicalProperties={useLogicalProperties />- create a hook to access provider props from within children. For instance:
export const Reboot: React.FC<{ theme: Theme }> = ({ theme }) => {
const { logicalProperties } = useExperimentalFeatures();
// text-align: ${logicalProperties ? 'start' : 'left'};I do think option 2 is better since it opens the door for using this pattern for "work-in-progress" stuff in the future, but it's obviously more work. You'd have to create an <ExperimentalFeatureProvider> and related hook (private APIs just for us) and move the useLogicalProperties there.
There was a problem hiding this comment.
oh and the only reason I even thought of option 2 was because of the conversation about "beta" releases, so FYI @dreamwasp. even if we don't use that pattern here, you may want to consider it as a way for us to gate features.
sh0ji
left a comment
There was a problem hiding this comment.
changing this to approved after talking with @LinKCoding. I didn't realize that the themeWithLogicalProperties was already being used so I'm fine with addressing this more holistically in another PR.
Overview
Updates the reboot.tsx file that overrides user agent styling to conditionally use logical properties or physical properties
PR Checklist
Testing Instructions
Don't make me tap the sign.
CarddirPR Links and Envs