react-native-varia 0.2.1 → 0.2.3

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 CHANGED
@@ -12,26 +12,188 @@ A Component library based on **react-native-unistyles** that provides a CLI tool
12
12
  yarn add -D react-native-varia
13
13
  ```
14
14
 
15
- You also need to install [react-native-unistyles](https://www.unistyl.es/v3/start/getting-started) for advanced styling capabilities:
15
+ You also need to install [react-native-unistyles](https://www.unistyl.es/v3/start/getting-started)
16
+
17
+ 2. Components dependencies
18
+
19
+ | Component | Dependencies |
20
+ | ------------------ | ---------------------------------------------------------------------------- |
21
+ | Badge | - |
22
+ | Button | react-native-svg |
23
+ | Checkbox | react-native-svg |
24
+ | CircleProgress | react-native-reanimated, react-native-svg |
25
+ | Field | - |
26
+ | GradientBackground | react-native-svg |
27
+ | GradientText | react-native-svg |
28
+ | Input | - |
29
+ | Link | - |
30
+ | Modal | react-native-reanimated, @gorhom/portal, react-native-svg |
31
+ | NumberInput | - |
32
+ | RadioGroup | - |
33
+ | ReText | react-native-reanimated |
34
+ | Select | @gorhom/portal |
35
+ | Slider | react-native-reanimated, react-native-gesture-handler, react-native-worklets |
36
+ | Slideshow | react-native-reanimated, react-native-gesture-handler, react-native-worklets |
37
+ | SlidingDrawer | react-native-reanimated, react-native-gesture-handler, react-native-worklets |
38
+ | Spinner | - |
39
+ | Switch | react-native-reanimated |
40
+
41
+ Install react-native-reanimated, react-native-worklets and react-native-gesture-handler.
16
42
 
17
- 2. Some components has reanimated dependency.
18
- If you are going to use the next components:
19
-
20
- - Slider
21
- - SlidingDrawer
22
- - Slideshow
23
- - Switch
24
- - ReText
25
- - Modal
26
-
27
- Install react-native-reanimated and react-native-worklets.
28
43
  Check the [react-native-reanimated](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started/) docs.
29
- And install react-native-gesture-handler.
44
+
30
45
  Check the [react-native-gesture-handler](https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/installation) docs.
31
46
 
32
- 3. Install react-native-svg.
47
+ Check the [react-native-worklets](https://docs.swmansion.com/react-native-worklets/docs/) docs.
48
+
49
+ Check the [react-native-svg](https://github.com/software-mansion/react-native-svg?tab=readme-ov-file#installation) docs.
50
+
51
+ Check the [react-native-portal](https://github.com/gorhom/react-native-portal) docs.
52
+
53
+ ## Varia setup
54
+
55
+ Now you need to run:
56
+
57
+ ```
58
+ npx varia setup
59
+ ```
60
+
61
+ This will copy the mixins, types and utils files from **lib** into **src/style/varia**.
62
+
63
+ ## About ColorPalettes
64
+
65
+ React Native Varia uses a color palette system to provide a consistent color scheme for your app. It is based on Radix color palette system.
66
+ Check the [Radix Color Palettes](https://www.radix-ui.com/colors/docs/palette-composition/scales) for more information.
67
+
68
+ Check how to [Compose a color palette](https://www.radix-ui.com/colors/docs/palette-composition/composing-a-palette) for more information.
69
+
70
+ Varia has the same color palettes as Radix built-in.
71
+ In the next section you will learn how to add them.
72
+
73
+ ## Creating your Theme
74
+
75
+ After setting up react-native unistyles theme, you will need to update it, to include the color palette system and default token needed for varia components.
76
+
77
+ In you src/style/themes.ts file, you will need to update it, to include the color palettes you will use:
78
+
79
+ ```ts
80
+ import {tomato} from './varia/colorPalettes/tomato'
81
+ import {teal} from './varia/colorPalettes/teal'
82
+ import {slate} from './varia/colorPalettes/slate'
83
+ import {iris} from './varia/colorPalettes/iris'
84
+ ```
85
+
86
+ Create a your preset with them, following how to [Compose a color palette](https://www.radix-ui.com/colors/docs/palette-composition/composing-a-palette) from radix you will set an accent and a gray color palette, and a red color palette is needed as well for default error styling in the components:
87
+
88
+ ```ts
89
+ import {slate} from './varia/colorPalettes/slate'
90
+ import {iris} from './varia/colorPalettes/iris'
91
+ import {red} from './varia/colorPalettes/red'
92
+
93
+ export const colorPalettes = createPreset({
94
+ accent: iris,
95
+ gray: slate,
96
+ red,
97
+ })
98
+ ```
33
99
 
34
- `yarn add react-native-svg`
100
+ Beside those color palettes you can add more optional color palettes to your theme.
101
+
102
+ ```ts
103
+ import {lime} from './varia/colorPalettes/lime'
104
+ import {olive} from './varia/colorPalettes/olive'
105
+ import {red} from './varia/colorPalettes/red'
106
+ import {yellow} from './varia/colorPalettes/yellow'
107
+ import {forest} from './varia/colorPalettes/forest'
108
+
109
+ export const colorPalettes = createPreset({
110
+ accent: lime,
111
+ gray: olive,
112
+ red,
113
+ yellow,
114
+ forest,
115
+ })
116
+ ```
117
+
118
+ Include de default theme tokens:
119
+
120
+ ```ts
121
+ import {
122
+ defaultColors,
123
+ defaultFontSizes,
124
+ defaultFontWeights,
125
+ defaultRadii,
126
+ defaultShadows,
127
+ defaultSizes,
128
+ defaultSpacing,
129
+ } from './varia/defaultTheme'
130
+ ```
131
+
132
+ Create the base theme, here you can override the default tokens with whatever you want:
133
+
134
+ ```ts
135
+ export const base = {
136
+ colors: {
137
+ ...defaultColors,
138
+ },
139
+ fontWeights: {
140
+ ...defaultFontWeights,
141
+ },
142
+ sizes: {
143
+ ...defaultSizes,
144
+ },
145
+ fontSizes: {
146
+ ...defaultFontSizes,
147
+ },
148
+ spacing: {
149
+ ...defaultSpacing,
150
+ },
151
+ radii: {
152
+ ...defaultRadii,
153
+ },
154
+ } as const
155
+ ```
156
+
157
+ Get the shadows tokens:
158
+
159
+ ```ts
160
+ const lightShadows = defaultShadows(colorPalettes.light)
161
+ const darkShadows = defaultShadows(colorPalettes.dark)
162
+ ```
163
+
164
+ Ensamble the light and dark theme, you can add extend here with independent light and dark colors:
165
+
166
+ ```ts
167
+ export const lightTheme = {
168
+ colors: {
169
+ ...base.colors,
170
+ ...colorPalettes.light,
171
+ },
172
+ fontSizes: base.fontSizes,
173
+ fontWeights: base.fontWeights,
174
+ spacing: base.spacing,
175
+ radii: base.radii,
176
+ sizes: base.sizes,
177
+ shadows: {
178
+ ...lightShadows,
179
+ },
180
+ } as const
181
+
182
+ export const darkTheme = {
183
+ colors: {
184
+ ...base.colors,
185
+ ...colorPalettes.dark,
186
+ },
187
+ fontSizes: base.fontSizes,
188
+ fontWeights: base.fontWeights,
189
+ spacing: base.spacing,
190
+ radii: base.radii,
191
+ sizes: base.sizes,
192
+ shadows: {
193
+ ...darkShadows,
194
+ },
195
+ } as const
196
+ ```
35
197
 
36
198
  ## ⚙️ Available Commands
37
199
 
@@ -47,7 +209,11 @@ Once installed, you can use the following commands via `npx varia`:
47
209
 
48
210
  | Command | Description |
49
211
  | -------------------------------- | -------------------------------------------------------------------------------- |
50
- | `npx varia setup` | Copies the mixins, types and utils files from **lib** into **src/style**. |
51
- | `npx varia add <component_name>` | Copies the specified component from **lib/components** into your project. |
212
+ | `npx varia setup` | Adds the mixins, types and utils files from to **src/style/varia**. |
213
+ | `npx varia add <component_name>` | Adds the specified component into your project **src/components**. |
52
214
  | `npx varia add-icon <icon_name>` | Copies the **Icon.tsx** template and renames it to the specified icon name. |
53
215
  | `npx varia add-patterns` | Copies the entire **lib/patterns** folder into **src/patterns** in your project. |
216
+
217
+ ```
218
+
219
+ ```