chore: removing default font sizes and colors#739
Conversation
📖 Storybook Preview |
10151b0 to
0689466
Compare
📖 Storybook Preview |
0689466 to
fe1c7e0
Compare
📖 Storybook Preview |
| extend: {}, | ||
| }, | ||
| plugins: [], | ||
| }; |
There was a problem hiding this comment.
Updating the tailwind.config.js for intellisense. Going to look at generating this from tailwind.config.ts and pointing to the version that we can include in the twrnc preset
| white: '#ffffff', | ||
| }, | ||
| fontSize: {}, // This removes all default Tailwind font sizes. We want to rely on the design system font sizes and enforce use of the Text component | ||
| extend: {}, |
There was a problem hiding this comment.
Updated storybook Tailwind config to explicitly include essential semantic colors like inherit, current, transparent, black, and white, while removing the default palette (e.g., bg-red-500, bg-blue-400). I hadn’t realized that setting colors: {} also removes these semantic colors, which we still need. Although I previously added this to the preset, I was concerned about potentially breaking existing Tailwind projects. For now, we’ll manage this at the project level and ensure the @MetaMask/design-system-engineers team are code owners of these configuration files.
| !isDanger && | ||
| !isInverse && [ | ||
| 'bg-transparent border-2 border-icon-muted text-default', | ||
| 'border-2 border-icon-muted bg-transparent text-default', |
There was a problem hiding this comment.
📖 Storybook Preview |
| alignItems={BoxAlignItems.Center} | ||
| justifyContent={BoxJustifyContent.Between} | ||
| className="bg-transparent w-full px-4 py-2 hover:bg-hover active:bg-pressed md:px-8" | ||
| className="w-full px-4 py-2 hover:bg-hover active:bg-pressed md:px-8" |
There was a problem hiding this comment.
Removing unneeded bg-transparent classname
0f1125f to
5ae7103
Compare
| {/* Ethereum */} | ||
| <Pressable | ||
| style={tw`w-full flex-row items-center justify-between bg-transparent px-4 py-2`} | ||
| style={({ pressed }) => |
There was a problem hiding this comment.
Replacing unneeded bg-transparent with proper pressed example that mimics react example
📖 Storybook Preview |
| size={IconSize.Sm} | ||
| className={twMerge( | ||
| 'text-inherit mr-2 animate-spin', | ||
| 'mr-2 animate-spin text-inherit', |
| // Non-floating styles | ||
| !isFloating && [ | ||
| 'bg-transparent rounded', | ||
| 'rounded bg-transparent', |
There was a problem hiding this comment.
linting fixes now bg-transparent is being generated properly
| {...args} | ||
| name={IconName[iconKey as keyof typeof IconName]} | ||
| /> | ||
| <div className="text-center text-xs">{iconKey}</div> |
There was a problem hiding this comment.
Removing default font size classnames in favor of the text component. Also did a search for any font size classnames regex: \btext-(xs|sm|base|lg|xl|[2-9]xl)(/\d+)?\b
| name={IconName.AddSquare} | ||
| color={IconColor.IconDefault} | ||
| className="text-inherit text-lg" | ||
| className="text-inherit" |
There was a problem hiding this comment.
Removing unused font size classname
| color={IconColor.IconDefault} | ||
| size={IconSize.Md} | ||
| className="text-inherit h-10 w-10" | ||
| className="h-10 w-10 text-inherit" |
There was a problem hiding this comment.
Fixing inherit color classname
| const mergedClassName = twMerge( | ||
| // Reset padding, height and animations | ||
| 'bg-transparent h-auto rounded-none px-0', | ||
| 'h-auto rounded-none bg-transparent px-0', |
There was a problem hiding this comment.
Lint fix now bg-transparent is being generated
| fontSize: { | ||
| // Empty to remove default Tailwind font sizes (text-sm, text-lg, etc.) | ||
| // Design system font sizes added via extend | ||
| }, |
There was a problem hiding this comment.
Because mobile won't have a tailwind config we can update the generateTailwindConfig function
📖 Storybook Preview |
| black: '#000000', | ||
| white: '#ffffff', | ||
| }, | ||
| fontSize: {}, // This removes all default Tailwind font sizes. We want to rely on the design system font sizes and enforce use of the Text component |
There was a problem hiding this comment.
We remove all default font sizes to enforce the use of the Text component. We aren't removing the below there are no inherit or other semantic default tailwind classnames for font size
text-xs
text-sm
text-base
text-lg
text-xl
text-2xl
text-3xl
text-4xl
text-5xl
text-6xl
text-7xl
text-8xl
text-9xl
4928f42 to
423f0f4
Compare
📖 Storybook Preview |
… font size classnames
📖 Storybook Preview |
| @@ -1,7 +1,7 @@ | |||
| import type { Meta, StoryObj } from '@storybook/react'; | |||
📖 Storybook Preview |
There was a problem hiding this comment.
Bug: Misused Labels Confuse Screen Readers
Semantic HTML misuse: <label> elements are incorrectly used for text referenced by aria-labelledby and aria-describedby on ButtonBase components. Labels should only be used for form controls. This can confuse screen readers and assistive technologies. The affected elements should be div, span, or p.
packages/design-system-react/src/components/ButtonBase/ButtonBase.stories.tsx#L223-L251
Was this report helpful? Give feedback by reacting with 👍 or 👎






Description
This PR enforces the use of design system components by removing default Tailwind CSS utilities while preserving essential semantic utilities.
What is the reason for the change?
text-sm,text-lg) bypass our Text component and design system typographybg-blue-500,text-red-300) bypass our design system color tokensWhat is the improvement/solution?
text-xs,text-sm,text-base,text-lg,text-xl, etc.) to enforce use of the Text componentred-500,blue-600, etc.) while keeping essential semantic colors (inherit,current,transparent,black,white)active:bg-pressedto proper Pressable state managementRelated issues
Fixes: #740
Manual testing steps
yarn storybook:reactTextVariant.BodyMd,TextVariant.HeadingLg, etc.) work as expectedbg-transparentstill render correctly (should appear with transparent background)text-sm- should not apply stylesbg-red-500- should not apply stylestext-blue-300- should not apply stylesyarn storybook:react-nativeand test press states work correctlybg-transparent,text-inherit,bg-black,bg-whiteScreenshots/Recordings
Before
active:pseudo-classesbefore480.mov
before.mov
After
after.rn.mov
after.react.mov
Pre-merge author checklist
Pre-merge reviewer checklist