Repository navigation
Conversation
`_hover` and `_focus` read the `hovered` and `focused` that `Pressable` gives its style function, and make a `Box` a `Pressable` as `_active` does. An `Input` with `_focus` renders through the runtime's new `Focused`, which follows its focus events. `_disabled` applies while the element's `disabled` prop is true, or a `styled()` component's. In `css()` these are build errors. 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 #1047 (base:
feat/react-native-styled). PR 8 of the React Native plan: the remaining interaction states (_hover,_focus,_disabled) from the design's selector table.What it does
_hoverand_focusonPressable: they read thehoveredandfocusedthatPressablegives its style function. The function destructures only the keys the element reads. Like_active, they make aBox/Flex/Center/VStackaPressable. React Native reports them where the platform has a pointer or keyboard focus, such as the web through react-native-web (D5). On a phone's touch screen they never apply. This is documented._focuson anInput: aTextInputtells its focus only through events. The element therefore renders through a new runtime component,Focused.Focusedkeeps the focus state, still calls the element's ownonFocus/onBlur, and gives the style function(focused, theme, breakpoint, landscape). Inside a component, the theme hooks stay in the component. Outside one,Focusedreads them asThemeddoes._disabled: applies while the element'sdisabledprop is true. It compiles tobusy && __s.e, or to the style alone for a baredisabled. On an element withoutdisabledit never applies, so it is dropped. In astyled()component it reads the component'sdisabledprop:__props.disabled && …._hover,_focusand_disabledalso work instyled()(feat(native): styled() on React Native #1047).Runtime:
@devup-ui/react/nativeFocused(internal) is added. Size, measured withbun build --minify(react and react-native external) and thengzip -9:Build errors
_hover/_focus/_activeon aTextor anImage,_hoveron anInput, and any of them withascss():_hover,_focusand_active(fix: give them to the element)._disabledis also an error there, because only the element knows itsdisabled._focusVisible,_checked,_before, …), as beforeExpo example and CI
apps/expotakes_focus={{ borderColor: '#5a44ff' }}.check-bundle.mjsrequiressrc/App.tsxto useFocused. Locally,expo exportpasses the check.feat/react-native-styledis added to thepull_requestbranches of the workflow. It will be removed when this PR is retargeted.Tests
Button,BoxandInput;disabled, and a baredisabled;Focusedinside and outside a component, with theme and breakpoint values;styled()with states;css(), onText/Inputand withas.cargo test --workspacepasses. There are no web snapshot changes.-D warningsandcargo fmtare clean.cargo llvm-covshows every new line covered.Focused:#411의 일부이며 #1047에 의존합니다 (base:
feat/react-native-styled). React Native 계획의 8번째 PR로, 설계의 selector 표에 남아 있던 상호작용 상태(_hover,_focus,_disabled)를 다룹니다.변경 내용
Pressable의_hover와_focus:Pressable이 style 함수에 주는hovered와focused를 읽습니다. 함수는 요소가 읽는 키만 구조 분해합니다._active처럼Box/Flex/Center/VStack을Pressable로 만듭니다. React Native는 포인터나 키보드 포커스가 있는 플랫폼에서만 이 값을 알려 줍니다. react-native-web을 쓰는 웹(D5)이 그 예이고, 휴대폰 터치 화면에서는 적용되지 않습니다. 이 내용은 README에 문서화했습니다.Input의_focus:TextInput은 포커스를 이벤트로만 알려 줍니다. 그래서 이 요소는 새 런타임 컴포넌트Focused로 렌더링합니다.Focused는 포커스 상태를 관리하고, 요소의onFocus/onBlur도 그대로 호출하며, style 함수에(focused, theme, breakpoint, landscape)를 넘깁니다. 컴포넌트 안에서는 테마 hook이 컴포넌트에 그대로 남습니다. 컴포넌트 밖에서는Themed처럼Focused가 직접 읽습니다._disabled: 요소의disabledprop이 참일 때 적용되며,busy && __s.e로 컴파일됩니다.disabled만 쓰면 스타일만 남습니다.disabled가 없는 요소에서는 적용될 일이 없으므로 제거합니다.styled()컴포넌트에서는 컴포넌트의disabledprop을 읽습니다(__props.disabled && …)._hover,_focus,_disabled는styled()(feat(native): styled() on React Native #1047)에서도 동작합니다.런타임
@devup-ui/react/native내부용
Focused를 추가했습니다. 크기는bun build --minify(react와 react-native는 external)로 번들한 뒤gzip -9로 측정했습니다.빌드 에러
Text·Image의_hover/_focus/_active,Input의_hover,as와 함께 쓴 경우css()안의_hover,_focus,_active(요소에 주세요).disabled는 요소만 알기 때문에_disabled도 에러입니다._focusVisible,_checked,_before, …)는 이전과 같습니다.Expo 예제와 CI
apps/expo의 이름 입력란에_focus={{ borderColor: '#5a44ff' }}를 추가했습니다.check-bundle.mjs는src/App.tsx가Focused를 쓰는지 확인합니다. 로컬에서expo export가 검사를 통과했습니다.pull_requestbranches에feat/react-native-styled를 추가했습니다. 이 PR의 base를 바꿀 때 제거합니다.테스트
Button·Box·Input의 모든 상태;disabled가 있는 요소와 없는 요소, 값 없이 쓴disabled;Focused(테마·breakpoint 값 포함);styled();css(),Text/Input,as의 에러.cargo test --workspace가 통과합니다. 웹 snapshot 변경은 없습니다.-D warnings와cargo fmt는 깨끗합니다.cargo llvm-cov에서 새로 추가한 줄은 모두 커버됩니다.Focused런타임 bun 테스트:🤖 Generated with Claude Code