✨(tokens) make sass maps overridable
We suffix all sass maps with `!default` flag. In this way, if a consumer needs to override cunningham tokens, it will be able to.
This commit is contained in:
committed by
Jean-Baptiste PENRATH
parent
fb2fb3e107
commit
7eac0bfca1
5
.changeset/calm-ties-hear.md
Normal file
5
.changeset/calm-ties-hear.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@openfun/cunningham-tokens": minor
|
||||
---
|
||||
|
||||
Suffix all sass maps with the `!default` map
|
||||
@@ -30,22 +30,22 @@ describe("SassGenerator", () => {
|
||||
'secondary': #DA0000,
|
||||
'ternary-900': #022858,
|
||||
'ogre-odor-is-orange-indeed': #FD5240
|
||||
);
|
||||
) !default;
|
||||
$fontFamilies: (
|
||||
'base': Roboto
|
||||
);
|
||||
) !default;
|
||||
$fontSizes: (
|
||||
'm': 1rem
|
||||
);
|
||||
) !default;
|
||||
$fontWeights: (
|
||||
'medium': 400
|
||||
);
|
||||
) !default;
|
||||
$spacings: (
|
||||
's': 1rem
|
||||
);
|
||||
) !default;
|
||||
$transitions: (
|
||||
'ease': linear
|
||||
);
|
||||
) !default;
|
||||
"
|
||||
`);
|
||||
});
|
||||
|
||||
@@ -49,7 +49,7 @@ const generateTransitionsSassMap = (tokens: Tokens) => {
|
||||
return `$transitions: ${JSONToSassMap(tokens.theme.transitions)};`;
|
||||
};
|
||||
|
||||
function JSONToSassMap(json: Object) {
|
||||
function JSONToSassMap(json: Object, isDefault = true) {
|
||||
function deepQuoteObjectKeys(object: Object) {
|
||||
return Object.entries(object).reduce(
|
||||
(acc, [key, value]): Record<string, any> => ({
|
||||
@@ -65,5 +65,6 @@ function JSONToSassMap(json: Object) {
|
||||
return JSON.stringify(jsonWithQuotedKeys, null, 2)
|
||||
.replace(/{/g, "(")
|
||||
.replace(/}/g, ")")
|
||||
.replace(/"/g, "");
|
||||
.replace(/"/g, "")
|
||||
.concat(isDefault ? " !default" : "");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user