@apple-pie/slice-native 0.1.2 → 0.1.4
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 +50 -5
- package/dist/cjs/index.js +11 -0
- package/dist/cjs/theme.js +595 -0
- package/dist/esm/index.mjs +10 -2
- package/dist/esm/theme.mjs +585 -0
- package/dist/types/{components → native/components}/Icon/icons.d.ts +1 -0
- package/dist/types/native/index.d.ts +4 -0
- package/dist/types/native/theme/index.d.ts +287 -0
- package/dist/types/native/theme/motion.d.ts +2 -0
- package/dist/types/src/theme/colors/colors.d.ts +6 -0
- package/dist/types/src/theme/colors/types.d.ts +178 -0
- package/dist/types/src/theme/corners/corners.d.ts +2 -0
- package/dist/types/src/theme/corners/types.d.ts +10 -0
- package/dist/types/src/theme/elevations/_types.d.ts +10 -0
- package/dist/types/src/theme/elevations/elevations.d.ts +5 -0
- package/dist/types/src/theme/motion/_types.d.ts +8 -0
- package/dist/types/src/theme/motion/motion.d.ts +5 -0
- package/dist/types/src/theme/spacing/_types.d.ts +10 -0
- package/dist/types/src/theme/spacing/spacing.d.ts +2 -0
- package/dist/types/src/theme/type/type.d.ts +39 -0
- package/dist/types/src/theme/type/types.d.ts +23 -0
- package/package.json +11 -5
- package/dist/types/index.d.ts +0 -2
- /package/dist/types/{components → native/components}/Icon/NativeIcon.d.ts +0 -0
- /package/dist/types/{components → native/components}/Icon/_types.d.ts +0 -0
- /package/dist/types/{components → native/components}/Icon/iconRegistry.d.ts +0 -0
- /package/dist/types/{components → native/components}/Icon/index.d.ts +0 -0
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# @apple-pie/slice-native
|
|
2
2
|
|
|
3
3
|
Experimental React Native SVG icons, with the same names and artwork as the web UIKit.
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
Includes native light/dark theme tokens; other Slice components and a theme provider
|
|
5
|
+
are not included. It is built and published independently
|
|
6
6
|
of `@apple-pie/slice` and does not require that package at runtime.
|
|
7
7
|
|
|
8
8
|
```tsx
|
|
@@ -70,6 +70,51 @@ Run `npm pack --dry-run` from `native/` to inspect the publishable files, or
|
|
|
70
70
|
`npm pack` to create a tarball. The `prepack` hook builds automatically. Build and
|
|
71
71
|
pack from this repository: generation uses the web artwork in `src/components/Icon`.
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
## Theme tokens
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
import { Text, View, useColorScheme } from 'react-native';
|
|
77
|
+
import { lightTheme, darkTheme } from '@apple-pie/slice-native/theme';
|
|
78
|
+
|
|
79
|
+
function Card() {
|
|
80
|
+
const theme = useColorScheme() === 'dark' ? darkTheme : lightTheme;
|
|
81
|
+
return (
|
|
82
|
+
<View style={{
|
|
83
|
+
backgroundColor: theme.colors['core-surface-primary'],
|
|
84
|
+
padding: theme.spacing.m,
|
|
85
|
+
borderRadius: theme.corners['corner-m'],
|
|
86
|
+
...theme.shadows['surface-shadow-soft'],
|
|
87
|
+
}}>
|
|
88
|
+
<Text style={{ ...theme.type['body-m-regular'], color: theme.colors['core-text-primary'] }}>
|
|
89
|
+
Hello Slice
|
|
90
|
+
</Text>
|
|
91
|
+
</View>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
`lightTheme`, `darkTheme`, `createTypography`, and the `SliceNativeTheme` type are
|
|
97
|
+
also available from the package root. `SliceTheme` aliases the native theme type.
|
|
98
|
+
The dedicated `/theme` entry has no runtime React Native, React, or SVG imports.
|
|
99
|
+
It also exports `coreColors`, `corners`, `spacing`, `elevations`, `type`, and `motion`.
|
|
100
|
+
|
|
101
|
+
Colors, spacing, corners, and stacking levels are sourced from the web tokens at
|
|
102
|
+
build time and bundled into this package. No web package is needed in an app.
|
|
103
|
+
CSS shadow strings are removed from `colors` and `coreColors`; use `theme.shadows`
|
|
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.
|
package/dist/cjs/index.js
CHANGED
|
@@ -4,12 +4,19 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
4
4
|
var react = require('react');
|
|
5
5
|
var reactNative = require('react-native');
|
|
6
6
|
var Svg = require('react-native-svg');
|
|
7
|
+
var theme = require('./theme.js');
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Static icon registry created once at module load.
|
|
10
11
|
* Each entry stores only icon line content renderers.
|
|
11
12
|
*/
|
|
12
13
|
const STATIC_ICON_REGISTRY = new Map([
|
|
14
|
+
[
|
|
15
|
+
'@',
|
|
16
|
+
{
|
|
17
|
+
line: ({ strokeColor }) => (jsxRuntime.jsx(Svg.Path, { d: "M10.03,17.85c-1.61,0-3.01-.32-4.21-.97s-2.12-1.54-2.78-2.69c-.66-1.15-.98-2.49-.98-4.01,0-1.19.2-2.27.59-3.25s.96-1.83,1.69-2.54c.73-.72,1.6-1.27,2.61-1.66,1.01-.39,2.11-.58,3.33-.58,1.12,0,2.15.18,3.08.53.93.35,1.74.84,2.42,1.46.68.62,1.21,1.36,1.58,2.2s.56,1.77.56,2.77-.18,1.89-.55,2.67c-.37.78-.86,1.4-1.49,1.85-.63.45-1.33.67-2.11.67-.53,0-.96-.12-1.27-.37-.31-.24-.52-.61-.62-1.1h-.07c-.47.98-1.27,1.47-2.4,1.47-.69,0-1.29-.18-1.79-.53s-.9-.85-1.17-1.48c-.28-.63-.42-1.36-.42-2.19s.14-1.57.42-2.2c.28-.63.67-1.12,1.17-1.47.51-.35,1.1-.53,1.78-.53,1.13,0,1.93.48,2.38,1.45h.07v-1.25h1.57v7.02c.6,0,1.13-.17,1.58-.52.46-.34.81-.81,1.07-1.41.25-.59.38-1.26.38-2.01,0-1.07-.26-2.02-.77-2.86s-1.23-1.5-2.15-1.98-1.99-.73-3.22-.73c-1.33,0-2.51.27-3.53.83-1.02.55-1.82,1.31-2.39,2.29-.57.98-.86,2.13-.86,3.45,0,1.23.26,2.32.79,3.25.53.93,1.28,1.66,2.25,2.18.97.52,2.13.77,3.48.77h4.53v1.47h-4.55ZM9.83,12.93c.61,0,1.1-.2,1.47-.61s.56-.96.56-1.66v-1.13c0-.71-.19-1.27-.56-1.67s-.86-.6-1.47-.6c-.7,0-1.25.26-1.63.78-.39.52-.58,1.2-.58,2.06s.19,1.54.58,2.06c.39.52.93.77,1.63.77Z", fill: strokeColor })),
|
|
18
|
+
},
|
|
19
|
+
],
|
|
13
20
|
[
|
|
14
21
|
'fullscreen',
|
|
15
22
|
{
|
|
@@ -697,6 +704,7 @@ const SliceIcons = {
|
|
|
697
704
|
inbox: 'inbox',
|
|
698
705
|
like: 'like',
|
|
699
706
|
unlike: 'unlike',
|
|
707
|
+
at: '@',
|
|
700
708
|
},
|
|
701
709
|
media: {
|
|
702
710
|
camera: 'camera',
|
|
@@ -805,6 +813,9 @@ const SliceIcons = {
|
|
|
805
813
|
},
|
|
806
814
|
};
|
|
807
815
|
|
|
816
|
+
exports.createTypography = theme.createTypography;
|
|
817
|
+
exports.darkTheme = theme.darkTheme;
|
|
818
|
+
exports.lightTheme = theme.lightTheme;
|
|
808
819
|
exports.Icon = NativeIcon;
|
|
809
820
|
exports.NativeIcon = NativeIcon;
|
|
810
821
|
exports.SliceIcons = SliceIcons;
|