@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 +167 -104
- package/commands.js +4 -5
- package/dependencies.js +4 -1
- package/package.json +1 -1
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
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
103
|
-
const { s, c, t } }= useStyle()
|
|
178
|
+
export const templates = (s, c, t) => {
|
|
104
179
|
|
|
105
|
-
|
|
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
|
-
|
|
189
|
+
return t
|
|
190
|
+
}
|
|
191
|
+
```
|
|
116
192
|
|
|
117
|
-
|
|
193
|
+
In each component import useStyle
|
|
118
194
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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
|
-
|
|
201
|
+
const { s, c, f, t, F, B, S, I, H } = useStyle()
|
|
133
202
|
|
|
134
|
-
|
|
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
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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
|
-
|
|
232
|
+
Native Component
|
|
233
|
+
```js
|
|
234
|
+
import { View as NativeView, Pressable as NativePressable, Platform } from 'react-native'
|
|
163
235
|
|
|
164
|
-
|
|
165
|
-
Controls spacing/size utilities.
|
|
236
|
+
export const View = ({ classes = [], inline = {}, children, viewRef, setIsHover }) => {
|
|
166
237
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
238
|
+
const props = {}
|
|
239
|
+
props.style = [...classes, inline]
|
|
240
|
+
props.ref = viewRef
|
|
170
241
|
|
|
171
|
-
|
|
172
|
-
Creates color classes and React Native color styles.
|
|
242
|
+
if (F3.isFnc(setIsHover)) {
|
|
173
243
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
195
|
-
|
|
196
|
-
To update dependencies:
|
|
256
|
+
## ๐งช Generated Classes
|
|
197
257
|
|
|
198
|
-
|
|
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
|
-
##
|
|
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 '
|
|
3
|
-
import
|
|
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 (!
|
|
8
|
-
console.error(
|
|
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
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.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.",
|