@symbo.ls/scratch 0.3.18 → 0.3.21
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/package.json +16 -8
- package/src/config/document.js +2 -2
- package/src/config/index.js +1 -0
- package/src/config/media.js +2 -1
- package/src/config/spacing.js +1 -1
- package/src/index.js +1 -1
- package/src/reset.js +42 -38
- package/src/set.js +2 -2
- package/src/utils/font.js +15 -7
package/package.json
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
"name": "@symbo.ls/scratch",
|
|
3
3
|
"description": "Φ / CSS framework and methodology.",
|
|
4
4
|
"author": "Symbols",
|
|
5
|
-
"version": "0.3.
|
|
5
|
+
"version": "0.3.21",
|
|
6
6
|
"files": [
|
|
7
7
|
"src"
|
|
8
8
|
],
|
|
9
9
|
"repository": "https://github.com/rackai/scratch",
|
|
10
|
-
"
|
|
10
|
+
"source": "src/index.js",
|
|
11
|
+
"main": "build/main.js",
|
|
11
12
|
"publishConfig": {},
|
|
12
13
|
"dependencies": {
|
|
13
14
|
"color-contrast-checker": "^1.5.0"
|
|
@@ -19,19 +20,21 @@
|
|
|
19
20
|
"bump": "npx np"
|
|
20
21
|
},
|
|
21
22
|
"devDependencies": {
|
|
22
|
-
"@babel/core": "^7.0.0-0",
|
|
23
23
|
"@babel/preset-env": "^7.18.9",
|
|
24
|
-
"babel-eslint": "^10.0.3",
|
|
25
24
|
"babel-jest": "^27.0.2",
|
|
26
25
|
"babel-preset-env": "^1.7.0",
|
|
27
26
|
"coveralls": "^3.0.5",
|
|
28
|
-
"eslint": "^7.12.1",
|
|
29
27
|
"eslint-plugin-jest": "^24.1.0",
|
|
30
28
|
"jest": "^27.0.6",
|
|
31
29
|
"nodemon": "^2.0.6",
|
|
32
30
|
"np": "^7.2.0",
|
|
33
|
-
"
|
|
34
|
-
"
|
|
31
|
+
"@babel/core": "^7.11.5",
|
|
32
|
+
"@emotion/css": "^11.5.0",
|
|
33
|
+
"babel-eslint": "^10.0.3",
|
|
34
|
+
"eslint": "^6.1.0",
|
|
35
|
+
"parcel-bundler": "^1.12.3",
|
|
36
|
+
"parcel-plugin-svg-sprite": "^1.4.1",
|
|
37
|
+
"standard": "^13.1.0"
|
|
35
38
|
},
|
|
36
39
|
"jest": {
|
|
37
40
|
"collectCoverageFrom": [
|
|
@@ -47,5 +50,10 @@
|
|
|
47
50
|
"browserslist": [
|
|
48
51
|
"> 1%",
|
|
49
52
|
"ie >= 9"
|
|
50
|
-
]
|
|
53
|
+
],
|
|
54
|
+
"targets": {
|
|
55
|
+
"context": "browser",
|
|
56
|
+
"outputFormat": "commonjs",
|
|
57
|
+
"includeNodeModules": true
|
|
58
|
+
}
|
|
51
59
|
}
|
package/src/config/document.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
import { FONT_FAMILY, THEME, TYPOGRAPHY } from '.'
|
|
4
|
-
import { merge } from '../utils'
|
|
4
|
+
import { getDefaultOrFirstKey, merge } from '../utils'
|
|
5
5
|
|
|
6
6
|
export const DOCUMENT = {}
|
|
7
7
|
|
|
8
8
|
export const applyDocument = () => merge(DOCUMENT, {
|
|
9
9
|
theme: THEME.document,
|
|
10
|
-
fontFamily:
|
|
10
|
+
fontFamily: getDefaultOrFirstKey(FONT_FAMILY),
|
|
11
11
|
fontSize: TYPOGRAPHY.base,
|
|
12
12
|
lineHeight: TYPOGRAPHY.styles.lineHeight
|
|
13
13
|
})
|
package/src/config/index.js
CHANGED
package/src/config/media.js
CHANGED
package/src/config/spacing.js
CHANGED
package/src/index.js
CHANGED
package/src/reset.js
CHANGED
|
@@ -4,41 +4,45 @@ import * as CONFIG from './config'
|
|
|
4
4
|
import { getTheme } from './set'
|
|
5
5
|
import { deepMerge, merge } from './utils'
|
|
6
6
|
|
|
7
|
-
export const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
7
|
+
export const applyReset = (reset = {}) => {
|
|
8
|
+
return deepMerge(merge(CONFIG.RESET, reset), {
|
|
9
|
+
html: {
|
|
10
|
+
position: 'absolute',
|
|
11
|
+
overflow: 'hidden',
|
|
12
|
+
width: '100%',
|
|
13
|
+
height: '100%',
|
|
14
|
+
top: '0',
|
|
15
|
+
left: '0',
|
|
16
|
+
margin: '0',
|
|
17
|
+
WebkitFontSmoothing: 'antialiased',
|
|
18
|
+
transform: 'translate3d(0, 0, 1px)',
|
|
19
|
+
scrollBehavior: 'smooth',
|
|
20
|
+
|
|
21
|
+
fontFamily: CONFIG.DOCUMENT.fontFamily,
|
|
22
|
+
fontSize: CONFIG.DOCUMENT.fontSize / CONFIG.TYPOGRAPHY.default + CONFIG.UNIT.default,
|
|
23
|
+
lineHeight: CONFIG.DOCUMENT.lineHeight
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
body: {
|
|
27
|
+
boxSizing: 'border-box',
|
|
28
|
+
height: '100%',
|
|
29
|
+
margin: 0,
|
|
30
|
+
fontFamily: CONFIG.DOCUMENT.fontFamily,
|
|
31
|
+
|
|
32
|
+
...getTheme('document')
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
...CONFIG.TYPOGRAPHY.styles,
|
|
36
|
+
|
|
37
|
+
// form elements
|
|
38
|
+
fieldset: {
|
|
39
|
+
border: 0,
|
|
40
|
+
padding: 0,
|
|
41
|
+
margin: 0
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
select: {
|
|
45
|
+
fontFamily: CONFIG.DOCUMENT.fontFamily
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
}
|
package/src/set.js
CHANGED
|
@@ -221,7 +221,7 @@ export const getFontFamily = (LIBRARY, key) => {
|
|
|
221
221
|
const setFontFamily = (val, key) => {
|
|
222
222
|
const { FONT_FAMILY, FONT_FAMILY_TYPES } = CONFIG
|
|
223
223
|
const { value, type } = val
|
|
224
|
-
if (val.
|
|
224
|
+
if (val.isDefault) FONT_FAMILY.default = key
|
|
225
225
|
|
|
226
226
|
const CSSvar = `--font-family-${key}`
|
|
227
227
|
const str = `${value.join(', ')}, ${FONT_FAMILY_TYPES[type]}`
|
|
@@ -296,8 +296,8 @@ export const set = recivedConfig => {
|
|
|
296
296
|
// apply generic configs
|
|
297
297
|
applyTypographySequence()
|
|
298
298
|
applySpacingSequence()
|
|
299
|
-
applyDocument()
|
|
300
299
|
applyTimingSequence()
|
|
300
|
+
applyDocument()
|
|
301
301
|
applyReset()
|
|
302
302
|
|
|
303
303
|
CONFIG.VARS = CSS_VARS
|
package/src/utils/font.js
CHANGED
|
@@ -3,30 +3,38 @@
|
|
|
3
3
|
export const getDefaultOrFirstKey = (LIBRARY, key) => {
|
|
4
4
|
if (LIBRARY[key]) return LIBRARY[key].value
|
|
5
5
|
if (LIBRARY.default) return LIBRARY[LIBRARY.default].value
|
|
6
|
-
|
|
6
|
+
const hasValue = Object.keys(LIBRARY)[0]
|
|
7
|
+
return hasValue && LIBRARY[hasValue] && LIBRARY[hasValue].value
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
export const getFontFormat = url => url.split(/[#?]/)[0].split('.').pop().trim()
|
|
10
11
|
|
|
11
|
-
export const setCustomFont = (name, weight, url) =>
|
|
12
|
+
export const setCustomFont = (name, weight, url) => `
|
|
12
13
|
font-family: '${name}';
|
|
13
14
|
font-style: normal;
|
|
14
15
|
font-weight: ${weight};
|
|
15
|
-
src: url('${url}') format('${getFontFormat(url)}')
|
|
16
|
+
src: url('${url}') format('${getFontFormat(url)}');`
|
|
17
|
+
|
|
18
|
+
export const setCustomFontMedia = (name, weight, url) => `@font-face {
|
|
19
|
+
${setCustomFont((name, weight, url))}
|
|
16
20
|
}`
|
|
17
21
|
// src: url('${url}') format('${getFontFormat(url)}');
|
|
18
22
|
|
|
19
23
|
export const getFontFaceEach = (name, weightsObject) => {
|
|
20
24
|
const keys = Object.keys(weightsObject)
|
|
21
|
-
|
|
25
|
+
return keys.map(key => {
|
|
22
26
|
const { fontWeight, url } = weightsObject[key]
|
|
23
27
|
return setCustomFont(name, fontWeight, url)
|
|
24
28
|
})
|
|
25
|
-
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const getFontFaceEachString = (name, weightsObject) => {
|
|
32
|
+
return getFontFaceEach(name, weightsObject).join('\n')
|
|
26
33
|
}
|
|
27
34
|
|
|
28
35
|
export const getFontFace = LIBRARY => {
|
|
29
36
|
const keys = Object.keys(LIBRARY)
|
|
30
|
-
|
|
31
|
-
return fontsJoint.join('\n')
|
|
37
|
+
return keys.map(key => getFontFaceEach(key, LIBRARY[key].value))
|
|
32
38
|
}
|
|
39
|
+
|
|
40
|
+
export const getFontFaceString = LIBRARY => getFontFace(LIBRARY).join('\n')
|