Repository navigation
Conversation
Their `styled` (with `styled.View` and any other `styled.Name`) and `css` compile as Devup UI's, with numbers as pixels as those packages read them. Function parts get `props.theme` from the runtime's new `ThemeProvider`, and `ThemeProvider`, `useTheme` and `withTheme` import from the React Native runtime, sharing the web compat theme context. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ement Tarpaulin counted the deferred `let pixels;` as an uncovered line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #411, depends on #1049 (base:
feat/react-native-animations). PR 10 of the React Native plan: compat forstyled-components/nativeand@emotion/native(design §8 step 7, and the "ThemeProvider, compatuseTheme/withTheme: context over the same store" row).What it does
Files importing
styled-components/nativeor@emotion/nativecompile with neither package at runtime. Theirstyledandcsscompile as Devup UI's, so the CSS is parsed once at build time. Those libraries otherwise parse it with css-to-react-native on every render.styled) isstyled, andcssiscss; both are removed.ThemeProviderandwithThemeimport from@devup-ui/react/native, anduseThemeimports as itsuseStyledTheme.ThemeContext).styled.Name:styled.View,styled.Text,styled.Pressableand any otherstyled.Namerender React Native's component of that name. It is imported once per file. This works for Devup UI's ownstyledtoo.styled(X)works as in feat(native): styled() on React Native #1047.styled.Pressabletakes press, hover and focus styles through itsstylefunction.styled.Name(feat(native): animations and transitions on react-native-reanimated #1049) renders Reanimated'sAnimated.View/Text/Image, orcreateAnimatedComponent.padding: 8is8, not Devup UI's8 * 4. Unitless properties (opacity,flex, …) and durations stay numbers. A value read at runtime converts at scale 1. On the web, compat also reads Emotion's numbers as pixels.$tokens, responsive arrays and_active-style blocks work in these styles too.theme, the theme of the nearestThemeProvider(athemeprop the caller gives wins). The hook is called only when a function part reads the props.styled()still rejects this, because it would need to convert style props.ThemeProvider,useStyledThemeandwithThemeare a React context. A provider's theme is merged over the outer provider's, or a function of that theme can make it. They reuse the web compat entry'sStyledThemeContextandwithTheme(forwarded refs, hoisted statics). Only the provider is new, because the web provider declares CSS variables.Runtime size
Measured with
bun build --minify(react, react-native and react/jsx-runtime external) and thengzip -9. Metro does not tree-shake, so an app using the runtime bundles all of it.Build errors
runtime: false:ThemeProvider,useThemeandwithThemefrom these packagesimport * as S from 'styled-components/native'), as for@devup-ui/reactExpo example and CI
dist/utils/theme-contextanddist/utils/with-theme.check-bundle.mjsaccepts those two modules as part of the runtime, and still rejects any other module of@devup-ui/react. Locally,expo exportpasses the check.feat/react-native-animationsis added to thepull_requestbranches of the workflow. It will be removed when this PR is retargeted.Tests
styled.TextCSS text that readsprops.theme;styled.Viewobjects with theme tokens,styled(Box), function parts, and kept imports;styled.Pressablepress styles, function objects, pixel numbers in objects and CSS text, runtime values, and animatedstyled.View/styled.Pressable;styled;runtime: falseand namespace errors;cargo test --workspacepasses. There are no web snapshot changes.-D warningsandcargo fmtare clean.cargo llvm-covshows every new line covered.withThemewith the context theme and with a given theme.#411의 일부이며 #1049에 의존합니다 (base:
feat/react-native-animations). React Native 계획의 10번째 PR로,styled-components/native와@emotion/nativecompat입니다(설계 §8의 7단계, 그리고 "ThemeProvider, compatuseTheme/withTheme: 같은 store 위의 context" 항목).변경 내용
styled-components/native나@emotion/native를 import하는 파일은 런타임에 두 패키지 없이 컴파일됩니다. 두 패키지의styled와css는 Devup UI의 것으로 컴파일되므로, CSS는 빌드할 때 한 번만 파싱합니다. 원래 라이브러리는 렌더링할 때마다 css-to-react-native로 파싱합니다(위 예시 참고).styled)는styled,css는css가 되며 둘 다 제거됩니다.ThemeProvider·withTheme는@devup-ui/react/native에서,useTheme는 그곳의useStyledTheme로 import합니다.ThemeContext).styled.Name:styled.View·styled.Text·styled.Pressable등 모든styled.Name은 같은 이름의 React Native 컴포넌트로 렌더링합니다. 이 컴포넌트는 파일마다 한 번 import합니다. Devup UI의styled에서도 동작하며,styled(X)는 #1047과 같습니다.styled.Pressable은style함수를 통해 press·hover·focus 스타일을 받습니다.styled.Name(feat(native): animations and transitions on react-native-reanimated #1049)은 Reanimated의Animated.View/Text/Image또는createAnimatedComponent로 렌더링합니다.padding: 8은 Devup UI의8 * 4가 아니라8입니다. 단위 없는 속성(opacity,flex등)과 duration은 숫자로 남습니다. 런타임에 읽는 값은 scale 1로 변환합니다. 웹의 compat도 Emotion의 숫자를 픽셀로 읽습니다.$토큰, 반응형 배열,_active같은 블록을 쓸 수 있습니다.theme을 더해 호출됩니다.theme은 가장 가까운ThemeProvider의 테마이며, 호출하는 쪽이 준themeprop이 우선합니다. hook은 함수 부분이 props를 읽을 때만 호출합니다.styled()는 style prop을 변환해야 하므로 여전히 에러입니다.ThemeProvider·useStyledTheme·withTheme는 React context입니다. provider의 테마는 바깥 provider의 테마 위에 병합되거나, 그 테마를 받는 함수로 만들 수 있습니다. 웹 compat entry의StyledThemeContext와withTheme(ref 전달, static hoist)를 재사용합니다. 웹 provider는 CSS 변수를 선언하므로, 새로 만든 것은 provider 하나뿐입니다.런타임 크기
bun build --minify(react, react-native, react/jsx-runtime은 external)로 번들한 뒤gzip -9로 측정했습니다. Metro는 tree-shaking을 하지 않으므로, 런타임을 쓰는 앱은 런타임 전체를 번들합니다.빌드 에러
runtime: false일 때 두 패키지의ThemeProvider·useTheme·withTheme@devup-ui/react와 마찬가지로 namespace import(import * as S from 'styled-components/native')Expo 예제와 CI
dist/utils/theme-context와dist/utils/with-theme를 import합니다.check-bundle.mjs는 이 두 모듈을 런타임의 일부로 인정하고,@devup-ui/react의 다른 모듈은 여전히 거부합니다. 로컬에서expo export가 검사를 통과했습니다.pull_requestbranches에feat/react-native-animations를 추가했습니다. 이 PR의 base를 바꿀 때 제거합니다.테스트
props.theme을 읽는 styled-components의styled.TextCSS 텍스트;styled.View객체,styled(Box), 함수 부분, 남는 import;styled.Pressablepress 스타일, 함수 객체, 객체와 CSS 텍스트 안의 픽셀 숫자, 런타임 값, 애니메이션이 있는styled.View/styled.Pressable;styled;runtime: false와 namespace 에러;cargo test --workspace가 통과합니다. 웹 snapshot 변경은 없습니다.-D warnings와cargo fmt는 깨끗합니다.cargo llvm-cov에서 새로 추가한 줄은 모두 커버됩니다.withTheme.🤖 Generated with Claude Code