Repository navigation
Conversation
`styled(Target)(...parts)`, `` styled(Target)`css text` `` and `styled(Target, styles)` compile to a function component rendering its target with the styles they describe, before the `style` it is given. The parts are those of `css()`; a function in them is called with the props, as a value or as a part giving what `css()` gives. A Devup UI target keeps the styles it declares first, a styled `Box` with a press style becomes a `Pressable`, and the hooks the styles read are called in the component. 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 #1046 (base:
feat/react-native-css). PR 7 of the React Native plan:styled().What it does
styled()compiles to a function component. The component renders its target with the styles it describes, followed by thestyleit is given. As the design planned, the static part is hoisted into theStyleSheet, and functions of the props become values and parts chosen at render:styled(Target)(...parts),styled(Target)`css text`andstyled(Target, styles).css()in feat(native): css() and className on React Native #1046:css()results;w: (p) => p.width, or an interpolation in CSS text, converted like a runtime value;css()gives:(p) => p.primary && css({...}).Flexkeeps its row).VieworAnimated.View, is rendered as it is.Boxmakes it aPressable(feat(native): press styles through Pressable on React Native #1045). A styledButtongets astylefunction.css()calls inside functions, are called at the top of the generated component.styled()can therefore be called at the top of the file even when its styles differ by theme or breakpoint.styledimport is removed.Build errors
styled('div')), or a target that is not a component namestyled(Target)that is not called with styles,styled(...parts),styledused other than as a call, andstyled(Target, styles, extra)(p) => ({ bg: p.color }), or a condition choosing such objects). React Native cannot read style props at runtime. Fix: return whatcss()gives, or write each value as a function.PressableKnown difference from the web, documented in the README:
<Card p={1} />passespon to the target instead of compiling it, because the component is not a Devup UI element. GivestyleorclassNameinstead.Expo example and CI
apps/expo/src/Badge.tsxis nowstyled(Text)({...}). It still uses no runtime:check-bundle.mjspasses locally.feat/react-native-cssis added to thepull_requestbranches of the workflow. It will be removed when this PR is retargeted.Tests
BoxandButton;cargo test --workspacepasses. There are no web snapshot changes.-D warningsandcargo fmtare clean.cargo llvm-covshows every new line covered.#411의 일부이며 #1046에 의존합니다 (base:
feat/react-native-css). React Native 계획의 7번째 PR인styled()입니다.변경 내용
styled()는 함수 컴포넌트로 컴파일됩니다. 이 컴포넌트는 target을 렌더링하면서styled()가 설명하는 스타일을 적용하고, 그 뒤에 자신이 받은style을 붙입니다. 설계대로 정적인 부분은StyleSheet로 끌어올리고, props의 함수는 렌더링할 때 고르는 값과 부분이 됩니다(위 예시 참고).styled(Target)(...parts),styled(Target)`css text`,styled(Target, styles)css()와 같습니다.css()결과;w: (p) => p.width또는 CSS 텍스트의 보간. 런타임 값처럼 변환합니다.css()결과를 돌려주는 부분:(p) => p.primary && css({...})Flex의 row).View,Animated.View등 그 밖의 컴포넌트는 그대로 렌더링합니다.Box는Pressable이 되고(feat(native): press styles through Pressable on React Native #1045), styledButton은style함수를 받습니다.css()가 읽는 hook도 포함됩니다. 그래서 테마나 breakpoint에 따라 스타일이 달라지더라도styled()를 파일 최상단에서 호출할 수 있습니다.styledimport는 제거됩니다.빌드 에러
styled('div')) 또는 컴포넌트 이름이 아닌 targetstyled(Target),styled(...parts), 호출이 아닌styled사용,styled(Target, styles, extra)(p) => ({ bg: p.color })또는 그런 객체를 고르는 조건식). React Native는 런타임에 style prop을 읽을 수 없습니다. 해결:css()결과를 돌려주거나, 값마다 함수로 쓰세요.Pressable로 만들 수 없는 target의 press 스타일웹과 다른 점(README에 문서화):
<Card p={1} />는p를 컴파일하지 않고 target에 그대로 넘깁니다. 이 컴포넌트는 Devup UI 요소가 아니기 때문입니다. 대신style이나className을 주세요.Expo 예제와 CI
apps/expo/src/Badge.tsx는 이제styled(Text)({...})입니다. 여전히 런타임을 쓰지 않으며, 로컬에서check-bundle.mjs를 통과했습니다.pull_requestbranches에feat/react-native-css를 추가했습니다. 이 PR의 base를 바꿀 때 제거합니다.테스트
Box와Button의 press 스타일;cargo test --workspace가 통과합니다. 웹 snapshot 변경은 없습니다.-D warnings와cargo fmt는 깨끗합니다.cargo llvm-cov에서 새로 추가한 줄은 모두 커버됩니다.🤖 Generated with Claude Code