@fullstackunicorn/style 1.0.0 โ†’ 1.0.2

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
@@ -36,23 +36,108 @@ npm install @fullstackunicorn/style
36
36
 
37
37
  ## ๐Ÿงฉ Usage
38
38
 
39
- Create a `style.config.js` file in your project:
39
+ Create a `style.config.js` file in the root folder of the project:
40
40
 
41
41
  ```js
42
42
  export default {
43
- web: true,
44
- native: true,
45
43
 
46
- numbers: { min: 0, max: 80, step: 1 },
47
- colors: {
48
- primary: '#4A46FF',
49
- danger: '#FF3B30'
44
+ // BASE PATH:
45
+ BASE_PATH: './',
46
+
47
+ // PLATFORM:
48
+ isWeb: true,
49
+ isNative: false,
50
+
51
+ // SATURATION: 0 16 32 48 64 80 96 112 128 144 160 176 192 208 224 240 255
52
+ saturation: 128,
53
+
54
+ // HUES: ONE channel must be ZERO
55
+ hues: {
56
+ C1: { R: 0, G: 128, B: 256, name: 'blue' },
57
+ C2: { R: 256, G: 128, B: 0, name: 'orange' },
58
+ C3: { R: 256, G: 0, B: 128, name: 'pink' },
50
59
  },
51
60
 
52
- fonts: {
53
- heading: 'Inter-Bold',
54
- text: 'Inter-Regular'
55
- }
61
+ // STATIC HUES NOT AFFECTED BY SATURATION
62
+ staticHues: {
63
+ RR: { R: 256, G: 0, B: 0, name: 'error' },
64
+ OR: { R: 256, G: 128, B: 0, name: 'warning' },
65
+ },
66
+
67
+ // SET THE DEFAULTS FONTS FOR EACH PLATFORM
68
+ // SET THE FONTS FOR EACH ALPHABET
69
+ // ANY FONT MENTIONED IN THE ALPHABETH (es. f1, m1) MUST HAVE A DEFAULT (fallback)
70
+ fontFamily: {
71
+ html: `html { font-family: 'sans-serif'; font-weight: 400; };`,
72
+ defaults: {
73
+ f1: {
74
+ ios: 'System',
75
+ android: 'sans-serif',
76
+ web: 'sans-serif'
77
+ },
78
+ m1: {
79
+ ios: 'Courier New',
80
+ android: 'monospace',
81
+ web: 'monospace'
82
+ }
83
+ },
84
+ fonts: {
85
+ latin: {
86
+ f1: 'OpenSans',
87
+ m1: 'Inconsolata'
88
+ },
89
+ cyrillic: {
90
+ f1: 'OpenSans',
91
+ },
92
+ greek: {
93
+ f1: 'OpenSans',
94
+ },
95
+ arabic: {
96
+ f1: 'OpenSans',
97
+ },
98
+ chinese: {
99
+ f1: 'OpenSans',
100
+ },
101
+ japanese: {
102
+ f1: 'OpenSans',
103
+ },
104
+ }
105
+ },
106
+
107
+ // DEFAULT SASS
108
+ defaultSass:
109
+ `* {
110
+ padding:0;
111
+ margin:0;
112
+ border:0;
113
+ outline:none;
114
+ background-color:unset;
115
+ text-decoration:none;
116
+ box-sizing:border-box;
117
+ cursor:default;
118
+ // user-select: none;
119
+ };
120
+
121
+ html, body { max-width:100vw; overflow-x:hidden }
122
+
123
+ body { margin:0; padding:0 }
124
+
125
+ img { overflow-clip-margin:border-box; overflow:clip }
126
+
127
+ a {
128
+ &:link {color:unset; text-decoration: none}
129
+ &:visited {color:unset; text-decoration: none}
130
+ &:link:active {color:unset; text-decoration: none}
131
+ &:visited:active {color:unset; text-decoration: none}
132
+ };
133
+
134
+ h1, h2, h3, h4, h5, h6, p, a, span, input, textarea, option, button {
135
+ margin-block-start: 0;
136
+ margin-block-end: 0;
137
+ margin-inline-start: 0;
138
+ margin-inline-end: 0;
139
+ };`
140
+
56
141
  }
57
142
  ```
58
143
 
@@ -76,133 +161,111 @@ This will output a `/style/` folder containing:
76
161
 
77
162
  ---
78
163
 
79
- ## ๐Ÿ–ฅ Web Integration
164
+ ## ๐Ÿ–ฅ Web and React Native Integration
80
165
 
81
- Import the generated SCSS:
166
+ Ensure you create in the root folder of the project the templates folder and index.js
82
167
 
83
- ```scss
84
- @use './style/@use.scss';
85
168
  ```
86
-
87
- Use utilities:
88
-
89
- ```html
90
- <div class="p16 flex row gap8 radius4 bg-primary text-white">
91
- Hello Web UI
92
- </div>
169
+ /templates
170
+ โ”œโ”€โ”€ index.js
171
+ โ””โ”€โ”€ ...
93
172
  ```
94
173
 
95
- ---
96
-
97
- ## ๐Ÿ“ฑ React Native Integration
174
+ You can add as many blocks of styles you wish and later reuse it
98
175
 
99
176
  ```js
100
- import { useStyle } from './style/@use'
101
177
 
102
- export const MyComponent = () => {
103
- const { s, c, t } }= useStyle()
178
+ export const templates = (s, c, t) => {
104
179
 
105
- return (
106
- <View style={[s.flex, s.row, s.gap8]}>
107
- <Text style={t.heading}>Hello Native</Text>
108
- </View>
109
- )
110
- }
111
- ```
180
+ t.server = getServer(s,c,t)
112
181
 
113
- ---
182
+ t.page = {} // create a template for the pages
183
+ t.page.home = [s.col, s.XYc]
184
+ t.page.fluid = [s.col, s.XYc]
185
+ t.page.fixed = [s.col_cXsY, s.Yc, s.Xx, s.Xmax540, s.paddingX16]
186
+ t.page.docs = [s.col_cXsY, s.Yc, s.Xx, s.Xmax540, s.paddingX16, s.marginT16]
187
+ t.page.card = [s.col_cX, s.Yc, s.paddingX16]
114
188
 
115
- ## ๐Ÿงช Generated Classes
189
+ return t
190
+ }
191
+ ```
116
192
 
117
- ### Example utilities
193
+ In each component import useStyle
118
194
 
119
- | Utility | Meaning |
120
- |--------|----------|
121
- | `m16` | margin 16 |
122
- | `p8` | padding 8 |
123
- | `flex` | display flex |
124
- | `row` | flex-direction row |
125
- | `gap12` | gap 12 |
126
- | `radius4` | border-radius 4 |
127
- | `ratio1` | 1/1 square ratio |
128
- | `ratio_X16Y9` | 16/9 layout ratio |
195
+ ```js
196
+ import { useStyle } from '#@/style/@use.js'
197
+ import { View } from '#@/imports/core/View.js'
129
198
 
130
- ---
199
+ export const BoxPod = ({ children }) => {
131
200
 
132
- ## โš™๏ธ CLI
201
+ const { s, c, f, t, F, B, S, I, H } = useStyle()
133
202
 
134
- The package exposes the `style` CLI (handled by `commands.js` internally):
203
+ S.box = [t.page.home, s.marginB16, c.base_C1_W600]
135
204
 
205
+ return (
206
+ <View classes={S.box}>
207
+ {children}
208
+ </View>
209
+ )
210
+ }
136
211
  ```
137
- yarn style
138
- ```
139
-
140
- Outputs all generated styles into the `/style` folder.
141
212
 
142
- ---
143
-
144
- ## ๐Ÿ“ Project Structure
213
+ The View component should have the same interface for Web and Native, but in Native environment the Native component will be rendered and in Web environments the Web component will be rendered
145
214
 
146
- Example generated output:
147
-
148
- ```
149
- style/
150
- โ”œโ”€โ”€ @use.js
151
- โ”œโ”€โ”€ @use.scss
152
- โ”œโ”€โ”€ web_styles.scss
153
- โ”œโ”€โ”€ web_styles_colors.scss
154
- โ”œโ”€โ”€ native_styles.js
155
- โ”œโ”€โ”€ native_styles_colors.js
156
- โ”œโ”€โ”€ web_numbers.scss
157
- โ””โ”€โ”€ fonts.js
215
+ Web Component
216
+ ```js
217
+ export const View = ({
218
+ classes = [], inline = {}, children,
219
+ viewRef = null, setIsHover = () => { } }) => {
220
+ return (
221
+ <div className={classes.join(' ')} style={inline}
222
+ ref={viewRef}
223
+ onMouseEnter={() => setIsHover(true)}
224
+ onMouseLeave={() => setIsHover(false)}
225
+ >
226
+ {children}
227
+ </div>
228
+ )
229
+ }
158
230
  ```
159
231
 
160
- ---
161
-
162
- ## ๐Ÿงฑ Configuration Reference
232
+ Native Component
233
+ ```js
234
+ import { View as NativeView, Pressable as NativePressable, Platform } from 'react-native'
163
235
 
164
- ### `numbers`
165
- Controls spacing/size utilities.
236
+ export const View = ({ classes = [], inline = {}, children, viewRef, setIsHover }) => {
166
237
 
167
- ```js
168
- numbers: { min: 0, max: 80, step: 1 }
169
- ```
238
+ const props = {}
239
+ props.style = [...classes, inline]
240
+ props.ref = viewRef
170
241
 
171
- ### `colors`
172
- Creates color classes and React Native color styles.
242
+ if (F3.isFnc(setIsHover)) {
173
243
 
174
- ```js
175
- colors: {
176
- primary: '#4A46FF',
177
- surface: '#FFFFFF',
178
- text: '#000000'
179
- }
180
- ```
244
+ props.onPressIn = () => setIsHover(true);
245
+ props.onPressOut = () => setIsHover(false);
246
+ return <NativePressable {...props}>{children}</NativePressable>
247
+ }
181
248
 
182
- ### `fonts`
183
- Maps font families to identifiers.
249
+ return <NativeView {...props}>{children}</NativeView>
184
250
 
185
- ```js
186
- fonts: {
187
- h1: 'Inter-Bold',
188
- body: 'Inter-Regular'
189
251
  }
190
252
  ```
191
253
 
192
254
  ---
193
255
 
194
- ## ๐Ÿ”ง Development
195
-
196
- To update dependencies:
256
+ ## ๐Ÿงช Generated Classes
197
257
 
198
- ```bash
199
- yarn add @fullstackunicorn/filesystem
200
- yarn add @fullstackunicorn/initialize
201
- yarn add sass
202
- yarn add -D @fullstackunicorn/reduce
203
- ```
258
+ ### Example utilities
204
259
 
205
- ---
260
+ | Utility | Meaning |
261
+ |--------|----------|
262
+ | `s.margin16` | margin 16 |
263
+ | `s.padding8` | padding 8 |
264
+ | `s.row` | display flex, flex-direction row |
265
+ | `s.gap12` | gap 12 |
266
+ | `s.radius4` | border-radius 4 |
267
+ | `s.ratio1` | 1/1 square ratio |
268
+ | `s.ratio_X16Y9` | 16/9 layout ratio |
206
269
 
207
270
  ## ๐Ÿชช License
208
271
 
@@ -210,7 +273,7 @@ MIT ยฉ fullstackunicorn.dev
210
273
 
211
274
  ---
212
275
 
213
- ## ๐ŸŒˆ FullstackUnicorn Ecosystem
276
+ ## ๐Ÿ“ฆ FullstackUnicorn Ecosystem
214
277
 
215
278
  - `@fullstackunicorn/filesystem`
216
279
  - `@fullstackunicorn/initialize`
package/commands.js CHANGED
@@ -1,15 +1,14 @@
1
1
  #!/usr/bin/env node
2
- import path from 'node:path'
3
- import fs from 'node:fs'
2
+ import { fss, path} from '#@/dependencies.js'
3
+ import { run } from '#@/index.js'
4
4
 
5
5
  const configPath = path.resolve(process.cwd(), 'style.config.js')
6
6
 
7
- if (!fs.existsSync(configPath)) {
8
- console.error('โŒ Missing style.config.js in project root')
7
+ if (!fss.exists(configPath)) {
8
+ console.error(`โŒ Missing style.config.js in: ${cwd}`)
9
9
  process.exit(1)
10
10
  }
11
11
 
12
12
  const setup = (await import(configPath)).default
13
- import { run } from './sources/index.js'
14
13
 
15
14
  run(setup)
package/dependencies.js CHANGED
@@ -1,2 +1,5 @@
1
1
  // @FULLSTACKUNICORN
2
- export { fss } from '@fullstackunicorn/initialize'
2
+ export { fss } from '@fullstackunicorn/initialize'
3
+
4
+ // NODE
5
+ export { default as path } from 'node:path'
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.0",
2
+ "version": "1.0.2",
3
3
  "name": "@fullstackunicorn/style",
4
4
  "author": "lucanigido (https://fullstackunicorn.dev/author/lucanigido)",
5
5
  "description": "A development utility for generating responsive web and native styles (CSS, SCSS, JS, RN) from a declarative style.config.js file.",