@symbo.ls/scratch 2.11.226 → 2.11.228
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 +196 -83
- package/dist/cjs/set.js +183 -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 +184 -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 +153 -60
- package/dist/cjs/transforms/index.js +47 -13
- 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 +36 -26
- package/src/system/typography.js +49 -29
- package/src/utils/sequence.js +54 -14
- package/src/utils/var.js +84 -21
package/dist/cjs/system/index.js
CHANGED
|
@@ -1456,6 +1456,7 @@ var defaultProps = {
|
|
|
1456
1456
|
h1Matches: 6,
|
|
1457
1457
|
lineHeight: 1.5,
|
|
1458
1458
|
subSequence: true,
|
|
1459
|
+
mediaRegenerate: false,
|
|
1459
1460
|
unit: "em",
|
|
1460
1461
|
templates: {},
|
|
1461
1462
|
sequence: {},
|
|
@@ -1511,6 +1512,7 @@ var defaultProps2 = {
|
|
|
1511
1512
|
ratio: SEQUENCE.phi,
|
|
1512
1513
|
range: [-5, 15],
|
|
1513
1514
|
subSequence: true,
|
|
1515
|
+
mediaRegenerate: false,
|
|
1514
1516
|
unit: "em",
|
|
1515
1517
|
sequence: {},
|
|
1516
1518
|
scales: {},
|
|
@@ -1538,6 +1540,7 @@ var defaultProps3 = {
|
|
|
1538
1540
|
type: "timing",
|
|
1539
1541
|
ratio: SEQUENCE["perfect-fourth"],
|
|
1540
1542
|
range: [-3, 12],
|
|
1543
|
+
mediaRegenerate: false,
|
|
1541
1544
|
unit: "ms",
|
|
1542
1545
|
sequence: {},
|
|
1543
1546
|
scales: {},
|
|
@@ -1787,45 +1790,77 @@ var numToLetterMap = {
|
|
|
1787
1790
|
19: "T"
|
|
1788
1791
|
};
|
|
1789
1792
|
var setSequenceValue = (props, sequenceProps) => {
|
|
1790
|
-
const { key, variable, value, scaling, index } = props;
|
|
1793
|
+
const { key, variable, value, scaling, index, scalingVariable } = props;
|
|
1791
1794
|
sequenceProps.sequence[key] = {
|
|
1792
1795
|
key,
|
|
1793
1796
|
decimal: ~~(value * 100) / 100,
|
|
1794
1797
|
val: ~~value,
|
|
1795
1798
|
scaling,
|
|
1796
1799
|
index,
|
|
1800
|
+
scalingVariable,
|
|
1797
1801
|
variable
|
|
1798
1802
|
};
|
|
1799
1803
|
sequenceProps.scales[key] = scaling;
|
|
1800
1804
|
sequenceProps.vars[variable] = scaling + sequenceProps.unit;
|
|
1801
1805
|
};
|
|
1806
|
+
var setScalingVar = (key, sequenceProps) => {
|
|
1807
|
+
const { type } = sequenceProps;
|
|
1808
|
+
if (key === 0)
|
|
1809
|
+
return "1em";
|
|
1810
|
+
const prefix = "--" + (type && type.replace(".", "-"));
|
|
1811
|
+
const ratioVar = `${prefix}-ratio`;
|
|
1812
|
+
if (key > 0) {
|
|
1813
|
+
const prevLetterKey = numToLetterMap[key - 1];
|
|
1814
|
+
return `calc(var(${prefix}-${prevLetterKey}) * var(${ratioVar}))`;
|
|
1815
|
+
}
|
|
1816
|
+
if (key < 0) {
|
|
1817
|
+
const nextLetterKey = numToLetterMap[key + 1];
|
|
1818
|
+
return `calc(var(${prefix}-${nextLetterKey}) / var(${ratioVar}))`;
|
|
1819
|
+
}
|
|
1820
|
+
};
|
|
1821
|
+
var setSubScalingVar = (index, arr, variable, sequenceProps) => {
|
|
1822
|
+
const { type } = sequenceProps;
|
|
1823
|
+
const skipMiddle = index === 2 && arr.length === 2;
|
|
1824
|
+
const indexMapWithLength = skipMiddle ? index + 1 : index;
|
|
1825
|
+
const prefix = "--" + (type && type.replace(".", "-"));
|
|
1826
|
+
const subRatioVarPrefix = `${prefix}-sub-ratio-`;
|
|
1827
|
+
return `calc(var(${variable}) * var(${subRatioVarPrefix + indexMapWithLength}))`;
|
|
1828
|
+
};
|
|
1829
|
+
var getSubratioDifference = (base, ratio) => {
|
|
1830
|
+
const diff = base * ratio - base;
|
|
1831
|
+
const subRatio = diff / 1.618;
|
|
1832
|
+
const first = base * ratio - subRatio;
|
|
1833
|
+
const second = base + subRatio;
|
|
1834
|
+
const middle = (first + second) / 2;
|
|
1835
|
+
return [first, middle, second];
|
|
1836
|
+
};
|
|
1837
|
+
var getSubratio = (base, ratio) => {
|
|
1838
|
+
return getSubratioDifference(base, ratio).map((v) => v / base);
|
|
1839
|
+
};
|
|
1802
1840
|
var generateSubSequence = (props, sequenceProps) => {
|
|
1803
1841
|
const { key, base, value, ratio, variable, index } = props;
|
|
1804
1842
|
const next = value * ratio;
|
|
1805
|
-
const
|
|
1806
|
-
|
|
1807
|
-
const
|
|
1808
|
-
const nextRounded = ~~next;
|
|
1809
|
-
const diffRounded = nextRounded - valueRounded;
|
|
1810
|
-
let arr = [];
|
|
1811
|
-
const first = next - smallscale;
|
|
1812
|
-
const second = value + smallscale;
|
|
1813
|
-
const middle = (first + second) / 2;
|
|
1843
|
+
const diffRounded = ~~next - ~~value;
|
|
1844
|
+
let arr;
|
|
1845
|
+
const [first, middle, second] = getSubratioDifference(value, ratio);
|
|
1814
1846
|
if (diffRounded > 16)
|
|
1815
1847
|
arr = [first, middle, second];
|
|
1816
1848
|
else
|
|
1817
1849
|
arr = [first, second];
|
|
1818
|
-
arr.
|
|
1850
|
+
arr.forEach((v, k) => {
|
|
1819
1851
|
const scaling = ~~(v / base * 1e3) / 1e3;
|
|
1820
1852
|
const newVar = variable + (k + 1);
|
|
1853
|
+
const newIndex = index + (k + 1) / 10;
|
|
1854
|
+
const scalingVariable = setSubScalingVar(k + 1, arr, variable, sequenceProps);
|
|
1821
1855
|
const props2 = {
|
|
1822
1856
|
key: key + (k + 1),
|
|
1823
1857
|
variable: newVar,
|
|
1824
1858
|
value: v,
|
|
1825
1859
|
scaling,
|
|
1826
|
-
|
|
1860
|
+
scalingVariable,
|
|
1861
|
+
index: newIndex
|
|
1827
1862
|
};
|
|
1828
|
-
|
|
1863
|
+
setSequenceValue(props2, sequenceProps);
|
|
1829
1864
|
});
|
|
1830
1865
|
};
|
|
1831
1866
|
var switchSequenceOnNegative = (key, base, ratio) => {
|
|
@@ -1841,12 +1876,14 @@ var generateSequence = (sequenceProps) => {
|
|
|
1841
1876
|
const value = switchSequenceOnNegative(key, base, ratio);
|
|
1842
1877
|
const scaling = ~~(value / base * 100) / 100;
|
|
1843
1878
|
const variable = prefix + letterKey;
|
|
1879
|
+
const scalingVariable = setScalingVar(key, sequenceProps);
|
|
1844
1880
|
const props = {
|
|
1845
1881
|
key: letterKey,
|
|
1846
1882
|
variable,
|
|
1847
1883
|
value,
|
|
1848
1884
|
base,
|
|
1849
1885
|
scaling,
|
|
1886
|
+
scalingVariable,
|
|
1850
1887
|
ratio,
|
|
1851
1888
|
index: key
|
|
1852
1889
|
};
|
|
@@ -1930,35 +1967,75 @@ var findHeadings = (propertyNames) => {
|
|
|
1930
1967
|
|
|
1931
1968
|
// src/utils/var.js
|
|
1932
1969
|
var import_utils7 = __toESM(require_cjs(), 1);
|
|
1933
|
-
var
|
|
1970
|
+
var applyGlobalVars = (vars, obj, options) => {
|
|
1934
1971
|
const CONFIG2 = getActiveConfig();
|
|
1935
|
-
const { UNIT: UNIT2
|
|
1936
|
-
const unit =
|
|
1937
|
-
const {
|
|
1972
|
+
const { UNIT: UNIT2 } = CONFIG2;
|
|
1973
|
+
const unit = obj.unit || UNIT2.default;
|
|
1974
|
+
const { base, ratio, type } = obj;
|
|
1975
|
+
const prefix = "--" + (type && type.replace(".", "-"));
|
|
1976
|
+
vars[`${prefix}-base`] = base;
|
|
1977
|
+
vars[`${prefix}-unit`] = unit;
|
|
1978
|
+
const ratioVar = `${prefix}-ratio`;
|
|
1979
|
+
vars[ratioVar] = ratio;
|
|
1980
|
+
const [first, middle, second] = getSubratio(base, ratio);
|
|
1981
|
+
vars[`${prefix}-sub-ratio-1`] = first;
|
|
1982
|
+
vars[`${prefix}-sub-ratio-2`] = middle;
|
|
1983
|
+
vars[`${prefix}-sub-ratio-3`] = second;
|
|
1984
|
+
};
|
|
1985
|
+
var applySequenceVars = (FACTORY2, options = {}) => {
|
|
1986
|
+
const CONFIG2 = getActiveConfig();
|
|
1987
|
+
const { UNIT: UNIT2, TIMING: TIMING2, CSS_VARS: CSS_VARS2 } = CONFIG2;
|
|
1988
|
+
const unit = FACTORY2.unit || UNIT2.default;
|
|
1989
|
+
const { mediaRegenerate, sequence, scales } = FACTORY2;
|
|
1990
|
+
if (!mediaRegenerate) {
|
|
1991
|
+
applyGlobalVars(CSS_VARS2, FACTORY2, options);
|
|
1992
|
+
}
|
|
1938
1993
|
for (const key in sequence) {
|
|
1939
1994
|
const item = sequence[key];
|
|
1940
|
-
const value = (
|
|
1941
|
-
if (
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
if (!underMediaQuery)
|
|
1949
|
-
underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
|
|
1950
|
-
underMediaQuery[item.variable] = `var(${item.variable + "_" + mediaName})`;
|
|
1951
|
-
CSS_VARS2[item.variable + "_" + mediaName] = value;
|
|
1995
|
+
const value = (FACTORY2.type === TIMING2.type ? sequence[key].val : scales[key]) + unit;
|
|
1996
|
+
if (!mediaRegenerate) {
|
|
1997
|
+
CSS_VARS2[item.variable + "_default"] = value;
|
|
1998
|
+
CSS_VARS2[item.variable] = item.scalingVariable;
|
|
1999
|
+
continue;
|
|
2000
|
+
}
|
|
2001
|
+
if (options.useDefault === false) {
|
|
2002
|
+
CSS_VARS2[item.variable] = value;
|
|
1952
2003
|
} else {
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
} else {
|
|
1956
|
-
CSS_VARS2[item.variable + "_default"] = value;
|
|
1957
|
-
CSS_VARS2[item.variable] = `var(${item.variable + "_default"})`;
|
|
1958
|
-
}
|
|
2004
|
+
CSS_VARS2[item.variable + "_default"] = value;
|
|
2005
|
+
CSS_VARS2[item.variable] = `var(${item.variable + "_default"})`;
|
|
1959
2006
|
}
|
|
1960
2007
|
}
|
|
1961
2008
|
};
|
|
2009
|
+
var applyMediaSequenceVars = (FACTORY2, media, options = {}) => {
|
|
2010
|
+
const CONFIG2 = getActiveConfig();
|
|
2011
|
+
const { UNIT: UNIT2, MEDIA: MEDIA2, TIMING: TIMING2, CSS_VARS: CSS_VARS2 } = CONFIG2;
|
|
2012
|
+
const mediaName = media.slice(1);
|
|
2013
|
+
const unit = FACTORY2.unit || UNIT2.default;
|
|
2014
|
+
const { mediaRegenerate } = FACTORY2;
|
|
2015
|
+
const { sequence, scales } = FACTORY2[media];
|
|
2016
|
+
const query = MEDIA2[mediaName];
|
|
2017
|
+
if (!query && CONFIG2.verbose)
|
|
2018
|
+
console.warn("Can't find media query ", query);
|
|
2019
|
+
if (!mediaRegenerate) {
|
|
2020
|
+
let underMediaQuery = CSS_VARS2[`@media ${query}`];
|
|
2021
|
+
if (!underMediaQuery)
|
|
2022
|
+
underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
|
|
2023
|
+
applyGlobalVars(underMediaQuery, FACTORY2[media], options);
|
|
2024
|
+
return;
|
|
2025
|
+
}
|
|
2026
|
+
for (const key in sequence) {
|
|
2027
|
+
const item = sequence[key];
|
|
2028
|
+
const value = (FACTORY2.type === TIMING2.type ? sequence[key].val : scales[key]) + unit;
|
|
2029
|
+
if (!query && CONFIG2.verbose)
|
|
2030
|
+
console.warn("Can't find query ", query);
|
|
2031
|
+
let underMediaQuery = CSS_VARS2[`@media ${query}`];
|
|
2032
|
+
if (!underMediaQuery)
|
|
2033
|
+
underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
|
|
2034
|
+
underMediaQuery[item.variable] = `var(${item.variable + "_" + mediaName})`;
|
|
2035
|
+
CSS_VARS2[item.variable + "_" + mediaName] = value;
|
|
2036
|
+
}
|
|
2037
|
+
console.log(CSS_VARS2);
|
|
2038
|
+
};
|
|
1962
2039
|
|
|
1963
2040
|
// src/utils/sprite.js
|
|
1964
2041
|
var import_utils8 = __toESM(require_cjs(), 1);
|
|
@@ -2401,34 +2478,50 @@ var setFontFamily = (val, key) => {
|
|
|
2401
2478
|
|
|
2402
2479
|
// src/system/typography.js
|
|
2403
2480
|
var import_utils15 = __toESM(require_cjs(), 1);
|
|
2404
|
-
var runThroughMedia = (
|
|
2481
|
+
var runThroughMedia = (FACTORY2) => {
|
|
2405
2482
|
const CONFIG2 = getActiveConfig();
|
|
2406
2483
|
const { TYPOGRAPHY: TYPOGRAPHY2, MEDIA: MEDIA2 } = CONFIG2;
|
|
2407
|
-
for (const prop in
|
|
2408
|
-
const
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2484
|
+
for (const prop in FACTORY2) {
|
|
2485
|
+
const isPropMedia = prop.slice(0, 1) === "@";
|
|
2486
|
+
const mediaValue = FACTORY2[prop];
|
|
2487
|
+
if (!isPropMedia)
|
|
2488
|
+
continue;
|
|
2489
|
+
const { mediaRegenerate } = FACTORY2;
|
|
2490
|
+
const mediaName = prop.slice(1);
|
|
2491
|
+
const {
|
|
2492
|
+
type,
|
|
2493
|
+
base,
|
|
2494
|
+
ratio,
|
|
2495
|
+
range,
|
|
2496
|
+
subSequence,
|
|
2497
|
+
h1Matches,
|
|
2498
|
+
unit
|
|
2499
|
+
} = FACTORY2;
|
|
2500
|
+
(0, import_utils15.merge)(mediaValue, {
|
|
2501
|
+
type,
|
|
2502
|
+
base,
|
|
2503
|
+
ratio,
|
|
2504
|
+
range,
|
|
2505
|
+
subSequence,
|
|
2506
|
+
h1Matches,
|
|
2507
|
+
unit
|
|
2508
|
+
});
|
|
2509
|
+
const query = MEDIA2[mediaName];
|
|
2510
|
+
TYPOGRAPHY2.templates[`@media screen and ${query}`] = {
|
|
2511
|
+
fontSize: mediaValue.base / TYPOGRAPHY2.browserDefault + unit
|
|
2512
|
+
};
|
|
2513
|
+
if (!mediaRegenerate) {
|
|
2514
|
+
applyMediaSequenceVars(FACTORY2, prop);
|
|
2515
|
+
continue;
|
|
2431
2516
|
}
|
|
2517
|
+
(0, import_utils15.merge)(mediaValue, {
|
|
2518
|
+
sequence: {},
|
|
2519
|
+
scales: {},
|
|
2520
|
+
templates: {},
|
|
2521
|
+
vars: {}
|
|
2522
|
+
});
|
|
2523
|
+
generateSequence(mediaValue);
|
|
2524
|
+
applyMediaSequenceVars(FACTORY2, prop);
|
|
2432
2525
|
}
|
|
2433
2526
|
};
|
|
2434
2527
|
var applyHeadings = (props) => {
|
|
@@ -2470,28 +2563,36 @@ var getFontSizeByKey = (value) => {
|
|
|
2470
2563
|
|
|
2471
2564
|
// src/system/spacing.js
|
|
2472
2565
|
var import_utils18 = __toESM(require_cjs(), 1);
|
|
2473
|
-
var runThroughMedia2 = (
|
|
2474
|
-
for (const prop in
|
|
2475
|
-
const mediaProps =
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2566
|
+
var runThroughMedia2 = (FACTORY2) => {
|
|
2567
|
+
for (const prop in FACTORY2) {
|
|
2568
|
+
const mediaProps = FACTORY2[prop];
|
|
2569
|
+
const isMediaName = prop.slice(0, 1) === "@";
|
|
2570
|
+
if (!isMediaName)
|
|
2571
|
+
continue;
|
|
2572
|
+
const {
|
|
2573
|
+
type,
|
|
2574
|
+
base,
|
|
2575
|
+
ratio,
|
|
2576
|
+
range,
|
|
2577
|
+
subSequence,
|
|
2578
|
+
h1Matches,
|
|
2579
|
+
unit
|
|
2580
|
+
} = FACTORY2;
|
|
2581
|
+
(0, import_utils18.merge)(mediaProps, {
|
|
2582
|
+
type,
|
|
2583
|
+
base,
|
|
2584
|
+
ratio,
|
|
2585
|
+
range,
|
|
2586
|
+
subSequence,
|
|
2587
|
+
h1Matches,
|
|
2588
|
+
unit,
|
|
2589
|
+
sequence: {},
|
|
2590
|
+
scales: {},
|
|
2591
|
+
templates: {},
|
|
2592
|
+
vars: {}
|
|
2593
|
+
});
|
|
2594
|
+
generateSequence(mediaProps);
|
|
2595
|
+
applyMediaSequenceVars(FACTORY2, prop);
|
|
2495
2596
|
}
|
|
2496
2597
|
};
|
|
2497
2598
|
var applySpacingSequence = () => {
|
|
@@ -2566,7 +2667,7 @@ var getSpacingBasedOnRatio = (props, propertyName, val) => {
|
|
|
2566
2667
|
unit: SPACING2.unit
|
|
2567
2668
|
});
|
|
2568
2669
|
}
|
|
2569
|
-
applySequenceVars(sequenceProps,
|
|
2670
|
+
applySequenceVars(sequenceProps, { useDefault: false });
|
|
2570
2671
|
return getSpacingByKey(value, propertyName, sequenceProps);
|
|
2571
2672
|
}
|
|
2572
2673
|
return getSpacingByKey(value, propertyName);
|
package/dist/cjs/system/reset.js
CHANGED
|
@@ -1426,6 +1426,7 @@ var defaultProps = {
|
|
|
1426
1426
|
h1Matches: 6,
|
|
1427
1427
|
lineHeight: 1.5,
|
|
1428
1428
|
subSequence: true,
|
|
1429
|
+
mediaRegenerate: false,
|
|
1429
1430
|
unit: "em",
|
|
1430
1431
|
templates: {},
|
|
1431
1432
|
sequence: {},
|
|
@@ -1481,6 +1482,7 @@ var defaultProps2 = {
|
|
|
1481
1482
|
ratio: SEQUENCE.phi,
|
|
1482
1483
|
range: [-5, 15],
|
|
1483
1484
|
subSequence: true,
|
|
1485
|
+
mediaRegenerate: false,
|
|
1484
1486
|
unit: "em",
|
|
1485
1487
|
sequence: {},
|
|
1486
1488
|
scales: {},
|
|
@@ -1508,6 +1510,7 @@ var defaultProps3 = {
|
|
|
1508
1510
|
type: "timing",
|
|
1509
1511
|
ratio: SEQUENCE["perfect-fourth"],
|
|
1510
1512
|
range: [-3, 12],
|
|
1513
|
+
mediaRegenerate: false,
|
|
1511
1514
|
unit: "ms",
|
|
1512
1515
|
sequence: {},
|
|
1513
1516
|
scales: {},
|
|
@@ -1426,6 +1426,7 @@ var defaultProps = {
|
|
|
1426
1426
|
h1Matches: 6,
|
|
1427
1427
|
lineHeight: 1.5,
|
|
1428
1428
|
subSequence: true,
|
|
1429
|
+
mediaRegenerate: false,
|
|
1429
1430
|
unit: "em",
|
|
1430
1431
|
templates: {},
|
|
1431
1432
|
sequence: {},
|
|
@@ -1481,6 +1482,7 @@ var defaultProps2 = {
|
|
|
1481
1482
|
ratio: SEQUENCE.phi,
|
|
1482
1483
|
range: [-5, 15],
|
|
1483
1484
|
subSequence: true,
|
|
1485
|
+
mediaRegenerate: false,
|
|
1484
1486
|
unit: "em",
|
|
1485
1487
|
sequence: {},
|
|
1486
1488
|
scales: {},
|
|
@@ -1508,6 +1510,7 @@ var defaultProps3 = {
|
|
|
1508
1510
|
type: "timing",
|
|
1509
1511
|
ratio: SEQUENCE["perfect-fourth"],
|
|
1510
1512
|
range: [-3, 12],
|
|
1513
|
+
mediaRegenerate: false,
|
|
1511
1514
|
unit: "ms",
|
|
1512
1515
|
sequence: {},
|
|
1513
1516
|
scales: {},
|
|
@@ -1729,45 +1732,74 @@ var numToLetterMap = {
|
|
|
1729
1732
|
19: "T"
|
|
1730
1733
|
};
|
|
1731
1734
|
var setSequenceValue = (props, sequenceProps) => {
|
|
1732
|
-
const { key, variable, value, scaling, index } = props;
|
|
1735
|
+
const { key, variable, value, scaling, index, scalingVariable } = props;
|
|
1733
1736
|
sequenceProps.sequence[key] = {
|
|
1734
1737
|
key,
|
|
1735
1738
|
decimal: ~~(value * 100) / 100,
|
|
1736
1739
|
val: ~~value,
|
|
1737
1740
|
scaling,
|
|
1738
1741
|
index,
|
|
1742
|
+
scalingVariable,
|
|
1739
1743
|
variable
|
|
1740
1744
|
};
|
|
1741
1745
|
sequenceProps.scales[key] = scaling;
|
|
1742
1746
|
sequenceProps.vars[variable] = scaling + sequenceProps.unit;
|
|
1743
1747
|
};
|
|
1748
|
+
var setScalingVar = (key, sequenceProps) => {
|
|
1749
|
+
const { type } = sequenceProps;
|
|
1750
|
+
if (key === 0)
|
|
1751
|
+
return "1em";
|
|
1752
|
+
const prefix = "--" + (type && type.replace(".", "-"));
|
|
1753
|
+
const ratioVar = `${prefix}-ratio`;
|
|
1754
|
+
if (key > 0) {
|
|
1755
|
+
const prevLetterKey = numToLetterMap[key - 1];
|
|
1756
|
+
return `calc(var(${prefix}-${prevLetterKey}) * var(${ratioVar}))`;
|
|
1757
|
+
}
|
|
1758
|
+
if (key < 0) {
|
|
1759
|
+
const nextLetterKey = numToLetterMap[key + 1];
|
|
1760
|
+
return `calc(var(${prefix}-${nextLetterKey}) / var(${ratioVar}))`;
|
|
1761
|
+
}
|
|
1762
|
+
};
|
|
1763
|
+
var setSubScalingVar = (index, arr, variable, sequenceProps) => {
|
|
1764
|
+
const { type } = sequenceProps;
|
|
1765
|
+
const skipMiddle = index === 2 && arr.length === 2;
|
|
1766
|
+
const indexMapWithLength = skipMiddle ? index + 1 : index;
|
|
1767
|
+
const prefix = "--" + (type && type.replace(".", "-"));
|
|
1768
|
+
const subRatioVarPrefix = `${prefix}-sub-ratio-`;
|
|
1769
|
+
return `calc(var(${variable}) * var(${subRatioVarPrefix + indexMapWithLength}))`;
|
|
1770
|
+
};
|
|
1771
|
+
var getSubratioDifference = (base, ratio) => {
|
|
1772
|
+
const diff = base * ratio - base;
|
|
1773
|
+
const subRatio = diff / 1.618;
|
|
1774
|
+
const first = base * ratio - subRatio;
|
|
1775
|
+
const second = base + subRatio;
|
|
1776
|
+
const middle = (first + second) / 2;
|
|
1777
|
+
return [first, middle, second];
|
|
1778
|
+
};
|
|
1744
1779
|
var generateSubSequence = (props, sequenceProps) => {
|
|
1745
1780
|
const { key, base, value, ratio, variable, index } = props;
|
|
1746
1781
|
const next = value * ratio;
|
|
1747
|
-
const
|
|
1748
|
-
|
|
1749
|
-
const
|
|
1750
|
-
const nextRounded = ~~next;
|
|
1751
|
-
const diffRounded = nextRounded - valueRounded;
|
|
1752
|
-
let arr = [];
|
|
1753
|
-
const first = next - smallscale;
|
|
1754
|
-
const second = value + smallscale;
|
|
1755
|
-
const middle = (first + second) / 2;
|
|
1782
|
+
const diffRounded = ~~next - ~~value;
|
|
1783
|
+
let arr;
|
|
1784
|
+
const [first, middle, second] = getSubratioDifference(value, ratio);
|
|
1756
1785
|
if (diffRounded > 16)
|
|
1757
1786
|
arr = [first, middle, second];
|
|
1758
1787
|
else
|
|
1759
1788
|
arr = [first, second];
|
|
1760
|
-
arr.
|
|
1789
|
+
arr.forEach((v, k) => {
|
|
1761
1790
|
const scaling = ~~(v / base * 1e3) / 1e3;
|
|
1762
1791
|
const newVar = variable + (k + 1);
|
|
1792
|
+
const newIndex = index + (k + 1) / 10;
|
|
1793
|
+
const scalingVariable = setSubScalingVar(k + 1, arr, variable, sequenceProps);
|
|
1763
1794
|
const props2 = {
|
|
1764
1795
|
key: key + (k + 1),
|
|
1765
1796
|
variable: newVar,
|
|
1766
1797
|
value: v,
|
|
1767
1798
|
scaling,
|
|
1768
|
-
|
|
1799
|
+
scalingVariable,
|
|
1800
|
+
index: newIndex
|
|
1769
1801
|
};
|
|
1770
|
-
|
|
1802
|
+
setSequenceValue(props2, sequenceProps);
|
|
1771
1803
|
});
|
|
1772
1804
|
};
|
|
1773
1805
|
var switchSequenceOnNegative = (key, base, ratio) => {
|
|
@@ -1783,12 +1815,14 @@ var generateSequence = (sequenceProps) => {
|
|
|
1783
1815
|
const value = switchSequenceOnNegative(key, base, ratio);
|
|
1784
1816
|
const scaling = ~~(value / base * 100) / 100;
|
|
1785
1817
|
const variable = prefix + letterKey;
|
|
1818
|
+
const scalingVariable = setScalingVar(key, sequenceProps);
|
|
1786
1819
|
const props = {
|
|
1787
1820
|
key: letterKey,
|
|
1788
1821
|
variable,
|
|
1789
1822
|
value,
|
|
1790
1823
|
base,
|
|
1791
1824
|
scaling,
|
|
1825
|
+
scalingVariable,
|
|
1792
1826
|
ratio,
|
|
1793
1827
|
index: key
|
|
1794
1828
|
};
|