Skip to content

Commit

Permalink
docs: Fix computed value bug in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
alanbsmith committed Oct 19, 2023
1 parent 33654f4 commit f9c89d8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const fontFamilyTokens: FontFamilyToken[] = Object.values(system.fontFamily).map

return {
label: varName,
value: value,
value: value.replace(/"/g, ''),
};
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ interface ShapeToken {
}

function multiplyCalcValues(value: string) {
// Matches numbers such as .25, 0.25, or 25
const numberRegExp = new RegExp(/(0*\.)?\d+/g);
// Find the numbers in the string value
const matches = value.match(/(0.)?\d+/g);
const matches = value.match(numberRegExp);
if (matches) {
// Multiply the matched values
return matches.reduce((acc, current) => acc * Number(current), 1);
Expand All @@ -24,6 +26,7 @@ function multiplyCalcValues(value: string) {
const shapeTokens: ShapeToken[] = Object.values(system.shape).map(varName => {
const value = getComputedStyle(document.documentElement).getPropertyValue(varName);
const computedValue = multiplyCalcValues(value);

return {
label: varName,
value: value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ interface SpaceToken {
}

function multiplyCalcValues(value: string) {
// Matches numbers such as .25, 0.25, or 25
const numberRegExp = new RegExp(/(0*\.)?\d+/g);
// Find the numbers in the string value
const matches = value.match(/(0.)?\d+/g);
const matches = value.match(numberRegExp);
if (matches) {
// Multiply the matched values
return matches.reduce((acc, current) => acc * Number(current), 1);
Expand Down

0 comments on commit f9c89d8

Please sign in to comment.