-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Set up twrnc theming for React Native component library #111
Conversation
"web": { | ||
"favicon": "./assets/favicon.png" | ||
} | ||
"userInterfaceStyle": "automatic" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For expo's theme switching capability
}, | ||
"web": { | ||
"favicon": "./assets/favicon.png" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unneeded things
"expo": "~49.0.23", | ||
"expo-status-bar": "~1.6.0", | ||
"expo-system-ui": "~2.4.0", | ||
"react-native-reanimated": "3.3.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needed for dark mode
return ( | ||
<View> | ||
<View style={tw`bg-primary-default p-3`}> | ||
<Button text="Sample Button" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding this here to show the theme switching colors
{ | ||
"path": "../design-system-twrnc-preset/tsconfig.build.json" | ||
} | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mcmire suggested to add this
export const useTailwind = () => { | ||
const { tw } = useContext(ThemeContext); | ||
return tw; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hook to be used instead of importing tw to get Themed tw
"build:docs": "typedoc", | ||
"changelog:update": "../../scripts/update-changelog.sh @metamask/design-system-twrnc-preset", | ||
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/design-system-twrnc-preset", | ||
"publish:preview": "yarn npm publish --tag preview", | ||
"since-latest-release": "../../scripts/since-latest-release.sh", | ||
"test": "NODE_OPTIONS=--experimental-vm-modules jest --reporters=jest-silent-reporter", | ||
"test": "NODE_OPTIONS=--experimental-vm-modules jest --reporters=jest-silent-reporter -passWithNoTests", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
temporary addition since tests will be added later #90
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Theming and Expo are working well! 🚀 I’ve left a few questions. This PR is quite large, and while I appreciate the comments, it would be helpful to provide even more. A self-review with additional context, especially on React Native specifics, would be valuable to break things down for future PRs since I'm less familiar with those areas.
I still think including the ThemeProvider within design-system-react-native could have simplified things by reducing complexity, dependencies, and overall overhead. That said, I’m on board with this approach to keep us aligned and moving forward.
- Pulled the branch and confirmed theming in Expo and Storybook ✅
👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎ This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored. Ignoring: Next stepsTake a deeper look at the dependencyTake a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev. Remove the packageIf you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency. Mark a package as acceptable riskTo ignore an alert, reply with a comment starting with |
@metamaskbot publish-preview |
@SocketSecurity ignore-all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description
This PR introduces Themed twrnc to metamask-design-system. It includes updates to
@metamask/design-system-twrnc-preset
to provide twrnc settings, provider, and hooks to be used to achieve the themed tailwind-like capabilities.@metamask/design-system-twrnc-preset
is also updated to be consumed by@metamask/design-system-react-native
and@metamask/storybook-react-native
with a simple example.Related issues
Fixes: #19
Manual testing steps
yarn install
in rootyarn storybook:ios
in rootCmd
+Shift
+A
or navigate to Features > Toggle Appearance for theme switchingScreenshots/Recordings
Before
After
Simulator.Screen.Recording.-.iPhone.15.Pro.Max.-.2024-11-13.at.16.08.29.mp4
Pre-merge author checklist
Pre-merge reviewer checklist