@apple-pie/slice-native 0.1.4 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +164 -97
- package/SliceNative.podspec +24 -0
- package/dist/cjs/components.js +19 -0
- package/dist/cjs/hooks.js +9 -0
- package/dist/cjs/index.js +27 -812
- package/dist/cjs/providers.js +9 -0
- package/dist/cjs/src/components/SliceBackgroundBlur/SliceBackgroundBlur.js +11 -0
- package/dist/cjs/src/components/SliceButton/SliceButton.js +146 -0
- package/dist/cjs/src/components/SliceIcon/SliceIcon.js +20 -0
- package/dist/cjs/src/components/SliceIcon/iconRegistry.js +668 -0
- package/dist/cjs/src/components/SliceIcon/icons.js +144 -0
- package/dist/cjs/src/components/SliceLiquidGlassView/SliceLiquidGlassView.js +12 -0
- package/dist/cjs/src/components/SliceText/SliceText.js +21 -0
- package/dist/cjs/src/components/SliceTextInput/SliceTextInput.js +117 -0
- package/dist/cjs/src/hooks/useCreateThemedStyles/useCreateThemedStyles.js +13 -0
- package/dist/cjs/src/hooks/useDeviceCapabilities/useDeviceCapabilities.js +19 -0
- package/dist/cjs/src/providers/SliceThemeProvider.js +37 -0
- package/dist/cjs/src/theme/colors/colors.js +253 -0
- package/dist/cjs/src/theme/corners/corners.js +14 -0
- package/dist/cjs/src/theme/elevations/elevations.js +17 -0
- package/dist/cjs/src/theme/motion/motion.js +15 -0
- package/dist/cjs/src/theme/motion.js +47 -0
- package/dist/cjs/src/theme/spacing/spacing.js +14 -0
- package/dist/cjs/src/theme/type/type.js +190 -0
- package/dist/cjs/src/utils/sizes/sizes.js +40 -0
- package/dist/cjs/src/utils/typography/typography.js +17 -0
- package/dist/cjs/theme.js +23 -538
- package/dist/cjs/utils.js +10 -0
- package/dist/esm/components.mjs +7 -0
- package/dist/esm/hooks.mjs +2 -0
- package/dist/esm/index.mjs +12 -813
- package/dist/esm/providers.mjs +1 -0
- package/dist/esm/src/components/SliceBackgroundBlur/SliceBackgroundBlur.mjs +9 -0
- package/dist/esm/src/components/SliceButton/SliceButton.mjs +144 -0
- package/dist/esm/src/components/SliceIcon/SliceIcon.mjs +18 -0
- package/dist/esm/src/components/SliceIcon/iconRegistry.mjs +666 -0
- package/dist/esm/src/components/SliceIcon/icons.mjs +142 -0
- package/dist/esm/src/components/SliceLiquidGlassView/SliceLiquidGlassView.mjs +10 -0
- package/dist/esm/src/components/SliceText/SliceText.mjs +19 -0
- package/dist/esm/src/components/SliceTextInput/SliceTextInput.mjs +115 -0
- package/dist/esm/src/hooks/useCreateThemedStyles/useCreateThemedStyles.mjs +11 -0
- package/dist/esm/src/hooks/useDeviceCapabilities/useDeviceCapabilities.mjs +17 -0
- package/dist/esm/src/providers/SliceThemeProvider.mjs +33 -0
- package/dist/esm/src/theme/colors/colors.mjs +249 -0
- package/dist/esm/src/theme/corners/corners.mjs +12 -0
- package/dist/esm/src/theme/elevations/elevations.mjs +15 -0
- package/dist/esm/src/theme/motion/motion.mjs +13 -0
- package/dist/esm/src/theme/motion.mjs +45 -0
- package/dist/esm/src/theme/spacing/spacing.mjs +12 -0
- package/dist/esm/src/theme/type/type.mjs +184 -0
- package/dist/esm/src/utils/sizes/sizes.mjs +37 -0
- package/dist/esm/src/utils/typography/typography.mjs +15 -0
- package/dist/esm/theme.mjs +7 -522
- package/dist/esm/utils.mjs +2 -0
- package/dist/react-native/native/src/components/SliceBackgroundBlur/SliceBackgroundBlur.js +6 -0
- package/dist/react-native/native/src/components/SliceBackgroundBlur/SliceBackgroundBlur.native.js +6 -0
- package/dist/react-native/native/src/components/SliceBackgroundBlur/_types.js +1 -0
- package/dist/react-native/native/src/components/SliceBackgroundBlur/index.js +1 -0
- package/dist/react-native/native/src/components/SliceButton/SliceButton.js +141 -0
- package/dist/react-native/native/src/components/SliceButton/_types.js +1 -0
- package/dist/react-native/native/src/components/SliceButton/index.js +1 -0
- package/dist/react-native/native/src/components/SliceIcon/SliceIcon.js +15 -0
- package/dist/react-native/native/src/components/SliceIcon/_types.js +1 -0
- package/dist/react-native/native/src/components/SliceIcon/iconRegistry.js +663 -0
- package/dist/react-native/native/src/components/SliceIcon/icons.js +140 -0
- package/dist/react-native/native/src/components/SliceIcon/index.js +2 -0
- package/dist/react-native/native/src/components/SliceLiquidGlassView/SliceLiquidGlassView.ios.js +6 -0
- package/dist/react-native/native/src/components/SliceLiquidGlassView/SliceLiquidGlassView.js +7 -0
- package/dist/react-native/native/src/components/SliceLiquidGlassView/_types.js +1 -0
- package/dist/react-native/native/src/components/SliceLiquidGlassView/index.js +1 -0
- package/dist/react-native/native/src/components/SliceText/SliceText.js +16 -0
- package/dist/react-native/native/src/components/SliceText/_types.js +1 -0
- package/dist/react-native/native/src/components/SliceText/index.js +1 -0
- package/dist/react-native/native/src/components/SliceTextInput/SliceTextInput.js +111 -0
- package/dist/react-native/native/src/components/SliceTextInput/_types.js +1 -0
- package/dist/react-native/native/src/components/SliceTextInput/index.js +1 -0
- package/dist/react-native/native/src/components/index.js +6 -0
- package/dist/react-native/native/src/hooks/index.js +2 -0
- package/dist/react-native/native/src/hooks/useCreateThemedStyles/index.js +1 -0
- package/dist/react-native/native/src/hooks/useCreateThemedStyles/useCreateThemedStyles.js +8 -0
- package/dist/react-native/native/src/hooks/useDeviceCapabilities/_types.js +1 -0
- package/dist/react-native/native/src/hooks/useDeviceCapabilities/index.js +1 -0
- package/dist/react-native/native/src/hooks/useDeviceCapabilities/useDeviceCapabilities.js +14 -0
- package/dist/react-native/native/src/hooks/useDeviceCapabilities/useDeviceCapabilities.native.js +23 -0
- package/dist/react-native/native/src/index.js +6 -0
- package/dist/react-native/native/src/providers/SliceThemeProvider.js +30 -0
- package/dist/react-native/native/src/providers/index.js +1 -0
- package/dist/react-native/native/src/specs/BackgroundBlurNativeComponent.ts +16 -0
- package/dist/react-native/native/src/specs/LiquidGlassNativeComponent.ts +18 -0
- package/dist/react-native/native/src/specs/NativeDeviceCapabilities.ts +13 -0
- package/dist/react-native/native/src/theme/index.js +69 -0
- package/dist/react-native/native/src/theme/motion.js +43 -0
- package/dist/react-native/native/src/types/index.js +1 -0
- package/dist/react-native/native/src/types/sharedTypes.js +1 -0
- package/dist/react-native/native/src/utils/index.js +2 -0
- package/dist/react-native/native/src/utils/sizes/index.js +1 -0
- package/dist/react-native/native/src/utils/sizes/sizes.js +35 -0
- package/dist/react-native/native/src/utils/typography/index.js +1 -0
- package/dist/react-native/native/src/utils/typography/typography.js +13 -0
- package/dist/react-native/src/theme/colors/colors.js +385 -0
- package/dist/react-native/src/theme/colors/types.js +1 -0
- package/dist/react-native/src/theme/corners/corners.js +10 -0
- package/dist/react-native/src/theme/corners/types.js +1 -0
- package/dist/react-native/src/theme/elevations/_types.js +1 -0
- package/dist/react-native/src/theme/elevations/elevations.js +13 -0
- package/dist/react-native/src/theme/motion/_types.js +1 -0
- package/dist/react-native/src/theme/motion/motion.js +11 -0
- package/dist/react-native/src/theme/spacing/_types.js +1 -0
- package/dist/react-native/src/theme/spacing/spacing.js +10 -0
- package/dist/react-native/src/theme/type/type.js +371 -0
- package/dist/react-native/src/theme/type/types.js +1 -0
- package/dist/types/native/src/components/SliceBackgroundBlur/SliceBackgroundBlur.d.ts +3 -0
- package/dist/types/native/src/components/SliceBackgroundBlur/SliceBackgroundBlur.native.d.ts +2 -0
- package/dist/types/native/src/components/SliceBackgroundBlur/_types.d.ts +24 -0
- package/dist/types/native/src/components/SliceBackgroundBlur/index.d.ts +2 -0
- package/dist/types/native/src/components/SliceButton/SliceButton.d.ts +5 -0
- package/dist/types/native/src/components/SliceButton/_types.d.ts +78 -0
- package/dist/types/native/src/components/SliceButton/index.d.ts +2 -0
- package/dist/types/native/src/components/SliceIcon/SliceIcon.d.ts +2 -0
- package/dist/types/native/{components/Icon → src/components/SliceIcon}/icons.d.ts +1 -0
- package/dist/types/native/src/components/SliceIcon/index.d.ts +3 -0
- package/dist/types/native/src/components/SliceLiquidGlassView/SliceLiquidGlassView.d.ts +3 -0
- package/dist/types/native/src/components/SliceLiquidGlassView/SliceLiquidGlassView.ios.d.ts +2 -0
- package/dist/types/native/src/components/SliceLiquidGlassView/_types.d.ts +17 -0
- package/dist/types/native/src/components/SliceLiquidGlassView/index.d.ts +2 -0
- package/dist/types/native/src/components/SliceText/SliceText.d.ts +5 -0
- package/dist/types/native/src/components/SliceText/_types.d.ts +17 -0
- package/dist/types/native/src/components/SliceText/index.d.ts +2 -0
- package/dist/types/native/src/components/SliceTextInput/SliceTextInput.d.ts +2 -0
- package/dist/types/native/src/components/SliceTextInput/_types.d.ts +58 -0
- package/dist/types/native/src/components/SliceTextInput/index.d.ts +2 -0
- package/dist/types/native/src/components/index.d.ts +12 -0
- package/dist/types/native/src/hooks/index.d.ts +3 -0
- package/dist/types/native/src/hooks/useCreateThemedStyles/index.d.ts +1 -0
- package/dist/types/native/src/hooks/useCreateThemedStyles/useCreateThemedStyles.d.ts +7 -0
- package/dist/types/native/src/hooks/useDeviceCapabilities/_types.d.ts +17 -0
- package/dist/types/native/src/hooks/useDeviceCapabilities/index.d.ts +2 -0
- package/dist/types/native/src/hooks/useDeviceCapabilities/useDeviceCapabilities.d.ts +3 -0
- package/dist/types/native/src/hooks/useDeviceCapabilities/useDeviceCapabilities.native.d.ts +7 -0
- package/dist/types/native/src/index.d.ts +12 -0
- package/dist/types/native/src/providers/SliceThemeProvider.d.ts +16 -0
- package/dist/types/native/src/providers/index.d.ts +2 -0
- package/dist/types/native/src/specs/BackgroundBlurNativeComponent.d.ts +9 -0
- package/dist/types/native/src/specs/LiquidGlassNativeComponent.d.ts +9 -0
- package/dist/types/native/src/specs/NativeDeviceCapabilities.d.ts +11 -0
- package/dist/types/native/{theme → src/theme}/index.d.ts +5 -5
- package/dist/types/native/src/types/index.d.ts +1 -0
- package/dist/types/native/src/types/sharedTypes.d.ts +14 -0
- package/dist/types/native/src/utils/index.d.ts +2 -0
- package/dist/types/native/src/utils/sizes/index.d.ts +1 -0
- package/dist/types/native/src/utils/sizes/sizes.d.ts +7 -0
- package/dist/types/native/src/utils/typography/index.d.ts +1 -0
- package/dist/types/native/src/utils/typography/typography.d.ts +7 -0
- package/package.json +57 -11
- package/platform/android/build.gradle +22 -0
- package/platform/android/src/main/AndroidManifest.xml +1 -0
- package/platform/android/src/main/java/com/slice/SliceBackgroundBlurManager.java +28 -0
- package/platform/android/src/main/java/com/slice/SliceBackgroundBlurView.java +98 -0
- package/platform/android/src/main/java/com/slice/SliceDeviceCapabilitiesModule.java +25 -0
- package/platform/android/src/main/java/com/slice/SlicePackage.java +25 -0
- package/platform/ios/BackgroundBlurSurface.swift +89 -0
- package/platform/ios/LiquidGlassSurface.swift +82 -0
- package/platform/ios/RCTBackgroundBlurView.h +3 -0
- package/platform/ios/RCTBackgroundBlurView.mm +42 -0
- package/platform/ios/RCTLiquidGlassView.h +8 -0
- package/platform/ios/RCTLiquidGlassView.mm +73 -0
- package/platform/ios/SliceDeviceCapabilities.h +4 -0
- package/platform/ios/SliceDeviceCapabilities.mm +35 -0
- package/react-native.config.js +1 -0
- package/src/specs/BackgroundBlurNativeComponent.ts +16 -0
- package/src/specs/LiquidGlassNativeComponent.ts +18 -0
- package/src/specs/NativeDeviceCapabilities.ts +13 -0
- package/dist/types/native/components/Icon/NativeIcon.d.ts +0 -2
- package/dist/types/native/components/Icon/index.d.ts +0 -3
- package/dist/types/native/index.d.ts +0 -4
- /package/dist/types/native/{components/Icon → src/components/SliceIcon}/_types.d.ts +0 -0
- /package/dist/types/native/{components/Icon → src/components/SliceIcon}/iconRegistry.d.ts +0 -0
- /package/dist/types/native/{theme → src/theme}/motion.d.ts +0 -0
package/README.md
CHANGED
|
@@ -1,120 +1,187 @@
|
|
|
1
1
|
# @apple-pie/slice-native
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
**Alpha software — APIs, styling, and platform behavior may change between releases.**
|
|
4
|
+
|
|
5
|
+
A React Native UI kit with themed components, SVG icons, native blur, and Liquid Glass.
|
|
6
|
+
It shares Slice’s visual language with the web UIKit, but is packaged independently
|
|
7
|
+
and does not require `@apple-pie/slice` at runtime.
|
|
8
|
+
|
|
9
|
+
**Blur, gradient masking, Liquid Glass, and device capability detection are built
|
|
10
|
+
into this package and connected directly to native platform code.** No additional
|
|
11
|
+
blur, gradient, masking, or glass libraries are required—including `expo-blur`,
|
|
12
|
+
`expo-linear-gradient`, and `@react-native-masked-view/masked-view`.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npm install @apple-pie/slice-native
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Configure the package’s peer dependencies in your app: React 18/19, React Native
|
|
21
|
+
0.80+, `react-native-svg` 15, and Reanimated 4 with its compatible Worklets setup.
|
|
22
|
+
For Expo projects, use `npx expo install` for native peers to select compatible versions.
|
|
23
|
+
These general UI dependencies are separate from the built-in native visual effects.
|
|
24
|
+
|
|
25
|
+
Native components require the New Architecture. iOS builds require Xcode 26+.
|
|
26
|
+
Install iOS pods and rebuild your app after installing or updating the package.
|
|
27
|
+
Expo apps need a development build; the custom native components are not available
|
|
28
|
+
in Expo Go. Restarting Metro alone does not register new native code.
|
|
29
|
+
|
|
30
|
+
## Quick start
|
|
7
31
|
|
|
8
32
|
```tsx
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
33
|
+
import { View } from 'react-native';
|
|
34
|
+
import {
|
|
35
|
+
SliceButton,
|
|
36
|
+
SliceIcons,
|
|
37
|
+
SliceTextInput,
|
|
38
|
+
SliceThemeProvider,
|
|
39
|
+
} from '@apple-pie/slice-native';
|
|
40
|
+
|
|
41
|
+
export default function App() {
|
|
42
|
+
return (
|
|
43
|
+
<SliceThemeProvider>
|
|
44
|
+
<View style={{ padding: 24, gap: 16 }}>
|
|
45
|
+
<SliceTextInput accessibilityLabel="Search tasks" placeholder="Search…" />
|
|
46
|
+
<SliceButton icon={SliceIcons.ui.home} onPress={() => console.log('Home')}>
|
|
47
|
+
Go home
|
|
48
|
+
</SliceButton>
|
|
49
|
+
</View>
|
|
50
|
+
</SliceThemeProvider>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
18
53
|
```
|
|
19
54
|
|
|
20
|
-
|
|
21
|
-
native `style` objects; use `onPress` instead of `onClick`. CSS classes, cursor
|
|
22
|
-
styling (`pointer`), and browser keyboard handlers are not part of this API.
|
|
23
|
-
Use an enclosing React Native `Pressable` when you need a larger touch target or
|
|
24
|
-
button feedback, and mark the icon `accessible={false}` when it is decorative.
|
|
55
|
+
## Components
|
|
25
56
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
`
|
|
29
|
-
`
|
|
30
|
-
`
|
|
31
|
-
`
|
|
57
|
+
| Component | Summary |
|
|
58
|
+
| --- | --- |
|
|
59
|
+
| `SliceButton` | Primary/secondary buttons, optional icons, disabled states, Reanimated transitions, and optional Liquid Glass backgrounds. |
|
|
60
|
+
| `SliceTextInput` | Themed native input with icons, optional focus control, focus callbacks, and opt-in clearing on blur. |
|
|
61
|
+
| `StyledText` | Theme-based typography presets with native text props. |
|
|
62
|
+
| `SliceIcon` / `SliceIcons` | Native SVG artwork and typed icon names shared with the web UIKit. Supports toggles, fills, sizing, and press handlers. |
|
|
63
|
+
| `SliceLiquidGlassView` | Native glass container with children, tint, interaction feedback, and rounded corners. |
|
|
64
|
+
| `SliceBackgroundBlur` | Background blur overlay with an optional directional fade on iOS. |
|
|
32
65
|
|
|
33
|
-
|
|
34
|
-
|
|
66
|
+
Buttons and inputs support `size` (`s`, `m`, `l`, or a number), `borderRadius`
|
|
67
|
+
(`pill`, `rectangular`, or a number), `borderWidth`, `borderColor`, and
|
|
68
|
+
`backgroundColor`. Sizes define minimum heights, allowing room for larger text.
|
|
69
|
+
Inputs forward `style` to the underlying text field. Buttons expose `animatedStyle`
|
|
70
|
+
for their wrapper.
|
|
35
71
|
|
|
36
|
-
|
|
72
|
+
`SliceButton`, `SliceTextInput`, and `StyledText` use `SliceThemeProvider`. Give
|
|
73
|
+
inputs and icon-only buttons an accessible name. Icons inside these components
|
|
74
|
+
are decorative; standalone icons can use `accessibilityLabel` and `onPress`.
|
|
75
|
+
For `SliceIcon`, `fillColor` means fill opacity, not a color value.
|
|
37
76
|
|
|
38
|
-
|
|
39
|
-
generated artwork, and tests live in `native/components/Icon/`.
|
|
77
|
+
### Built-in Liquid Glass and blur
|
|
40
78
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
79
|
+
| Effect | iOS | Android | Web |
|
|
80
|
+
| --- | --- | --- | --- |
|
|
81
|
+
| `SliceLiquidGlassView` | Native Liquid Glass on iOS 26+; system blur on older iOS. | Tinted color fallback. | Tinted color fallback. |
|
|
82
|
+
| `SliceBackgroundBlur` | Native backdrop blur; optional directional fade. | Uniform backdrop blur when the required API is present (SDK 37.2+) and hardware acceleration is available; otherwise a color fallback. | Color fallback. |
|
|
45
83
|
|
|
46
|
-
|
|
84
|
+
The implementations ship with the package: Swift/UIKit and Fabric on iOS, and Java
|
|
85
|
+
platform code on Android. Consumers do not need to install another effects library.
|
|
86
|
+
iOS respects Reduce Transparency and renders a fallback when it is enabled.
|
|
47
87
|
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
npm run build --prefix native
|
|
54
|
-
```
|
|
88
|
+
```tsx
|
|
89
|
+
import { SliceBackgroundBlur, SliceLiquidGlassView } from '@apple-pie/slice-native';
|
|
90
|
+
|
|
91
|
+
// Place over background content; fills its parent by default.
|
|
92
|
+
<SliceBackgroundBlur blurIntensity={20} fadeStop={0.5} direction="down" />
|
|
55
93
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
94
|
+
<SliceLiquidGlassView cornerRadius={24} glassStyle="regular" style={{ padding: 20 }}>
|
|
95
|
+
{/* Foreground content */}
|
|
96
|
+
</SliceLiquidGlassView>
|
|
59
97
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
98
|
+
<SliceButton liquidGlassBackground={{ glassStyle: 'clear', fallbackColor: '#eeeeee' }}>
|
|
99
|
+
Continue
|
|
100
|
+
</SliceButton>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Blur defaults to intensity `12` and `fadeStop={0}`, which renders uniform blur
|
|
104
|
+
without a mask. A positive `fadeStop` (0–1) enables fading on iOS. Directions are
|
|
105
|
+
`down`, `up`, `left`, and `right`, from transparent toward full blur. Android
|
|
106
|
+
ignores fading props. This fades the visibility of a uniform blur rather than
|
|
107
|
+
varying the blur radius across the view.
|
|
63
108
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
109
|
+
Use `cornerRadius` to control a glass container’s shape. Supported glass buttons
|
|
110
|
+
keep their background transparent; unsupported devices use their solid background
|
|
111
|
+
or configured fallback. Both effect components accept `fallbackColor`. Avoid opaque
|
|
112
|
+
content over glass when you want the backdrop to remain visible. Android backdrop
|
|
113
|
+
blur samples the same window; separately composed surfaces such as video may differ.
|
|
68
114
|
|
|
69
|
-
|
|
70
|
-
`npm pack` to create a tarball. The `prepack` hook builds automatically. Build and
|
|
71
|
-
pack from this repository: generation uses the web artwork in `src/components/Icon`.
|
|
115
|
+
## Hooks, provider, and theme
|
|
72
116
|
|
|
73
|
-
|
|
117
|
+
| Export | Purpose |
|
|
118
|
+
| --- | --- |
|
|
119
|
+
| `SliceThemeProvider` | Light/dark themes; follows the system by default. Use `preference="light"` or `"dark"` to override. |
|
|
120
|
+
| `useSliceTheme()` | Returns the active theme. |
|
|
121
|
+
| `useSliceContext()` | Returns the theme, mode, preference, and optional preference setter. |
|
|
122
|
+
| `useCreateThemedStyles(factory)` | Creates memoized styles from the active theme. Define the factory outside the component for stable reuse. |
|
|
123
|
+
| `useDeviceCapabilities()` | Reports native effect support, platform, OS/API version, and device information. Does not require the theme provider. |
|
|
74
124
|
|
|
75
125
|
```tsx
|
|
76
|
-
|
|
77
|
-
|
|
126
|
+
const {
|
|
127
|
+
supportsLiquidGlass,
|
|
128
|
+
supportsNativeBlur,
|
|
129
|
+
platform,
|
|
130
|
+
iosVersion,
|
|
131
|
+
androidSdkVersion,
|
|
132
|
+
deviceName,
|
|
133
|
+
deviceModel,
|
|
134
|
+
} = useDeviceCapabilities();
|
|
135
|
+
```
|
|
78
136
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
137
|
+
Capability flags describe API availability, not live accessibility settings or
|
|
138
|
+
per-view rendering conditions. They return `false` when the native module is absent.
|
|
139
|
+
`iosVersion` is a full version string; `androidSdkVersion` is an integer API level
|
|
140
|
+
without minor-release information. Use the support flags for effects decisions.
|
|
141
|
+
Unavailable fields are `null`. iOS device names may be generic; its model is a
|
|
142
|
+
hardware identifier such as `iPhone17,1`, not a marketing name. Android reports
|
|
143
|
+
the system model name/code.
|
|
144
|
+
|
|
145
|
+
`lightTheme`, `darkTheme`, and `createTypography` are exported alongside theme types.
|
|
146
|
+
Themes include colors, spacing, corners, typography, shadows, stacking levels, and
|
|
147
|
+
motion. The `/theme` entry also exposes the underlying token groups. Typography
|
|
148
|
+
uses Funnel Sans by default; load it in your app or use `createTypography` with
|
|
149
|
+
your own loaded font. Fonts are not loaded by the package.
|
|
150
|
+
|
|
151
|
+
## Utilities and entry points
|
|
152
|
+
|
|
153
|
+
| Utility | Purpose |
|
|
154
|
+
| --- | --- |
|
|
155
|
+
| `sizeToNumber(size)` | Resolves size presets to points: `s` = 40, `m` = 48, `l` = 56. |
|
|
156
|
+
| `borderRadiusToNumber(radius)` | Resolves `pill` to 1000, `rectangular` to 4, and numeric radii to nonnegative points. |
|
|
157
|
+
| `lineHeightTextStyle(style, multiplier)` | Returns a new text style with an absolute line height. |
|
|
158
|
+
|
|
159
|
+
Public types include `Size`, `BorderRadius`, `LiquidGlassBackground`,
|
|
160
|
+
`DeviceCapabilities`, component props, and theme/provider types.
|
|
161
|
+
|
|
162
|
+
Import from the package root or the dedicated `/components`, `/hooks`, `/providers`,
|
|
163
|
+
`/theme`, and `/utils` entry points. ESM, CommonJS, TypeScript declarations, and
|
|
164
|
+
Metro platform files are included. Theme tokens and utilities can be used independently
|
|
165
|
+
of the component runtime.
|
|
166
|
+
|
|
167
|
+
## Development
|
|
168
|
+
|
|
169
|
+
From the repository root:
|
|
170
|
+
|
|
171
|
+
```sh
|
|
172
|
+
npm install
|
|
173
|
+
npm install --prefix native
|
|
174
|
+
npm run lint:ci --prefix native
|
|
175
|
+
npm run coverage --prefix native
|
|
176
|
+
npm run test:package --prefix native
|
|
177
|
+
npm run pack:tarball --prefix native
|
|
94
178
|
```
|
|
95
179
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
instead. Shadows use native `boxShadow` arrays, which require the New Architecture
|
|
105
|
-
and supported Android versions (outset shadows require Android 9+).
|
|
106
|
-
|
|
107
|
-
Typography uses a fixed 16dp base for rem conversion and numeric line heights and
|
|
108
|
-
letter spacing. Load Funnel Sans in your app, or replace `theme.type` with
|
|
109
|
-
`createTypography('YourLoadedFontName')`. Exact font weights depend on the font
|
|
110
|
-
and platform; test your loaded font on devices. This package does not load fonts.
|
|
111
|
-
|
|
112
|
-
Motion durations are milliseconds. Curve tokens are easing functions suitable for
|
|
113
|
-
`Animated.timing`'s `easing` option; the CSS spring is interpolated from its original
|
|
114
|
-
samples, preserving overshoot. They are ordinary JavaScript functions, not Reanimated
|
|
115
|
-
worklets. `elevations` retains the web stacking levels for `zIndex`; do not pass these
|
|
116
|
-
values to Android's `elevation` property.
|
|
117
|
-
|
|
118
|
-
Build from the repository so shared source tokens are available. All generated
|
|
119
|
-
JavaScript and declarations are included under `dist/`, including declarations for
|
|
120
|
-
shared source types. Changes to web tokens are picked up by the next native build.
|
|
180
|
+
Builds regenerate and automatically format native icons from the shared web artwork,
|
|
181
|
+
check types, and emit the package distributions. The tarball is written to
|
|
182
|
+
`native/pack/apple-pie-slice-native-<version>.tgz`; reinstall it and rebuild the
|
|
183
|
+
consuming native app when testing platform changes.
|
|
184
|
+
|
|
185
|
+
Browser documentation runs with `npm run storybook:native` from the repository root.
|
|
186
|
+
It previews web fallbacks; native effects need simulator/device checks. Native unit
|
|
187
|
+
coverage enforces a 95% overall threshold and does not measure Swift/Java rendering.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = 'SliceNative'
|
|
7
|
+
s.module_name = 'SliceNative'
|
|
8
|
+
s.version = package['version']
|
|
9
|
+
s.summary = package['description']
|
|
10
|
+
s.homepage = 'https://github.com/uris/slice'
|
|
11
|
+
s.license = package['license']
|
|
12
|
+
s.authors = package['author']
|
|
13
|
+
s.source = { :git => 'https://github.com/uris/slice.git', :tag => "native-v#{s.version}" }
|
|
14
|
+
s.platforms = { :ios => min_ios_version_supported }
|
|
15
|
+
s.swift_version = '5.0'
|
|
16
|
+
s.requires_arc = true
|
|
17
|
+
s.source_files = 'platform/ios/**/*.{h,m,mm,swift}'
|
|
18
|
+
# Keep C++ React headers out of the module imported by the Swift compiler.
|
|
19
|
+
s.private_header_files = 'platform/ios/RCT*View.h', 'platform/ios/SliceDeviceCapabilities.h'
|
|
20
|
+
s.frameworks = 'UIKit'
|
|
21
|
+
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
|
|
22
|
+
|
|
23
|
+
install_modules_dependencies(s)
|
|
24
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var SliceIcon = require('./src/components/SliceIcon/SliceIcon.js');
|
|
4
|
+
var icons = require('./src/components/SliceIcon/icons.js');
|
|
5
|
+
var SliceText = require('./src/components/SliceText/SliceText.js');
|
|
6
|
+
var SliceButton = require('./src/components/SliceButton/SliceButton.js');
|
|
7
|
+
var SliceTextInput = require('./src/components/SliceTextInput/SliceTextInput.js');
|
|
8
|
+
var SliceLiquidGlassView = require('./src/components/SliceLiquidGlassView/SliceLiquidGlassView.js');
|
|
9
|
+
var SliceBackgroundBlur = require('./src/components/SliceBackgroundBlur/SliceBackgroundBlur.js');
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
exports.SliceIcon = SliceIcon.SliceIcon;
|
|
14
|
+
exports.SliceIcons = icons.SliceIcons;
|
|
15
|
+
exports.StyledText = SliceText.StyledText;
|
|
16
|
+
exports.SliceButton = SliceButton.SliceButton;
|
|
17
|
+
exports.SliceTextInput = SliceTextInput.SliceTextInput;
|
|
18
|
+
exports.SliceLiquidGlassView = SliceLiquidGlassView.SliceLiquidGlassView;
|
|
19
|
+
exports.SliceBackgroundBlur = SliceBackgroundBlur.SliceBackgroundBlur;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var useCreateThemedStyles = require('./src/hooks/useCreateThemedStyles/useCreateThemedStyles.js');
|
|
4
|
+
var useDeviceCapabilities = require('./src/hooks/useDeviceCapabilities/useDeviceCapabilities.js');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
exports.useCreateThemedStyles = useCreateThemedStyles.useCreateThemedStyles;
|
|
9
|
+
exports.useDeviceCapabilities = useDeviceCapabilities.useDeviceCapabilities;
|