Skip to content

fix: update reboot file to conditionally use logical properties or physical properties#3281

Open
LinKCoding wants to merge 4 commits intomainfrom
kl-gmt-1451-gamut-reboot-hotfix
Open

fix: update reboot file to conditionally use logical properties or physical properties#3281
LinKCoding wants to merge 4 commits intomainfrom
kl-gmt-1451-gamut-reboot-hotfix

Conversation

@LinKCoding
Copy link
Contributor

@LinKCoding LinKCoding commented Mar 12, 2026

Overview

Updates the reboot.tsx file that overrides user agent styling to conditionally use logical properties or physical properties

PR Checklist

  • Related to designs:
  • Related to JIRA ticket: GMT-1451
  • I have run this code to verify it works
  • This PR includes unit tests for the code change
  • This PR includes testing instructions tests for the code change
  • The alpha package of this PR is passing end-to-end tests in all relevant Codecademy repositories

Testing Instructions

Don't make me tap the sign.

  1. Go to Card
  2. Use the toolbar and set Storybook to use logical properties
  3. Check that it looks the same
  4. Use the toolbar and set RTL, see that the text is now aligned to the dir
  5. ...
  6. Finish and do a celebratory dance

PR Links and Envs

Repository PR Link
N/A

@nx-cloud
Copy link

nx-cloud bot commented Mar 12, 2026

View your CI Pipeline Execution ↗ for commit 5d144e5


☁️ Nx Cloud last updated this comment at 2026-03-12 19:40:34 UTC

@nx-cloud
Copy link

nx-cloud bot commented Mar 12, 2026

View your CI Pipeline Execution ↗ for commit 15db791


☁️ Nx Cloud last updated this comment at 2026-03-12 18:26:13 UTC

@codecov
Copy link

codecov bot commented Mar 12, 2026

⚠️ JUnit XML file not found

The CLI was unable to find any JUnit XML files to upload.
For more help, visit our troubleshooting guide.

margin-top: 0;
margin-bottom: ${theme.spacing[16]};
${useLogicalProperties ? 'margin-block-start' : 'margin-top'}: 0;
${useLogicalProperties ? 'margin-block-end' : 'margin-bottom'}: 1rem;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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

Copy link
Member

Choose a reason for hiding this comment

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

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>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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

@LinKCoding LinKCoding marked this pull request as ready for review March 12, 2026 19:37
@LinKCoding LinKCoding requested a review from a team as a code owner March 12, 2026 19:37
@LinKCoding LinKCoding requested review from aresnik11 and sh0ji March 12, 2026 19:37
@codecademydev
Copy link
Collaborator

📬 Published Alpha Packages:

@codecademy/gamut@68.1.1-alpha.613ffe.0
@codecademy/gamut-icons@9.56.4-alpha.613ffe.0
@codecademy/gamut-illustrations@0.58.7-alpha.613ffe.0
@codecademy/gamut-kit@0.6.586-alpha.613ffe.0
@codecademy/gamut-patterns@0.10.26-alpha.613ffe.0
@codecademy/gamut-styles@17.12.1-alpha.613ffe.0
@codecademy/gamut-tests@5.3.1-alpha.613ffe.0
@codecademy/styleguide@79.2.1-alpha.613ffe.0

@github-actions
Copy link
Contributor

Copy link
Member

@sh0ji sh0ji left a comment

Choose a reason for hiding this comment

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

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;
Copy link
Member

Choose a reason for hiding this comment

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

weird, any idea what the cause of that flakiness is? smells like a canary to me.

Comment on lines +88 to +97
// 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} />
Copy link
Member

Choose a reason for hiding this comment

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

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.

  1. add useLogicalProperties to the Typography & Reboot props. For instance:
 <Reboot theme={theme} logicalProperties={useLogicalProperties />
  1. 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.

Copy link
Member

Choose a reason for hiding this comment

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

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.

Copy link
Member

@sh0ji sh0ji left a comment

Choose a reason for hiding this comment

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

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.

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.

4 participants