Skip to content

Commit

Permalink
Do not convert the value to PX units if the variable scope is `FONT_W…
Browse files Browse the repository at this point in the history
…EIGHT`
  • Loading branch information
PavelLaptev committed Nov 21, 2024
1 parent 17bd151 commit 46c7c17
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 7 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -653,3 +653,7 @@ If you have any questions or suggestions, feel free to [create an issue](https:/
**2.2.1**

- Added `paragraphSpacing` and `paragraphIndent` to the typography styles

**2.2.2**

- Do not convert the value to PX units if the variable scope is `FONT_WEIGHT`
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tokens-bruecke",
"version": "2.2.1",
"version": "2.2.2",
"license": "MIT",
"author": {
"name": "Pavel Laptev",
Expand Down
2 changes: 1 addition & 1 deletion src/app/SettingsView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ export const SettingsView = (props: ViewProps) => {
<Text>Documentation</Text>
</a>
<a href={config.changelogLink} target="_blank">
<Text>v.2.2.1</Text>
<Text>v.2.2.2</Text>
</a>
</Stack>
</Panel>
Expand Down
9 changes: 8 additions & 1 deletion src/utils/normalizeValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ import { convertRGBA } from "./color/convertRGBA";
interface PropsI {
variableValue: any;
variableType: VariableResolvedDataType;
variableScope: VariableScope[];
colorMode: colorModeType;
isDTCGForamt: boolean;
includeValueAliasString: boolean;

}

export const normalizeValue = (props: PropsI) => {
const {
variableValue,
variableType,
variableScope,
colorMode,
isDTCGForamt,
includeValueAliasString,
Expand All @@ -37,7 +40,11 @@ export const normalizeValue = (props: PropsI) => {
}

if (variableType === "FLOAT") {
return `${variableValue}px`;
if (variableScope.length === 1 && variableScope[0] === "FONT_WEIGHT") {
return `${variableValue}`;
} else {
return `${variableValue}px`
}
}

return variableValue;
Expand Down
8 changes: 6 additions & 2 deletions src/utils/normilizeType.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
export const normilizeType = (type: VariableResolvedDataType) => {
export const normilizeType = (type: VariableResolvedDataType, variableScopes: VariableScope[]) => {
switch (type) {
case "COLOR":
return "color";
case "FLOAT":
return "dimension";
if (variableScopes.length === 1 && variableScopes[0] === "FONT_WEIGHT") {
return "string";
} else {
return "dimension";
}
case "STRING":
return "string";
case "BOOLEAN":
Expand Down
2 changes: 1 addition & 1 deletion src/utils/styles/effectStylesToTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const wrapShadowObject = (
return null;
}

console.log("shadowEffect", shadowEffect);
// console.log("shadowEffect", shadowEffect);
return {
inset: shadowEffect.type === "INNER_SHADOW",
color: convertRGBA(shadowEffect.color, colorMode),
Expand Down
3 changes: 2 additions & 1 deletion src/utils/variablesToTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const variablesToTokens = async (
normalizeValue({
variableType: variable.resolvedType,
variableValue: variable.valuesByMode[Object.keys(modes)[modeIndex]],
variableScope: variable.scopes,
colorMode,
isDTCGForamt,
includeValueAliasString,
Expand All @@ -76,7 +77,7 @@ export const variablesToTokens = async (
const filteredModesValues = modesAmount === 1 ? {} : modesValues;

const variableObject = {
[keyNames.type]: normilizeType(variable.resolvedType),
[keyNames.type]: normilizeType(variable.resolvedType, variable.scopes),
[keyNames.value]: defaultValue,
[keyNames.description]: variable.description,
// add scopes if true
Expand Down

0 comments on commit 46c7c17

Please sign in to comment.