@symbo.ls/scratch 2.11.225 → 2.11.227
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/dist/cjs/defaultConfig/index.js +3 -0
- package/dist/cjs/defaultConfig/spacing.js +2 -0
- package/dist/cjs/defaultConfig/timing.js +1 -0
- package/dist/cjs/defaultConfig/typography.js +1 -0
- package/dist/cjs/factory.js +3 -0
- package/dist/cjs/index.js +210 -87
- package/dist/cjs/set.js +181 -82
- package/dist/cjs/system/color.js +3 -0
- package/dist/cjs/system/document.js +3 -0
- package/dist/cjs/system/font.js +3 -0
- package/dist/cjs/system/index.js +182 -83
- package/dist/cjs/system/reset.js +3 -0
- package/dist/cjs/system/shadow.js +47 -13
- package/dist/cjs/system/spacing.js +143 -58
- package/dist/cjs/system/svg.js +3 -0
- package/dist/cjs/system/theme.js +3 -0
- package/dist/cjs/system/timing.js +82 -35
- package/dist/cjs/system/typography.js +151 -60
- package/dist/cjs/transforms/index.js +63 -17
- package/dist/cjs/utils/index.js +118 -35
- package/dist/cjs/utils/sequence.js +55 -14
- package/dist/cjs/utils/sprite.js +3 -0
- package/dist/cjs/utils/var.js +101 -34
- package/package.json +2 -2
- package/src/defaultConfig/spacing.js +1 -0
- package/src/defaultConfig/timing.js +1 -0
- package/src/defaultConfig/typography.js +1 -0
- package/src/system/spacing.js +35 -26
- package/src/system/typography.js +42 -25
- package/src/transforms/index.js +12 -4
- package/src/utils/sequence.js +54 -14
- package/src/utils/var.js +84 -21
package/dist/cjs/utils/index.js
CHANGED
|
@@ -1346,6 +1346,8 @@ var require_cjs2 = __commonJS({
|
|
|
1346
1346
|
// src/utils/index.js
|
|
1347
1347
|
var utils_exports = {};
|
|
1348
1348
|
__export(utils_exports, {
|
|
1349
|
+
applyGlobalVars: () => applyGlobalVars,
|
|
1350
|
+
applyMediaSequenceVars: () => applyMediaSequenceVars,
|
|
1349
1351
|
applySequenceVars: () => applySequenceVars,
|
|
1350
1352
|
changeLightness: () => changeLightness,
|
|
1351
1353
|
colorStringToRgbaArray: () => colorStringToRgbaArray,
|
|
@@ -1365,6 +1367,8 @@ __export(utils_exports, {
|
|
|
1365
1367
|
getRgbTone: () => getRgbTone,
|
|
1366
1368
|
getSequenceValue: () => getSequenceValue,
|
|
1367
1369
|
getSequenceValuePropertyPair: () => getSequenceValuePropertyPair,
|
|
1370
|
+
getSubratio: () => getSubratio,
|
|
1371
|
+
getSubratioDifference: () => getSubratioDifference,
|
|
1368
1372
|
hexToRgb: () => hexToRgb,
|
|
1369
1373
|
hexToRgbArray: () => hexToRgbArray,
|
|
1370
1374
|
hexToRgba: () => hexToRgba,
|
|
@@ -1381,6 +1385,8 @@ __export(utils_exports, {
|
|
|
1381
1385
|
setCustomFont: () => setCustomFont,
|
|
1382
1386
|
setCustomFontMedia: () => setCustomFontMedia,
|
|
1383
1387
|
setInCustomFontMedia: () => setInCustomFontMedia,
|
|
1388
|
+
setScalingVar: () => setScalingVar,
|
|
1389
|
+
setSubScalingVar: () => setSubScalingVar,
|
|
1384
1390
|
setVariables: () => setVariables
|
|
1385
1391
|
});
|
|
1386
1392
|
module.exports = __toCommonJS(utils_exports);
|
|
@@ -1674,6 +1680,7 @@ var defaultProps = {
|
|
|
1674
1680
|
h1Matches: 6,
|
|
1675
1681
|
lineHeight: 1.5,
|
|
1676
1682
|
subSequence: true,
|
|
1683
|
+
mediaRegenerate: false,
|
|
1677
1684
|
unit: "em",
|
|
1678
1685
|
templates: {},
|
|
1679
1686
|
sequence: {},
|
|
@@ -1729,6 +1736,7 @@ var defaultProps2 = {
|
|
|
1729
1736
|
ratio: SEQUENCE.phi,
|
|
1730
1737
|
range: [-5, 15],
|
|
1731
1738
|
subSequence: true,
|
|
1739
|
+
mediaRegenerate: false,
|
|
1732
1740
|
unit: "em",
|
|
1733
1741
|
sequence: {},
|
|
1734
1742
|
scales: {},
|
|
@@ -1756,6 +1764,7 @@ var defaultProps3 = {
|
|
|
1756
1764
|
type: "timing",
|
|
1757
1765
|
ratio: SEQUENCE["perfect-fourth"],
|
|
1758
1766
|
range: [-3, 12],
|
|
1767
|
+
mediaRegenerate: false,
|
|
1759
1768
|
unit: "ms",
|
|
1760
1769
|
sequence: {},
|
|
1761
1770
|
scales: {},
|
|
@@ -1856,45 +1865,77 @@ var numToLetterMap = {
|
|
|
1856
1865
|
19: "T"
|
|
1857
1866
|
};
|
|
1858
1867
|
var setSequenceValue = (props, sequenceProps) => {
|
|
1859
|
-
const { key, variable, value, scaling, index } = props;
|
|
1868
|
+
const { key, variable, value, scaling, index, scalingVariable } = props;
|
|
1860
1869
|
sequenceProps.sequence[key] = {
|
|
1861
1870
|
key,
|
|
1862
1871
|
decimal: ~~(value * 100) / 100,
|
|
1863
1872
|
val: ~~value,
|
|
1864
1873
|
scaling,
|
|
1865
1874
|
index,
|
|
1875
|
+
scalingVariable,
|
|
1866
1876
|
variable
|
|
1867
1877
|
};
|
|
1868
1878
|
sequenceProps.scales[key] = scaling;
|
|
1869
1879
|
sequenceProps.vars[variable] = scaling + sequenceProps.unit;
|
|
1870
1880
|
};
|
|
1881
|
+
var setScalingVar = (key, sequenceProps) => {
|
|
1882
|
+
const { type } = sequenceProps;
|
|
1883
|
+
if (key === 0)
|
|
1884
|
+
return "1em";
|
|
1885
|
+
const prefix = "--" + (type && type.replace(".", "-"));
|
|
1886
|
+
const ratioVar = `${prefix}-ratio`;
|
|
1887
|
+
if (key > 0) {
|
|
1888
|
+
const prevLetterKey = numToLetterMap[key - 1];
|
|
1889
|
+
return `calc(var(${prefix}-${prevLetterKey}) * var(${ratioVar}))`;
|
|
1890
|
+
}
|
|
1891
|
+
if (key < 0) {
|
|
1892
|
+
const nextLetterKey = numToLetterMap[key + 1];
|
|
1893
|
+
return `calc(var(${prefix}-${nextLetterKey}) / var(${ratioVar}))`;
|
|
1894
|
+
}
|
|
1895
|
+
};
|
|
1896
|
+
var setSubScalingVar = (index, arr, variable, sequenceProps) => {
|
|
1897
|
+
const { type } = sequenceProps;
|
|
1898
|
+
const skipMiddle = index === 2 && arr.length === 2;
|
|
1899
|
+
const indexMapWithLength = skipMiddle ? index + 1 : index;
|
|
1900
|
+
const prefix = "--" + (type && type.replace(".", "-"));
|
|
1901
|
+
const subRatioVarPrefix = `${prefix}-sub-ratio-`;
|
|
1902
|
+
return `calc(var(${variable}) * var(${subRatioVarPrefix + indexMapWithLength}))`;
|
|
1903
|
+
};
|
|
1904
|
+
var getSubratioDifference = (base, ratio) => {
|
|
1905
|
+
const diff = base * ratio - base;
|
|
1906
|
+
const subRatio = diff / 1.618;
|
|
1907
|
+
const first = base * ratio - subRatio;
|
|
1908
|
+
const second = base + subRatio;
|
|
1909
|
+
const middle = (first + second) / 2;
|
|
1910
|
+
return [first, middle, second];
|
|
1911
|
+
};
|
|
1912
|
+
var getSubratio = (base, ratio) => {
|
|
1913
|
+
return getSubratioDifference(base, ratio).map((v) => v / base);
|
|
1914
|
+
};
|
|
1871
1915
|
var generateSubSequence = (props, sequenceProps) => {
|
|
1872
1916
|
const { key, base, value, ratio, variable, index } = props;
|
|
1873
1917
|
const next = value * ratio;
|
|
1874
|
-
const
|
|
1875
|
-
|
|
1876
|
-
const
|
|
1877
|
-
const nextRounded = ~~next;
|
|
1878
|
-
const diffRounded = nextRounded - valueRounded;
|
|
1879
|
-
let arr = [];
|
|
1880
|
-
const first = next - smallscale;
|
|
1881
|
-
const second = value + smallscale;
|
|
1882
|
-
const middle = (first + second) / 2;
|
|
1918
|
+
const diffRounded = ~~next - ~~value;
|
|
1919
|
+
let arr;
|
|
1920
|
+
const [first, middle, second] = getSubratioDifference(value, ratio);
|
|
1883
1921
|
if (diffRounded > 16)
|
|
1884
1922
|
arr = [first, middle, second];
|
|
1885
1923
|
else
|
|
1886
1924
|
arr = [first, second];
|
|
1887
|
-
arr.
|
|
1925
|
+
arr.forEach((v, k) => {
|
|
1888
1926
|
const scaling = ~~(v / base * 1e3) / 1e3;
|
|
1889
1927
|
const newVar = variable + (k + 1);
|
|
1928
|
+
const newIndex = index + (k + 1) / 10;
|
|
1929
|
+
const scalingVariable = setSubScalingVar(k + 1, arr, variable, sequenceProps);
|
|
1890
1930
|
const props2 = {
|
|
1891
1931
|
key: key + (k + 1),
|
|
1892
1932
|
variable: newVar,
|
|
1893
1933
|
value: v,
|
|
1894
1934
|
scaling,
|
|
1895
|
-
|
|
1935
|
+
scalingVariable,
|
|
1936
|
+
index: newIndex
|
|
1896
1937
|
};
|
|
1897
|
-
|
|
1938
|
+
setSequenceValue(props2, sequenceProps);
|
|
1898
1939
|
});
|
|
1899
1940
|
};
|
|
1900
1941
|
var switchSequenceOnNegative = (key, base, ratio) => {
|
|
@@ -1910,12 +1951,14 @@ var generateSequence = (sequenceProps) => {
|
|
|
1910
1951
|
const value = switchSequenceOnNegative(key, base, ratio);
|
|
1911
1952
|
const scaling = ~~(value / base * 100) / 100;
|
|
1912
1953
|
const variable = prefix + letterKey;
|
|
1954
|
+
const scalingVariable = setScalingVar(key, sequenceProps);
|
|
1913
1955
|
const props = {
|
|
1914
1956
|
key: letterKey,
|
|
1915
1957
|
variable,
|
|
1916
1958
|
value,
|
|
1917
1959
|
base,
|
|
1918
1960
|
scaling,
|
|
1961
|
+
scalingVariable,
|
|
1919
1962
|
ratio,
|
|
1920
1963
|
index: key
|
|
1921
1964
|
};
|
|
@@ -2007,35 +2050,75 @@ var setVariables = (result, key) => {
|
|
|
2007
2050
|
CSS_VARS2[result.var] = result.value;
|
|
2008
2051
|
}
|
|
2009
2052
|
};
|
|
2010
|
-
var
|
|
2053
|
+
var applyGlobalVars = (vars, obj, options) => {
|
|
2011
2054
|
const CONFIG2 = getActiveConfig();
|
|
2012
|
-
const { UNIT: UNIT2
|
|
2013
|
-
const unit =
|
|
2014
|
-
const {
|
|
2055
|
+
const { UNIT: UNIT2 } = CONFIG2;
|
|
2056
|
+
const unit = obj.unit || UNIT2.default;
|
|
2057
|
+
const { base, ratio, type } = obj;
|
|
2058
|
+
const prefix = "--" + (type && type.replace(".", "-"));
|
|
2059
|
+
vars[`${prefix}-base`] = base;
|
|
2060
|
+
vars[`${prefix}-unit`] = unit;
|
|
2061
|
+
const ratioVar = `${prefix}-ratio`;
|
|
2062
|
+
vars[ratioVar] = ratio;
|
|
2063
|
+
const [first, middle, second] = getSubratio(base, ratio);
|
|
2064
|
+
vars[`${prefix}-sub-ratio-1`] = first;
|
|
2065
|
+
vars[`${prefix}-sub-ratio-2`] = middle;
|
|
2066
|
+
vars[`${prefix}-sub-ratio-3`] = second;
|
|
2067
|
+
};
|
|
2068
|
+
var applySequenceVars = (FACTORY2, options = {}) => {
|
|
2069
|
+
const CONFIG2 = getActiveConfig();
|
|
2070
|
+
const { UNIT: UNIT2, TIMING: TIMING2, CSS_VARS: CSS_VARS2 } = CONFIG2;
|
|
2071
|
+
const unit = FACTORY2.unit || UNIT2.default;
|
|
2072
|
+
const { mediaRegenerate, sequence, scales } = FACTORY2;
|
|
2073
|
+
if (!mediaRegenerate) {
|
|
2074
|
+
applyGlobalVars(CSS_VARS2, FACTORY2, options);
|
|
2075
|
+
}
|
|
2015
2076
|
for (const key in sequence) {
|
|
2016
2077
|
const item = sequence[key];
|
|
2017
|
-
const value = (
|
|
2018
|
-
if (
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
if (!underMediaQuery)
|
|
2026
|
-
underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
|
|
2027
|
-
underMediaQuery[item.variable] = `var(${item.variable + "_" + mediaName})`;
|
|
2028
|
-
CSS_VARS2[item.variable + "_" + mediaName] = value;
|
|
2078
|
+
const value = (FACTORY2.type === TIMING2.type ? sequence[key].val : scales[key]) + unit;
|
|
2079
|
+
if (!mediaRegenerate) {
|
|
2080
|
+
CSS_VARS2[item.variable + "_default"] = value;
|
|
2081
|
+
CSS_VARS2[item.variable] = item.scalingVariable;
|
|
2082
|
+
continue;
|
|
2083
|
+
}
|
|
2084
|
+
if (options.useDefault === false) {
|
|
2085
|
+
CSS_VARS2[item.variable] = value;
|
|
2029
2086
|
} else {
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
} else {
|
|
2033
|
-
CSS_VARS2[item.variable + "_default"] = value;
|
|
2034
|
-
CSS_VARS2[item.variable] = `var(${item.variable + "_default"})`;
|
|
2035
|
-
}
|
|
2087
|
+
CSS_VARS2[item.variable + "_default"] = value;
|
|
2088
|
+
CSS_VARS2[item.variable] = `var(${item.variable + "_default"})`;
|
|
2036
2089
|
}
|
|
2037
2090
|
}
|
|
2038
2091
|
};
|
|
2092
|
+
var applyMediaSequenceVars = (FACTORY2, media, options = {}) => {
|
|
2093
|
+
const CONFIG2 = getActiveConfig();
|
|
2094
|
+
const { UNIT: UNIT2, MEDIA: MEDIA2, TIMING: TIMING2, CSS_VARS: CSS_VARS2 } = CONFIG2;
|
|
2095
|
+
const mediaName = media.slice(1);
|
|
2096
|
+
const unit = FACTORY2.unit || UNIT2.default;
|
|
2097
|
+
const { mediaRegenerate } = FACTORY2;
|
|
2098
|
+
const { sequence, scales } = FACTORY2[media];
|
|
2099
|
+
const query = MEDIA2[mediaName];
|
|
2100
|
+
if (!query && CONFIG2.verbose)
|
|
2101
|
+
console.warn("Can't find media query ", query);
|
|
2102
|
+
if (!mediaRegenerate) {
|
|
2103
|
+
let underMediaQuery = CSS_VARS2[`@media ${query}`];
|
|
2104
|
+
if (!underMediaQuery)
|
|
2105
|
+
underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
|
|
2106
|
+
applyGlobalVars(underMediaQuery, FACTORY2[media], options);
|
|
2107
|
+
return;
|
|
2108
|
+
}
|
|
2109
|
+
for (const key in sequence) {
|
|
2110
|
+
const item = sequence[key];
|
|
2111
|
+
const value = (FACTORY2.type === TIMING2.type ? sequence[key].val : scales[key]) + unit;
|
|
2112
|
+
if (!query && CONFIG2.verbose)
|
|
2113
|
+
console.warn("Can't find query ", query);
|
|
2114
|
+
let underMediaQuery = CSS_VARS2[`@media ${query}`];
|
|
2115
|
+
if (!underMediaQuery)
|
|
2116
|
+
underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
|
|
2117
|
+
underMediaQuery[item.variable] = `var(${item.variable + "_" + mediaName})`;
|
|
2118
|
+
CSS_VARS2[item.variable + "_" + mediaName] = value;
|
|
2119
|
+
}
|
|
2120
|
+
console.log(CSS_VARS2);
|
|
2121
|
+
};
|
|
2039
2122
|
|
|
2040
2123
|
// src/utils/sprite.js
|
|
2041
2124
|
var import_utils8 = __toESM(require_cjs2(), 1);
|
|
@@ -1316,7 +1316,11 @@ __export(sequence_exports, {
|
|
|
1316
1316
|
generateSubSequence: () => generateSubSequence,
|
|
1317
1317
|
getSequenceValue: () => getSequenceValue,
|
|
1318
1318
|
getSequenceValuePropertyPair: () => getSequenceValuePropertyPair,
|
|
1319
|
-
|
|
1319
|
+
getSubratio: () => getSubratio,
|
|
1320
|
+
getSubratioDifference: () => getSubratioDifference,
|
|
1321
|
+
numToLetterMap: () => numToLetterMap,
|
|
1322
|
+
setScalingVar: () => setScalingVar,
|
|
1323
|
+
setSubScalingVar: () => setSubScalingVar
|
|
1320
1324
|
});
|
|
1321
1325
|
module.exports = __toCommonJS(sequence_exports);
|
|
1322
1326
|
var import_utils4 = __toESM(require_cjs(), 1);
|
|
@@ -1405,6 +1409,7 @@ var defaultProps = {
|
|
|
1405
1409
|
h1Matches: 6,
|
|
1406
1410
|
lineHeight: 1.5,
|
|
1407
1411
|
subSequence: true,
|
|
1412
|
+
mediaRegenerate: false,
|
|
1408
1413
|
unit: "em",
|
|
1409
1414
|
templates: {},
|
|
1410
1415
|
sequence: {},
|
|
@@ -1460,6 +1465,7 @@ var defaultProps2 = {
|
|
|
1460
1465
|
ratio: SEQUENCE.phi,
|
|
1461
1466
|
range: [-5, 15],
|
|
1462
1467
|
subSequence: true,
|
|
1468
|
+
mediaRegenerate: false,
|
|
1463
1469
|
unit: "em",
|
|
1464
1470
|
sequence: {},
|
|
1465
1471
|
scales: {},
|
|
@@ -1487,6 +1493,7 @@ var defaultProps3 = {
|
|
|
1487
1493
|
type: "timing",
|
|
1488
1494
|
ratio: SEQUENCE["perfect-fourth"],
|
|
1489
1495
|
range: [-3, 12],
|
|
1496
|
+
mediaRegenerate: false,
|
|
1490
1497
|
unit: "ms",
|
|
1491
1498
|
sequence: {},
|
|
1492
1499
|
scales: {},
|
|
@@ -1587,45 +1594,77 @@ var numToLetterMap = {
|
|
|
1587
1594
|
19: "T"
|
|
1588
1595
|
};
|
|
1589
1596
|
var setSequenceValue = (props, sequenceProps) => {
|
|
1590
|
-
const { key, variable, value, scaling, index } = props;
|
|
1597
|
+
const { key, variable, value, scaling, index, scalingVariable } = props;
|
|
1591
1598
|
sequenceProps.sequence[key] = {
|
|
1592
1599
|
key,
|
|
1593
1600
|
decimal: ~~(value * 100) / 100,
|
|
1594
1601
|
val: ~~value,
|
|
1595
1602
|
scaling,
|
|
1596
1603
|
index,
|
|
1604
|
+
scalingVariable,
|
|
1597
1605
|
variable
|
|
1598
1606
|
};
|
|
1599
1607
|
sequenceProps.scales[key] = scaling;
|
|
1600
1608
|
sequenceProps.vars[variable] = scaling + sequenceProps.unit;
|
|
1601
1609
|
};
|
|
1610
|
+
var setScalingVar = (key, sequenceProps) => {
|
|
1611
|
+
const { type } = sequenceProps;
|
|
1612
|
+
if (key === 0)
|
|
1613
|
+
return "1em";
|
|
1614
|
+
const prefix = "--" + (type && type.replace(".", "-"));
|
|
1615
|
+
const ratioVar = `${prefix}-ratio`;
|
|
1616
|
+
if (key > 0) {
|
|
1617
|
+
const prevLetterKey = numToLetterMap[key - 1];
|
|
1618
|
+
return `calc(var(${prefix}-${prevLetterKey}) * var(${ratioVar}))`;
|
|
1619
|
+
}
|
|
1620
|
+
if (key < 0) {
|
|
1621
|
+
const nextLetterKey = numToLetterMap[key + 1];
|
|
1622
|
+
return `calc(var(${prefix}-${nextLetterKey}) / var(${ratioVar}))`;
|
|
1623
|
+
}
|
|
1624
|
+
};
|
|
1625
|
+
var setSubScalingVar = (index, arr, variable, sequenceProps) => {
|
|
1626
|
+
const { type } = sequenceProps;
|
|
1627
|
+
const skipMiddle = index === 2 && arr.length === 2;
|
|
1628
|
+
const indexMapWithLength = skipMiddle ? index + 1 : index;
|
|
1629
|
+
const prefix = "--" + (type && type.replace(".", "-"));
|
|
1630
|
+
const subRatioVarPrefix = `${prefix}-sub-ratio-`;
|
|
1631
|
+
return `calc(var(${variable}) * var(${subRatioVarPrefix + indexMapWithLength}))`;
|
|
1632
|
+
};
|
|
1633
|
+
var getSubratioDifference = (base, ratio) => {
|
|
1634
|
+
const diff = base * ratio - base;
|
|
1635
|
+
const subRatio = diff / 1.618;
|
|
1636
|
+
const first = base * ratio - subRatio;
|
|
1637
|
+
const second = base + subRatio;
|
|
1638
|
+
const middle = (first + second) / 2;
|
|
1639
|
+
return [first, middle, second];
|
|
1640
|
+
};
|
|
1641
|
+
var getSubratio = (base, ratio) => {
|
|
1642
|
+
return getSubratioDifference(base, ratio).map((v) => v / base);
|
|
1643
|
+
};
|
|
1602
1644
|
var generateSubSequence = (props, sequenceProps) => {
|
|
1603
1645
|
const { key, base, value, ratio, variable, index } = props;
|
|
1604
1646
|
const next = value * ratio;
|
|
1605
|
-
const
|
|
1606
|
-
|
|
1607
|
-
const
|
|
1608
|
-
const nextRounded = ~~next;
|
|
1609
|
-
const diffRounded = nextRounded - valueRounded;
|
|
1610
|
-
let arr = [];
|
|
1611
|
-
const first = next - smallscale;
|
|
1612
|
-
const second = value + smallscale;
|
|
1613
|
-
const middle = (first + second) / 2;
|
|
1647
|
+
const diffRounded = ~~next - ~~value;
|
|
1648
|
+
let arr;
|
|
1649
|
+
const [first, middle, second] = getSubratioDifference(value, ratio);
|
|
1614
1650
|
if (diffRounded > 16)
|
|
1615
1651
|
arr = [first, middle, second];
|
|
1616
1652
|
else
|
|
1617
1653
|
arr = [first, second];
|
|
1618
|
-
arr.
|
|
1654
|
+
arr.forEach((v, k) => {
|
|
1619
1655
|
const scaling = ~~(v / base * 1e3) / 1e3;
|
|
1620
1656
|
const newVar = variable + (k + 1);
|
|
1657
|
+
const newIndex = index + (k + 1) / 10;
|
|
1658
|
+
const scalingVariable = setSubScalingVar(k + 1, arr, variable, sequenceProps);
|
|
1621
1659
|
const props2 = {
|
|
1622
1660
|
key: key + (k + 1),
|
|
1623
1661
|
variable: newVar,
|
|
1624
1662
|
value: v,
|
|
1625
1663
|
scaling,
|
|
1626
|
-
|
|
1664
|
+
scalingVariable,
|
|
1665
|
+
index: newIndex
|
|
1627
1666
|
};
|
|
1628
|
-
|
|
1667
|
+
setSequenceValue(props2, sequenceProps);
|
|
1629
1668
|
});
|
|
1630
1669
|
};
|
|
1631
1670
|
var switchSequenceOnNegative = (key, base, ratio) => {
|
|
@@ -1641,12 +1680,14 @@ var generateSequence = (sequenceProps) => {
|
|
|
1641
1680
|
const value = switchSequenceOnNegative(key, base, ratio);
|
|
1642
1681
|
const scaling = ~~(value / base * 100) / 100;
|
|
1643
1682
|
const variable = prefix + letterKey;
|
|
1683
|
+
const scalingVariable = setScalingVar(key, sequenceProps);
|
|
1644
1684
|
const props = {
|
|
1645
1685
|
key: letterKey,
|
|
1646
1686
|
variable,
|
|
1647
1687
|
value,
|
|
1648
1688
|
base,
|
|
1649
1689
|
scaling,
|
|
1690
|
+
scalingVariable,
|
|
1650
1691
|
ratio,
|
|
1651
1692
|
index: key
|
|
1652
1693
|
};
|
package/dist/cjs/utils/sprite.js
CHANGED
|
@@ -1391,6 +1391,7 @@ var defaultProps = {
|
|
|
1391
1391
|
h1Matches: 6,
|
|
1392
1392
|
lineHeight: 1.5,
|
|
1393
1393
|
subSequence: true,
|
|
1394
|
+
mediaRegenerate: false,
|
|
1394
1395
|
unit: "em",
|
|
1395
1396
|
templates: {},
|
|
1396
1397
|
sequence: {},
|
|
@@ -1446,6 +1447,7 @@ var defaultProps2 = {
|
|
|
1446
1447
|
ratio: SEQUENCE.phi,
|
|
1447
1448
|
range: [-5, 15],
|
|
1448
1449
|
subSequence: true,
|
|
1450
|
+
mediaRegenerate: false,
|
|
1449
1451
|
unit: "em",
|
|
1450
1452
|
sequence: {},
|
|
1451
1453
|
scales: {},
|
|
@@ -1473,6 +1475,7 @@ var defaultProps3 = {
|
|
|
1473
1475
|
type: "timing",
|
|
1474
1476
|
ratio: SEQUENCE["perfect-fourth"],
|
|
1475
1477
|
range: [-3, 12],
|
|
1478
|
+
mediaRegenerate: false,
|
|
1476
1479
|
unit: "ms",
|
|
1477
1480
|
sequence: {},
|
|
1478
1481
|
scales: {},
|
package/dist/cjs/utils/var.js
CHANGED
|
@@ -205,7 +205,7 @@ var require_types = __commonJS({
|
|
|
205
205
|
__export2(types_exports, {
|
|
206
206
|
TYPES: () => TYPES,
|
|
207
207
|
is: () => is,
|
|
208
|
-
isArray: () =>
|
|
208
|
+
isArray: () => isArray3,
|
|
209
209
|
isBoolean: () => isBoolean,
|
|
210
210
|
isDate: () => isDate,
|
|
211
211
|
isDefined: () => isDefined2,
|
|
@@ -213,24 +213,24 @@ var require_types = __commonJS({
|
|
|
213
213
|
isNot: () => isNot,
|
|
214
214
|
isNull: () => isNull,
|
|
215
215
|
isNumber: () => isNumber,
|
|
216
|
-
isObject: () =>
|
|
216
|
+
isObject: () => isObject4,
|
|
217
217
|
isObjectLike: () => isObjectLike2,
|
|
218
|
-
isString: () =>
|
|
218
|
+
isString: () => isString3,
|
|
219
219
|
isUndefined: () => isUndefined
|
|
220
220
|
});
|
|
221
221
|
module2.exports = __toCommonJS2(types_exports);
|
|
222
222
|
var import_node = require_node();
|
|
223
|
-
var
|
|
223
|
+
var isObject4 = (arg) => {
|
|
224
224
|
if (arg === null)
|
|
225
225
|
return false;
|
|
226
226
|
return typeof arg === "object" && arg.constructor === Object;
|
|
227
227
|
};
|
|
228
|
-
var
|
|
228
|
+
var isString3 = (arg) => typeof arg === "string";
|
|
229
229
|
var isNumber = (arg) => typeof arg === "number";
|
|
230
230
|
var isFunction = (arg) => typeof arg === "function";
|
|
231
231
|
var isBoolean = (arg) => arg === true || arg === false;
|
|
232
232
|
var isNull = (arg) => arg === null;
|
|
233
|
-
var
|
|
233
|
+
var isArray3 = (arg) => Array.isArray(arg);
|
|
234
234
|
var isDate = (d) => d instanceof Date;
|
|
235
235
|
var isObjectLike2 = (arg) => {
|
|
236
236
|
if (arg === null)
|
|
@@ -238,16 +238,16 @@ var require_types = __commonJS({
|
|
|
238
238
|
return typeof arg === "object";
|
|
239
239
|
};
|
|
240
240
|
var isDefined2 = (arg) => {
|
|
241
|
-
return
|
|
241
|
+
return isObject4(arg) || isObjectLike2(arg) || isString3(arg) || isNumber(arg) || isFunction(arg) || isArray3(arg) || isObjectLike2(arg) || isBoolean(arg) || isDate(arg) || isNull(arg);
|
|
242
242
|
};
|
|
243
243
|
var isUndefined = (arg) => {
|
|
244
244
|
return arg === void 0;
|
|
245
245
|
};
|
|
246
246
|
var TYPES = {
|
|
247
247
|
boolean: isBoolean,
|
|
248
|
-
array:
|
|
249
|
-
object:
|
|
250
|
-
string:
|
|
248
|
+
array: isArray3,
|
|
249
|
+
object: isObject4,
|
|
250
|
+
string: isString3,
|
|
251
251
|
date: isDate,
|
|
252
252
|
number: isNumber,
|
|
253
253
|
null: isNull,
|
|
@@ -1310,11 +1310,13 @@ var require_cjs = __commonJS({
|
|
|
1310
1310
|
// src/utils/var.js
|
|
1311
1311
|
var var_exports = {};
|
|
1312
1312
|
__export(var_exports, {
|
|
1313
|
+
applyGlobalVars: () => applyGlobalVars,
|
|
1314
|
+
applyMediaSequenceVars: () => applyMediaSequenceVars,
|
|
1313
1315
|
applySequenceVars: () => applySequenceVars,
|
|
1314
1316
|
setVariables: () => setVariables
|
|
1315
1317
|
});
|
|
1316
1318
|
module.exports = __toCommonJS(var_exports);
|
|
1317
|
-
var
|
|
1319
|
+
var import_utils6 = __toESM(require_cjs(), 1);
|
|
1318
1320
|
|
|
1319
1321
|
// src/factory.js
|
|
1320
1322
|
var import_utils = __toESM(require_cjs(), 1);
|
|
@@ -1391,6 +1393,7 @@ var defaultProps = {
|
|
|
1391
1393
|
h1Matches: 6,
|
|
1392
1394
|
lineHeight: 1.5,
|
|
1393
1395
|
subSequence: true,
|
|
1396
|
+
mediaRegenerate: false,
|
|
1394
1397
|
unit: "em",
|
|
1395
1398
|
templates: {},
|
|
1396
1399
|
sequence: {},
|
|
@@ -1446,6 +1449,7 @@ var defaultProps2 = {
|
|
|
1446
1449
|
ratio: SEQUENCE.phi,
|
|
1447
1450
|
range: [-5, 15],
|
|
1448
1451
|
subSequence: true,
|
|
1452
|
+
mediaRegenerate: false,
|
|
1449
1453
|
unit: "em",
|
|
1450
1454
|
sequence: {},
|
|
1451
1455
|
scales: {},
|
|
@@ -1473,6 +1477,7 @@ var defaultProps3 = {
|
|
|
1473
1477
|
type: "timing",
|
|
1474
1478
|
ratio: SEQUENCE["perfect-fourth"],
|
|
1475
1479
|
range: [-3, 12],
|
|
1480
|
+
mediaRegenerate: false,
|
|
1476
1481
|
unit: "ms",
|
|
1477
1482
|
sequence: {},
|
|
1478
1483
|
scales: {},
|
|
@@ -1543,41 +1548,103 @@ var getActiveConfig = (def) => {
|
|
|
1543
1548
|
return FACTORY[def || FACTORY.active];
|
|
1544
1549
|
};
|
|
1545
1550
|
|
|
1551
|
+
// src/utils/sequence.js
|
|
1552
|
+
var import_utils4 = __toESM(require_cjs(), 1);
|
|
1553
|
+
|
|
1554
|
+
// ../utils/src/index.js
|
|
1555
|
+
var import_utils3 = __toESM(require_cjs());
|
|
1556
|
+
|
|
1557
|
+
// ../utils/src/scaling.js
|
|
1558
|
+
var import_utils2 = __toESM(require_cjs());
|
|
1559
|
+
|
|
1560
|
+
// src/utils/sequence.js
|
|
1561
|
+
var getSubratioDifference = (base, ratio) => {
|
|
1562
|
+
const diff = base * ratio - base;
|
|
1563
|
+
const subRatio = diff / 1.618;
|
|
1564
|
+
const first = base * ratio - subRatio;
|
|
1565
|
+
const second = base + subRatio;
|
|
1566
|
+
const middle = (first + second) / 2;
|
|
1567
|
+
return [first, middle, second];
|
|
1568
|
+
};
|
|
1569
|
+
var getSubratio = (base, ratio) => {
|
|
1570
|
+
return getSubratioDifference(base, ratio).map((v) => v / base);
|
|
1571
|
+
};
|
|
1572
|
+
|
|
1546
1573
|
// src/utils/var.js
|
|
1547
1574
|
var setVariables = (result, key) => {
|
|
1548
1575
|
const CONFIG2 = getActiveConfig();
|
|
1549
1576
|
const { CSS_VARS: CSS_VARS2 } = CONFIG2;
|
|
1550
|
-
if ((0,
|
|
1577
|
+
if ((0, import_utils6.isObjectLike)(result.value)) {
|
|
1551
1578
|
} else {
|
|
1552
1579
|
CSS_VARS2[result.var] = result.value;
|
|
1553
1580
|
}
|
|
1554
1581
|
};
|
|
1555
|
-
var
|
|
1582
|
+
var applyGlobalVars = (vars, obj, options) => {
|
|
1556
1583
|
const CONFIG2 = getActiveConfig();
|
|
1557
|
-
const { UNIT: UNIT2
|
|
1558
|
-
const unit =
|
|
1559
|
-
const {
|
|
1584
|
+
const { UNIT: UNIT2 } = CONFIG2;
|
|
1585
|
+
const unit = obj.unit || UNIT2.default;
|
|
1586
|
+
const { base, ratio, type } = obj;
|
|
1587
|
+
const prefix = "--" + (type && type.replace(".", "-"));
|
|
1588
|
+
vars[`${prefix}-base`] = base;
|
|
1589
|
+
vars[`${prefix}-unit`] = unit;
|
|
1590
|
+
const ratioVar = `${prefix}-ratio`;
|
|
1591
|
+
vars[ratioVar] = ratio;
|
|
1592
|
+
const [first, middle, second] = getSubratio(base, ratio);
|
|
1593
|
+
vars[`${prefix}-sub-ratio-1`] = first;
|
|
1594
|
+
vars[`${prefix}-sub-ratio-2`] = middle;
|
|
1595
|
+
vars[`${prefix}-sub-ratio-3`] = second;
|
|
1596
|
+
};
|
|
1597
|
+
var applySequenceVars = (FACTORY2, options = {}) => {
|
|
1598
|
+
const CONFIG2 = getActiveConfig();
|
|
1599
|
+
const { UNIT: UNIT2, TIMING: TIMING2, CSS_VARS: CSS_VARS2 } = CONFIG2;
|
|
1600
|
+
const unit = FACTORY2.unit || UNIT2.default;
|
|
1601
|
+
const { mediaRegenerate, sequence, scales } = FACTORY2;
|
|
1602
|
+
if (!mediaRegenerate) {
|
|
1603
|
+
applyGlobalVars(CSS_VARS2, FACTORY2, options);
|
|
1604
|
+
}
|
|
1560
1605
|
for (const key in sequence) {
|
|
1561
1606
|
const item = sequence[key];
|
|
1562
|
-
const value = (
|
|
1563
|
-
if (
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
if (!underMediaQuery)
|
|
1571
|
-
underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
|
|
1572
|
-
underMediaQuery[item.variable] = `var(${item.variable + "_" + mediaName})`;
|
|
1573
|
-
CSS_VARS2[item.variable + "_" + mediaName] = value;
|
|
1607
|
+
const value = (FACTORY2.type === TIMING2.type ? sequence[key].val : scales[key]) + unit;
|
|
1608
|
+
if (!mediaRegenerate) {
|
|
1609
|
+
CSS_VARS2[item.variable + "_default"] = value;
|
|
1610
|
+
CSS_VARS2[item.variable] = item.scalingVariable;
|
|
1611
|
+
continue;
|
|
1612
|
+
}
|
|
1613
|
+
if (options.useDefault === false) {
|
|
1614
|
+
CSS_VARS2[item.variable] = value;
|
|
1574
1615
|
} else {
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
} else {
|
|
1578
|
-
CSS_VARS2[item.variable + "_default"] = value;
|
|
1579
|
-
CSS_VARS2[item.variable] = `var(${item.variable + "_default"})`;
|
|
1580
|
-
}
|
|
1616
|
+
CSS_VARS2[item.variable + "_default"] = value;
|
|
1617
|
+
CSS_VARS2[item.variable] = `var(${item.variable + "_default"})`;
|
|
1581
1618
|
}
|
|
1582
1619
|
}
|
|
1583
1620
|
};
|
|
1621
|
+
var applyMediaSequenceVars = (FACTORY2, media, options = {}) => {
|
|
1622
|
+
const CONFIG2 = getActiveConfig();
|
|
1623
|
+
const { UNIT: UNIT2, MEDIA: MEDIA2, TIMING: TIMING2, CSS_VARS: CSS_VARS2 } = CONFIG2;
|
|
1624
|
+
const mediaName = media.slice(1);
|
|
1625
|
+
const unit = FACTORY2.unit || UNIT2.default;
|
|
1626
|
+
const { mediaRegenerate } = FACTORY2;
|
|
1627
|
+
const { sequence, scales } = FACTORY2[media];
|
|
1628
|
+
const query = MEDIA2[mediaName];
|
|
1629
|
+
if (!query && CONFIG2.verbose)
|
|
1630
|
+
console.warn("Can't find media query ", query);
|
|
1631
|
+
if (!mediaRegenerate) {
|
|
1632
|
+
let underMediaQuery = CSS_VARS2[`@media ${query}`];
|
|
1633
|
+
if (!underMediaQuery)
|
|
1634
|
+
underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
|
|
1635
|
+
applyGlobalVars(underMediaQuery, FACTORY2[media], options);
|
|
1636
|
+
return;
|
|
1637
|
+
}
|
|
1638
|
+
for (const key in sequence) {
|
|
1639
|
+
const item = sequence[key];
|
|
1640
|
+
const value = (FACTORY2.type === TIMING2.type ? sequence[key].val : scales[key]) + unit;
|
|
1641
|
+
if (!query && CONFIG2.verbose)
|
|
1642
|
+
console.warn("Can't find query ", query);
|
|
1643
|
+
let underMediaQuery = CSS_VARS2[`@media ${query}`];
|
|
1644
|
+
if (!underMediaQuery)
|
|
1645
|
+
underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
|
|
1646
|
+
underMediaQuery[item.variable] = `var(${item.variable + "_" + mediaName})`;
|
|
1647
|
+
CSS_VARS2[item.variable + "_" + mediaName] = value;
|
|
1648
|
+
}
|
|
1649
|
+
console.log(CSS_VARS2);
|
|
1650
|
+
};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@symbo.ls/scratch",
|
|
3
3
|
"description": "Φ / CSS framework and methodology.",
|
|
4
4
|
"author": "symbo.ls",
|
|
5
|
-
"version": "2.11.
|
|
5
|
+
"version": "2.11.227",
|
|
6
6
|
"files": [
|
|
7
7
|
"src",
|
|
8
8
|
"dist"
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"@symbo.ls/utils": "latest",
|
|
30
30
|
"color-contrast-checker": "^1.5.0"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "6ac105edd74f4d797b096bebfdf80b473831f26e"
|
|
33
33
|
}
|