diff --git a/.changepacks/changepack_log_react_native_pressed.json b/.changepacks/changepack_log_react_native_pressed.json new file mode 100644 index 000000000..9ed03be7e --- /dev/null +++ b/.changepacks/changepack_log_react_native_pressed.json @@ -0,0 +1,8 @@ +{ + "changes": { + "bindings/devup-ui-binding/package.json": "Patch", + "bindings/devup-ui-wasm/package.json": "Patch" + }, + "note": "`codeExtractNative` compiles press styles for React Native (part of #411): `_active` and its React Native name `_pressed` make the element a `Pressable` (a `Box`, `Flex`, `Center` or `VStack` becomes one, a `Button` already is) whose `style` is a function of whether it is pressed, `({ pressed }) => [styles.a, pressed && styles.b]`. Press styles combine with responsive values, themes, platforms, orientations and conditions, and work with `runtime: false` as they need no runtime. They are build errors on a `Text`, an `Image` or an `Input`, and with `as`. Web output is unchanged.", + "date": "2026-11-21T00:00:00.000Z" +} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 1696a4342..2bf0a8564 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -10,6 +10,7 @@ on: - feat/napi-binding - feat/react-native-metro - feat/react-native-themes + - feat/react-native-responsive # Pull requests and every job below run read-only. Only the `release` and # `deploy-pages` jobs get write permissions, and they run on pushes to main diff --git a/apps/expo/check-bundle.mjs b/apps/expo/check-bundle.mjs index 445677c7b..a7168e173 100644 --- a/apps/expo/check-bundle.mjs +++ b/apps/expo/check-bundle.mjs @@ -5,7 +5,8 @@ // must be there as React Native style objects. src/App.tsx reads the theme, // the breakpoint and the orientation, so it calls each of those hooks of the // runtime; src/Badge.tsx is styled the same in every theme and at every -// width, so it must not use the runtime. +// width, so it must not use the runtime. Its buttons take press styles, which +// React Native's `Pressable` applies through a function for `style`. import { readdirSync, readFileSync } from 'node:fs' import { join } from 'node:path' @@ -117,7 +118,12 @@ for (const platform of ['ios', 'android']) { if (code.includes(PLACEHOLDER)) { failures.push(`${platform}/${file}: holds "${PLACEHOLDER}"`) } - for (const style of ['backgroundColor:"#5a44ff"', 'StyleSheet']) { + for (const style of [ + 'backgroundColor:"#5a44ff"', + 'backgroundColor:"#4330d9"', + 'StyleSheet', + 'style:({pressed:', + ]) { if (!code.replaceAll(' ', '').includes(style)) { failures.push(`${platform}/${file}: lacks ${style}`) } diff --git a/apps/expo/src/App.tsx b/apps/expo/src/App.tsx index 02be3958e..624128e25 100644 --- a/apps/expo/src/App.tsx +++ b/apps/expo/src/App.tsx @@ -67,6 +67,7 @@ export function App() { gap={3} > + <__Pressable onPress={go} style={({ pressed: __p }) => [__b < 1 ? __s.g : __s.a, __p && __s.h]} /> + <__Pressable onPress={go} style={({ pressed: __p }) => [ + __s.i, + __p && (on ? __s.g : __s.a), + extra + ]}> + + + <__Pressable style={({ pressed: __p }) => __t === 1 && __p && __s.j} /> + + + + + + +