@fullstackunicorn/style 1.0.6 → 1.0.8
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/{commands.js → index.cmd.js} +2 -2
- package/{dependencies.js → index.dep.js} +3 -3
- package/index.js +2 -83
- package/{sources → modules/engine}/files.js +1 -1
- package/{sources → modules/engine}/logs.js +1 -1
- package/{sources → modules/engine}/parse.js +1 -1
- package/{sources → modules/engine}/style.js +1 -70
- package/modules/run.js +83 -0
- package/{sources → modules}/styles/base.js +16 -0
- package/package.json +22 -21
- package/README.md +0 -281
- /package/{abstracts → modules/abstracts}/init.js +0 -0
- /package/{sources → modules/engine}/color.js +0 -0
- /package/{sources → modules/engine}/font.js +0 -0
- /package/{sources → modules}/styles/border.js +0 -0
- /package/{sources → modules}/styles/flex.js +0 -0
- /package/{sources → modules}/styles/font.js +0 -0
- /package/{sources → modules}/styles/index.js +0 -0
- /package/{sources → modules}/styles/opacity.js +0 -0
- /package/{sources → modules}/styles/radius.js +0 -0
- /package/{sources → modules}/styles/size.js +0 -0
- /package/{sources → modules}/styles/space.js +0 -0
- /package/{sources → modules}/styles/text.js +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { fss, path} from '#@/
|
|
2
|
+
import { fss, path} from '#@/index.dep.js'
|
|
3
3
|
import { run } from '#@/index.js'
|
|
4
4
|
|
|
5
5
|
const configPath = path.resolve(process.cwd(), 'config.style.js')
|
|
6
6
|
|
|
7
7
|
if (!fss.exists(configPath)) {
|
|
8
|
-
console.error(`❌ Missing style.
|
|
8
|
+
console.error(`❌ Missing config.style.js in: ${process.cwd()}`)
|
|
9
9
|
process.exit(1)
|
|
10
10
|
}
|
|
11
11
|
|
package/index.js
CHANGED
|
@@ -1,84 +1,3 @@
|
|
|
1
1
|
import '@fullstackunicorn/initialize'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { style } from '#@/sources/style.js'
|
|
5
|
-
import { color } from '#@/sources/color.js'
|
|
6
|
-
import { font } from '#@/sources/font.js'
|
|
7
|
-
import { files } from '#@/sources/files.js'
|
|
8
|
-
import { logs } from '#@/sources/logs.js'
|
|
9
|
-
|
|
10
|
-
export const run = async (setup) => {
|
|
11
|
-
|
|
12
|
-
init.basePath(setup.BASE_PATH)
|
|
13
|
-
init.logs()
|
|
14
|
-
|
|
15
|
-
const isWeb = setup.isWeb
|
|
16
|
-
const isNative = setup.isNative
|
|
17
|
-
|
|
18
|
-
const isMono = setup.isMono
|
|
19
|
-
const defaultHtmlSass = setup.fontFamily.html ? `\n\n${setup.fontFamily.html}` : ``
|
|
20
|
-
const defaultSass = setup.defaultSass+defaultHtmlSass
|
|
21
|
-
|
|
22
|
-
const whole = 256
|
|
23
|
-
const grey = setup.saturation
|
|
24
|
-
|
|
25
|
-
const staticHues = {
|
|
26
|
-
|
|
27
|
-
WW: {R:256, G:256, B:256, name:'white'},
|
|
28
|
-
BB: {R:0, G:0, B:0, name:'black'},
|
|
29
|
-
NN: {R:128, G:128, B:128, name:'grey'},
|
|
30
|
-
...setup.staticHues
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const types = [
|
|
34
|
-
'base', // background-color
|
|
35
|
-
'item', // color
|
|
36
|
-
'line' // border-color
|
|
37
|
-
]
|
|
38
|
-
|
|
39
|
-
const parsed = await parse.project()
|
|
40
|
-
|
|
41
|
-
const fontList = parsed.f
|
|
42
|
-
const styleList = style.getList(parsed.s)
|
|
43
|
-
const colorList = color.getList(parsed.c)
|
|
44
|
-
const colors = color.getColors(staticHues, setup.hues, grey, whole)
|
|
45
|
-
|
|
46
|
-
const fontContents = font.getContents(fontList, setup.fontFamily, isWeb, isNative)
|
|
47
|
-
const colorContents = color.getContents(colorList, colors, whole, types, isWeb, isNative, isMono)
|
|
48
|
-
const styleContents = style.getContents(styleList, setup, isWeb, isNative)
|
|
49
|
-
|
|
50
|
-
if (isWeb) {
|
|
51
|
-
|
|
52
|
-
files.write('web_classes_fixed','js', styleContents.web.classes.fixed.sort())
|
|
53
|
-
files.write('web_classes_directional','js', styleContents.web.classes.directional.sort())
|
|
54
|
-
files.write('web_numbers','scss', styleContents.web.numbers.sort())
|
|
55
|
-
files.write('web_styles','scss', styleContents.web.style.sort())
|
|
56
|
-
|
|
57
|
-
files.write('web_classes_color','js', colorContents.web.classes.sort())
|
|
58
|
-
files.write('web_colors','scss', colorContents.web.colors.sort())
|
|
59
|
-
files.write('web_styles_colors','scss', colorContents.web.style.sort())
|
|
60
|
-
|
|
61
|
-
files.write('web_classes_font','js', fontContents.web.classes.sort())
|
|
62
|
-
files.write('web_fonts','scss', fontContents.web.style.sort())
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (isNative) {
|
|
66
|
-
|
|
67
|
-
files.write('native_classes_fixed','js', styleContents.native.classes.fixed.sort())
|
|
68
|
-
files.write('native_classes_directional','js', styleContents.native.classes.directional.sort())
|
|
69
|
-
files.write('native_styles','js', styleContents.native.style.sort())
|
|
70
|
-
|
|
71
|
-
files.write('native_classes_color','js', colorContents.native.classes.sort())
|
|
72
|
-
files.write('native_styles_colors','js', colorContents.native.style.sort())
|
|
73
|
-
|
|
74
|
-
files.write('native_classes_font','js', fontContents.native.classes.sort())
|
|
75
|
-
files.write('native_styles_fonts','js', fontContents.native.style.sort())
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
files.writeUse(isWeb, isNative, defaultSass, defaultHtmlSass)
|
|
79
|
-
files.writeFonts(fontContents.alphabets, fontContents.names)
|
|
80
|
-
|
|
81
|
-
logs.prepare( fontContents.fonts, colorContents, styleContents, parsed)
|
|
82
|
-
logs.toConsole()
|
|
83
|
-
logs.toMarkdown(setup.LOGS_PATH)
|
|
84
|
-
}
|
|
2
|
+
F3.service = '@fullstackunicorn/style'
|
|
3
|
+
export { run } from '#@/modules/run.js'
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { styles } from '#@/
|
|
1
|
+
import { styles } from '#@/modules/styles/index.js'
|
|
2
2
|
|
|
3
3
|
class Style {
|
|
4
4
|
|
|
@@ -66,75 +66,6 @@ class Style {
|
|
|
66
66
|
return result
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
// getContents = (list, { fonts }, isWeb, isNative) => {
|
|
70
|
-
|
|
71
|
-
// const present = []
|
|
72
|
-
// const missing = []
|
|
73
|
-
// const done = []
|
|
74
|
-
// const web = {
|
|
75
|
-
// classes: {
|
|
76
|
-
// fixed: [],
|
|
77
|
-
// directional: []
|
|
78
|
-
// },
|
|
79
|
-
// style: [],
|
|
80
|
-
// numbers: []
|
|
81
|
-
// }
|
|
82
|
-
// const native = {
|
|
83
|
-
// classes: {
|
|
84
|
-
// fixed: [],
|
|
85
|
-
// directional: []
|
|
86
|
-
// },
|
|
87
|
-
// style: [],
|
|
88
|
-
// }
|
|
89
|
-
|
|
90
|
-
// for (const { name, key, number } of list) {
|
|
91
|
-
|
|
92
|
-
// const is0 = number === 0
|
|
93
|
-
|
|
94
|
-
// const noStyle = !styles?.[key]?.write(number)
|
|
95
|
-
// // const noFont = key==='font' && (number>(fonts.length-1))
|
|
96
|
-
|
|
97
|
-
// // if (noStyle || noFont) {
|
|
98
|
-
// if (noStyle) {
|
|
99
|
-
// missing.push(name)
|
|
100
|
-
// continue
|
|
101
|
-
// }
|
|
102
|
-
|
|
103
|
-
// const { target, write, webClasses, webStyle, nativeClasses, nativeStyle } = styles[key]
|
|
104
|
-
|
|
105
|
-
// const isDone = this.exists(done, write(number))
|
|
106
|
-
// if (isDone) continue
|
|
107
|
-
|
|
108
|
-
// if (isWeb) {
|
|
109
|
-
// web.classes[target].push(...webClasses(number))
|
|
110
|
-
// web.style.push(...webStyle(number, fonts))
|
|
111
|
-
// const numString = `$px${number} : ${is0 ? 0 : number / 16}rem;`
|
|
112
|
-
// if (is0 || (number && !web.numbers.includes(numString))) web.numbers.push(numString)
|
|
113
|
-
// if (key === 'fpSup' || key === 'fpSub') {
|
|
114
|
-
// const num1 = Math.floor(number * 0.25)
|
|
115
|
-
// const num1String = `$px${num1} : ${is0 ? 0 : num1 / 16}rem;`
|
|
116
|
-
// if (num1 && !web.numbers.includes(num1String)) web.numbers.push(num1String)
|
|
117
|
-
// const num2 = Math.floor(number * 0.75)
|
|
118
|
-
// const num2String = `$px${num2} : ${is0 ? 0 : num2 / 16}rem;`
|
|
119
|
-
// if (num2 && !web.numbers.includes(num2String)) web.numbers.push(num2String)
|
|
120
|
-
// }
|
|
121
|
-
// }
|
|
122
|
-
|
|
123
|
-
// if (isNative) {
|
|
124
|
-
// native.classes[target].push(...nativeClasses(number))
|
|
125
|
-
// native.style.push(...nativeStyle(number, fonts))
|
|
126
|
-
// }
|
|
127
|
-
|
|
128
|
-
// present.push(...this.getPresent(list, write(number)))
|
|
129
|
-
// done.push(...write(number))
|
|
130
|
-
// }
|
|
131
|
-
|
|
132
|
-
// const response = { missing, present, done }
|
|
133
|
-
// if (isWeb) response.web = web
|
|
134
|
-
// if (isNative) response.native = native
|
|
135
|
-
// return response
|
|
136
|
-
// }
|
|
137
|
-
|
|
138
69
|
getContents = (list, { fonts }, isWeb, isNative) => {
|
|
139
70
|
|
|
140
71
|
const present = []
|
package/modules/run.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { init } from '#@/modules/abstracts/init.js'
|
|
2
|
+
import { parse } from '#@/modules/engine/parse.js'
|
|
3
|
+
import { style } from '#@/modules/engine/style.js'
|
|
4
|
+
import { color } from '#@/modules/engine/color.js'
|
|
5
|
+
import { font } from '#@/modules/engine/font.js'
|
|
6
|
+
import { files } from '#@/modules/engine/files.js'
|
|
7
|
+
import { logs } from '#@/modules/engine/logs.js'
|
|
8
|
+
|
|
9
|
+
export const run = async (setup) => {
|
|
10
|
+
|
|
11
|
+
init.basePath(setup.BASE_PATH)
|
|
12
|
+
init.logs()
|
|
13
|
+
|
|
14
|
+
const isWeb = setup.isWeb
|
|
15
|
+
const isNative = setup.isNative
|
|
16
|
+
|
|
17
|
+
const isMono = setup.isMono
|
|
18
|
+
const defaultHtmlSass = setup.fontFamily.html ? `\n\n${setup.fontFamily.html}` : ``
|
|
19
|
+
const defaultSass = setup.defaultSass+defaultHtmlSass
|
|
20
|
+
|
|
21
|
+
const whole = 256
|
|
22
|
+
const grey = setup.saturation
|
|
23
|
+
|
|
24
|
+
const staticHues = {
|
|
25
|
+
|
|
26
|
+
WW: {R:256, G:256, B:256, name:'white'},
|
|
27
|
+
BB: {R:0, G:0, B:0, name:'black'},
|
|
28
|
+
NN: {R:128, G:128, B:128, name:'grey'},
|
|
29
|
+
...setup.staticHues
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const types = [
|
|
33
|
+
'base', // background-color
|
|
34
|
+
'item', // color
|
|
35
|
+
'line' // border-color
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
const parsed = await parse.project()
|
|
39
|
+
|
|
40
|
+
const fontList = parsed.f
|
|
41
|
+
const styleList = style.getList(parsed.s)
|
|
42
|
+
const colorList = color.getList(parsed.c)
|
|
43
|
+
const colors = color.getColors(staticHues, setup.hues, grey, whole)
|
|
44
|
+
|
|
45
|
+
const fontContents = font.getContents(fontList, setup.fontFamily, isWeb, isNative)
|
|
46
|
+
const colorContents = color.getContents(colorList, colors, whole, types, isWeb, isNative, isMono)
|
|
47
|
+
const styleContents = style.getContents(styleList, setup, isWeb, isNative)
|
|
48
|
+
|
|
49
|
+
if (isWeb) {
|
|
50
|
+
|
|
51
|
+
files.write('web_classes_fixed','js', styleContents.web.classes.fixed.sort())
|
|
52
|
+
files.write('web_classes_directional','js', styleContents.web.classes.directional.sort())
|
|
53
|
+
files.write('web_numbers','scss', styleContents.web.numbers.sort())
|
|
54
|
+
files.write('web_styles','scss', styleContents.web.style.sort())
|
|
55
|
+
|
|
56
|
+
files.write('web_classes_color','js', colorContents.web.classes.sort())
|
|
57
|
+
files.write('web_colors','scss', colorContents.web.colors.sort())
|
|
58
|
+
files.write('web_styles_colors','scss', colorContents.web.style.sort())
|
|
59
|
+
|
|
60
|
+
files.write('web_classes_font','js', fontContents.web.classes.sort())
|
|
61
|
+
files.write('web_fonts','scss', fontContents.web.style.sort())
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (isNative) {
|
|
65
|
+
|
|
66
|
+
files.write('native_classes_fixed','js', styleContents.native.classes.fixed.sort())
|
|
67
|
+
files.write('native_classes_directional','js', styleContents.native.classes.directional.sort())
|
|
68
|
+
files.write('native_styles','js', styleContents.native.style.sort())
|
|
69
|
+
|
|
70
|
+
files.write('native_classes_color','js', colorContents.native.classes.sort())
|
|
71
|
+
files.write('native_styles_colors','js', colorContents.native.style.sort())
|
|
72
|
+
|
|
73
|
+
files.write('native_classes_font','js', fontContents.native.classes.sort())
|
|
74
|
+
files.write('native_styles_fonts','js', fontContents.native.style.sort())
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
files.writeUse(isWeb, isNative, defaultSass, defaultHtmlSass)
|
|
78
|
+
files.writeFonts(fontContents.alphabets, fontContents.names)
|
|
79
|
+
|
|
80
|
+
logs.prepare( fontContents.fonts, colorContents, styleContents, parsed)
|
|
81
|
+
logs.toConsole()
|
|
82
|
+
logs.toMarkdown(setup.LOGS_PATH)
|
|
83
|
+
}
|
|
@@ -75,4 +75,20 @@ export const ratioXY = {
|
|
|
75
75
|
webStyle: ({ X, Y }) => ([`.ratioXY_${X}_${Y} { aspect-ratio: ${X} / ${Y} }`]),
|
|
76
76
|
nativeClasses: ({ X, Y }) => ([`ratioXY_${X}_${Y}: style['ratioXY_${X}_${Y}']`]),
|
|
77
77
|
nativeStyle: ({ X, Y }) => ([`ratioXY_${X}_${Y}: { aspectRatio: ${X / Y} }`]),
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
// image normalize cover
|
|
82
|
+
|
|
83
|
+
export const cover = {
|
|
84
|
+
target: `fixed`,
|
|
85
|
+
write: (n='') => ([`cover`]),
|
|
86
|
+
webClasses: (n) => ([`cover: 'cover'`]),
|
|
87
|
+
webStyle: (n) => ([
|
|
88
|
+
`.cover { width: 100%; height: 100%; object-fit: cover; object-position: center; display: block }`
|
|
89
|
+
]),
|
|
90
|
+
nativeClasses: (n) => ([`cover: style['cover']`]),
|
|
91
|
+
nativeStyle: (n) => ([
|
|
92
|
+
`cover: { width: '100%', height: '100%', resizeMode: 'cover' }`
|
|
93
|
+
])
|
|
78
94
|
}
|
package/package.json
CHANGED
|
@@ -1,26 +1,25 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.
|
|
2
|
+
"version": "1.0.8",
|
|
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.",
|
|
6
|
-
"readme": "README.md",
|
|
7
|
-
"main": "index.js",
|
|
8
|
-
"type": "module",
|
|
9
6
|
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
10
8
|
"private": false,
|
|
9
|
+
"readme": "package.readme.md",
|
|
10
|
+
"main": "index.js",
|
|
11
|
+
"files": [
|
|
12
|
+
"index.js",
|
|
13
|
+
"index.dep.js",
|
|
14
|
+
"modules/"
|
|
15
|
+
],
|
|
16
|
+
"bin": {
|
|
17
|
+
"style": "./index.cmd.js"
|
|
18
|
+
},
|
|
11
19
|
"repository": {
|
|
12
20
|
"type": "git",
|
|
13
21
|
"url": "https://gitlab.com/fullstackunicorn/style.git"
|
|
14
22
|
},
|
|
15
|
-
"files": [
|
|
16
|
-
"index.js",
|
|
17
|
-
"dependencies.js",
|
|
18
|
-
"abstracts/",
|
|
19
|
-
"sources/"
|
|
20
|
-
],
|
|
21
|
-
"sideEffects": [
|
|
22
|
-
"commands.js"
|
|
23
|
-
],
|
|
24
23
|
"keywords": [
|
|
25
24
|
"style-generator",
|
|
26
25
|
"scss",
|
|
@@ -31,23 +30,25 @@
|
|
|
31
30
|
"responsive-design",
|
|
32
31
|
"fullstackunicorn"
|
|
33
32
|
],
|
|
33
|
+
"sideEffects": [
|
|
34
|
+
"index.cmd.js"
|
|
35
|
+
],
|
|
34
36
|
"imports": {
|
|
35
37
|
"#@": "./",
|
|
36
38
|
"#@/*": "./*"
|
|
37
39
|
},
|
|
38
|
-
"bin": {
|
|
39
|
-
"style": "./commands.js"
|
|
40
|
-
},
|
|
41
40
|
"scripts": {
|
|
42
|
-
"test": "
|
|
41
|
+
"test": "exit 1",
|
|
42
|
+
"run": "chmod +x ./config.run.sh && ./config.run.sh"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@fullstackunicorn/filesystem": "^1.0.
|
|
46
|
-
"@fullstackunicorn/initialize": "^1.0.
|
|
45
|
+
"@fullstackunicorn/filesystem": "^1.0.4",
|
|
46
|
+
"@fullstackunicorn/initialize": "^1.0.7",
|
|
47
47
|
"glob": "^13.0.0",
|
|
48
|
-
"sass": "^1.
|
|
48
|
+
"sass": "^1.96.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@fullstackunicorn/
|
|
51
|
+
"@fullstackunicorn/cli": "^1.0.3",
|
|
52
|
+
"@fullstackunicorn/reduce": "^1.0.19"
|
|
52
53
|
}
|
|
53
54
|
}
|
package/README.md
DELETED
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
# @fullstackunicorn/style
|
|
2
|
-
|
|
3
|
-
A cross‑platform styling engine for Web and React Native.
|
|
4
|
-
It generates unified utility classes, directional rules, responsive ratios, color‑mode styles, and typography maps — all from a single configuration file.
|
|
5
|
-
|
|
6
|
-
Designed for use inside FullstackUnicorn projects, but fully usable as a standalone styling system.
|
|
7
|
-
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
## ✨ Features
|
|
11
|
-
|
|
12
|
-
- **Unified Web + Native styling**
|
|
13
|
-
- **Utility‑first class system** (space, flex, size, radius, opacity, border…)
|
|
14
|
-
- **Automatic LTR/RTL handling**
|
|
15
|
-
- **Dark/Light color mode mapping**
|
|
16
|
-
- **Typography + font families abstraction**
|
|
17
|
-
- **Aspect‑ratio utilities (`ratio1`, `ratio_X16Y9`, …)**
|
|
18
|
-
- **Fully configurable via `style.config.js`**
|
|
19
|
-
- **Generates SCSS, JS modules, and React Native StyleSheet maps**
|
|
20
|
-
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
## 📦 Installation
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
yarn add @fullstackunicorn/style
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
or
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
npm install @fullstackunicorn/style
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
---
|
|
36
|
-
|
|
37
|
-
## 🧩 Usage
|
|
38
|
-
|
|
39
|
-
Create a `style.config.js` file in the root folder of the project:
|
|
40
|
-
|
|
41
|
-
```js
|
|
42
|
-
export default {
|
|
43
|
-
|
|
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' },
|
|
59
|
-
},
|
|
60
|
-
|
|
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
|
-
|
|
141
|
-
}
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
Generate styles:
|
|
145
|
-
|
|
146
|
-
```bash
|
|
147
|
-
yarn style
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
This will output a `/style/` folder containing:
|
|
151
|
-
|
|
152
|
-
```
|
|
153
|
-
/style
|
|
154
|
-
├── @use.js
|
|
155
|
-
├── @use.scss
|
|
156
|
-
├── web_styles.scss
|
|
157
|
-
├── native_styles.js
|
|
158
|
-
├── fonts.js
|
|
159
|
-
└── ...
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
---
|
|
163
|
-
|
|
164
|
-
## 🖥 Web and React Native Integration
|
|
165
|
-
|
|
166
|
-
Ensure you create in the root folder of the project the templates folder and index.js
|
|
167
|
-
|
|
168
|
-
```
|
|
169
|
-
/templates
|
|
170
|
-
├── index.js
|
|
171
|
-
└── ...
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
You can add as many blocks of styles you wish and later reuse it
|
|
175
|
-
|
|
176
|
-
```js
|
|
177
|
-
|
|
178
|
-
export const templates = (s, c, t) => {
|
|
179
|
-
|
|
180
|
-
t.server = getServer(s,c,t)
|
|
181
|
-
|
|
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]
|
|
188
|
-
|
|
189
|
-
return t
|
|
190
|
-
}
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
In each component import useStyle
|
|
194
|
-
|
|
195
|
-
```js
|
|
196
|
-
import { useStyle } from '#@/style/@use.js'
|
|
197
|
-
import { View } from '#@/imports/core/View.js'
|
|
198
|
-
|
|
199
|
-
export const BoxPod = ({ children }) => {
|
|
200
|
-
|
|
201
|
-
const { s, c, f, t, F, B, S, I, H } = useStyle()
|
|
202
|
-
|
|
203
|
-
S.box = [t.page.home, s.marginB16, c.base_C1_W600]
|
|
204
|
-
|
|
205
|
-
return (
|
|
206
|
-
<View classes={S.box}>
|
|
207
|
-
{children}
|
|
208
|
-
</View>
|
|
209
|
-
)
|
|
210
|
-
}
|
|
211
|
-
```
|
|
212
|
-
|
|
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
|
|
214
|
-
|
|
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
|
-
}
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
Native Component
|
|
233
|
-
```js
|
|
234
|
-
import { View as NativeView, Pressable as NativePressable, Platform } from 'react-native'
|
|
235
|
-
|
|
236
|
-
export const View = ({ classes = [], inline = {}, children, viewRef, setIsHover }) => {
|
|
237
|
-
|
|
238
|
-
const props = {}
|
|
239
|
-
props.style = [...classes, inline]
|
|
240
|
-
props.ref = viewRef
|
|
241
|
-
|
|
242
|
-
if (F3.isFnc(setIsHover)) {
|
|
243
|
-
|
|
244
|
-
props.onPressIn = () => setIsHover(true);
|
|
245
|
-
props.onPressOut = () => setIsHover(false);
|
|
246
|
-
return <NativePressable {...props}>{children}</NativePressable>
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
return <NativeView {...props}>{children}</NativeView>
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
---
|
|
255
|
-
|
|
256
|
-
## 🧪 Generated Classes
|
|
257
|
-
|
|
258
|
-
### Example utilities
|
|
259
|
-
|
|
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 |
|
|
269
|
-
|
|
270
|
-
## 🪪 License
|
|
271
|
-
|
|
272
|
-
MIT © fullstackunicorn.dev
|
|
273
|
-
|
|
274
|
-
---
|
|
275
|
-
|
|
276
|
-
## 📦 FullstackUnicorn Ecosystem
|
|
277
|
-
|
|
278
|
-
- `@fullstackunicorn/filesystem`
|
|
279
|
-
- `@fullstackunicorn/initialize`
|
|
280
|
-
- `@fullstackunicorn/reduce`
|
|
281
|
-
- `@fullstackunicorn/style` ← (this package)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|