Skip to content

Commit

Permalink
fix(design): remove expectOverride on CSS causing runtime issue (#2664)
Browse files Browse the repository at this point in the history
## Proposed change

fix(design): remove expectOverride on CSS causing runtime issue
This feature can not be implemented with CSS Variable currently

<!--
Please include a summary of the changes and the related issue.
Please also include relevant motivation and context.
-->

## Related issues

<!--
Please make sure to follow the [contribution
guidelines](https://github.com/amadeus-digital/Otter/blob/main/CONTRIBUTING.md)
-->

*- No issue associated -*

<!-- * 🐛 Fix #issue -->
<!-- * 🐛 Fix resolves #issue -->
<!-- * 🚀 Feature #issue -->
<!-- * 🚀 Feature resolves #issue -->
<!-- * :octocat: Pull Request #issue -->
  • Loading branch information
kpanot authored Jan 8, 2025
2 parents 4fee47d + a021ea2 commit e116ac5
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/@o3r/design/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ To enhance the features of default Design Token standard and provide additional
| **o3rMetadata** | `css`, `sass`, `json-schema`, `metadata`, `design-token` | Additional information to provide to the metadata if generated |
| **o3rUnit** | `css`, `sass`, `metadata`, `design-token` | Convert a numeric value from the specified unit to the new unit. It will add a unit to the token with type "number" for which the unit is not specified.<br />In case of a complex type (such as shadow, transition, etc...), the unit will be applied to all numeric types in it. |
| **o3rRatio** | `css`, `sass`, `metadata`, `design-token` | Ratio to apply to previous value. The ratio will only be applied to a token of type "number" or to the first numbers determined in "string" types.<br />In case of a complex type (such as shadow, transition, etc...), the ratio will be applied to all numeric types in it. |
| **o3rExpectOverride** | `css`, `sass` | Indicate that the token is expected to be overridden by external rules. |
| **o3rExpectOverride** | `sass` | Indicate that the token is expected to be overridden by external rules. |
| **o3rExplodeComplexTypes** | `css`, `sass`, `json-schema`, `metadata`, `design-token` | Explode a Token with complex type to generate variables for each field of the type definition. |

> [!NOTE]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,4 @@ describe('getMetadataTokenDefinitionRenderer', () => {
expect(result2).toContain('$test');
expect(privateDefinitionRenderer).toHaveBeenCalledTimes(1);
});

test('should enforce reference when expecting override', () => {
const tokenValueRenderer = jest.fn().mockReturnValue(JSON.stringify({ name: 'test-var', value: 'test-value' }));
const renderer = getCssTokenDefinitionRenderer({ tokenValueRenderer });
const variable = designTokens.get('example.var-expect-override');

renderer(variable, designTokens);
expect(variable).toBeDefined();
expect(tokenValueRenderer).toHaveBeenCalledTimes(1);
expect(tokenValueRenderer).toHaveBeenCalledWith(expect.objectContaining({}), expect.objectContaining({}), true);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const getCssTokenDefinitionRenderer = (options?: CssTokenDefinitionRender
const renderer = (variable: DesignTokenVariableStructure, variableSet: Map<string, DesignTokenVariableStructure>) => {
let variableString: string | undefined;
if (!isPrivateVariable(variable)) {
variableString = `--${variable.getKey(tokenVariableNameRenderer)}: ${tokenValueRenderer(variable, variableSet, !!variable.extensions.o3rExpectOverride)};`;
variableString = `--${variable.getKey(tokenVariableNameRenderer)}: ${tokenValueRenderer(variable, variableSet)};`;
if (variable.extensions.o3rScope) {
variableString = `${variable.extensions.o3rScope} { ${variableString} }`;
}
Expand Down

0 comments on commit e116ac5

Please sign in to comment.