diff --git a/.changeset/quick-spies-own.md b/.changeset/quick-spies-own.md new file mode 100644 index 0000000..eaa860a --- /dev/null +++ b/.changeset/quick-spies-own.md @@ -0,0 +1,6 @@ +--- +"@initiate-ui/typescale-generator": patch +"@initiate-ui/typescale-cli": patch +--- + +patched in step to object for filtering diff --git a/apps/figma/src/index.ts b/apps/figma/src/index.ts deleted file mode 100644 index e56633a..0000000 --- a/apps/figma/src/index.ts +++ /dev/null @@ -1,41 +0,0 @@ -// flow for testing - -// this will have to be fetch in the real world so will need types - -function splitTokenReference(string: string) { - return string.replace("{", "").replace("}", "").split("."); -} - -function findReferenceValue(string: string[], tokens: object) { - return string.reduce((o: any, i) => o?.[i], tokens); -} - -async function get() { - const req = await fetch("/styles.json"); - const fontStyleData = await req.json(); - - //const config = fontStyleData.config; - const tokens = fontStyleData.tokens; - const styles = fontStyleData.styles; - - // loop through styles - - Object.keys(styles).forEach(function (styleName, index) { - const values = styles[styleName]?.$value; - Object.keys(values).forEach(function (prop) { - const token = values[prop]; - // is it a reference? - if (token && typeof token === "string" && token.match("{") !== null) { - const tokenReference = splitTokenReference(token); - const tokenValue = findReferenceValue(tokenReference, tokens); - console.log({ type: prop, value: tokenValue?.$value }); - } else { - console.log({ type: prop, value: token }); - } - }); - }); -} - -get(); - -export default get \ No newline at end of file diff --git a/packages/typescale-generator/src/tests/__snapshots__/buildTypographyScales.test.ts.snap b/packages/typescale-generator/src/tests/__snapshots__/buildTypographyScales.test.ts.snap index ad3f1d8..6d24ef6 100644 --- a/packages/typescale-generator/src/tests/__snapshots__/buildTypographyScales.test.ts.snap +++ b/packages/typescale-generator/src/tests/__snapshots__/buildTypographyScales.test.ts.snap @@ -25,6 +25,7 @@ Object { "width": 1440, }, ], + "step": -1, }, "step-0": Object { "clamp": "clamp(1rem, 0.93rem + 0.36vw, 1.25rem)", @@ -48,6 +49,7 @@ Object { "width": 1440, }, ], + "step": 0, }, "step-1": Object { "clamp": "clamp(1.07rem, 0.9rem + 0.86vw, 1.67rem)", @@ -71,6 +73,7 @@ Object { "width": 1440, }, ], + "step": 1, }, "step-2": Object { "clamp": "clamp(1.14rem, 0.83rem + 1.55vw, 2.22rem)", @@ -94,6 +97,7 @@ Object { "width": 1440, }, ], + "step": 2, }, }, } diff --git a/packages/typescale-generator/src/tests/__snapshots__/stepValues.test.ts.snap b/packages/typescale-generator/src/tests/__snapshots__/stepValues.test.ts.snap index 2782677..bd34b66 100644 --- a/packages/typescale-generator/src/tests/__snapshots__/stepValues.test.ts.snap +++ b/packages/typescale-generator/src/tests/__snapshots__/stepValues.test.ts.snap @@ -10,5 +10,6 @@ Object { "width": 320, }, ], + "step": 1, } `; diff --git a/packages/typescale-generator/src/utils/interfaces.ts b/packages/typescale-generator/src/utils/interfaces.ts index 4922915..ad92e24 100644 --- a/packages/typescale-generator/src/utils/interfaces.ts +++ b/packages/typescale-generator/src/utils/interfaces.ts @@ -13,7 +13,7 @@ export interface GeneratedNamedScalesProps { export interface GeneratedItemProps { - + step : number, sizes : ViewPortProps[]; clamp: string; } diff --git a/packages/typescale-generator/src/utils/scales/stepValues.ts b/packages/typescale-generator/src/utils/scales/stepValues.ts index 18aba5c..11e79a1 100644 --- a/packages/typescale-generator/src/utils/scales/stepValues.ts +++ b/packages/typescale-generator/src/utils/scales/stepValues.ts @@ -63,6 +63,7 @@ export function stepValues({ step, sizes}: { ) : undefined; return { + step : step, sizes: values, clamp: valueMax && max ? clampBuilder( min.width,