@openedx/paragon 23.0.0-alpha.2 → 23.0.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/paragon-scripts.js +10 -0
- package/dist/Annotation/index.scss +16 -0
- package/dist/Button/index.d.ts +35 -0
- package/dist/Button/index.js +37 -15
- package/dist/Button/index.js.map +1 -1
- package/dist/Card/CardDeck.js +0 -2
- package/dist/Card/CardDeck.js.map +1 -1
- package/dist/Card/index.scss +6 -6
- package/dist/Carousel/index.scss +24 -1
- package/dist/Chip/ChipIcon.d.ts +13 -8
- package/dist/Chip/ChipIcon.js +0 -2
- package/dist/Chip/ChipIcon.js.map +1 -1
- package/dist/Chip/constants.d.ts +4 -0
- package/dist/Chip/constants.js +3 -2
- package/dist/Chip/constants.js.map +1 -0
- package/dist/Chip/index.d.ts +4 -3
- package/dist/Chip/index.js +2 -4
- package/dist/Chip/index.js.map +1 -1
- package/dist/ChipCarousel/index.js +0 -2
- package/dist/ChipCarousel/index.js.map +1 -1
- package/dist/CloseButton/index.scss +8 -0
- package/dist/ColorPicker/index.scss +1 -1
- package/dist/DataTable/index.scss +12 -0
- package/dist/Dropdown/dropdown-bootstrap.scss +6 -0
- package/dist/Dropzone/index.scss +34 -0
- package/dist/Form/_FormText.scss +1 -1
- package/dist/Form/_bootstrap-custom-forms.scss +40 -0
- package/dist/Form/_index.scss +9 -0
- package/dist/Form/_mixins.scss +22 -0
- package/dist/Hyperlink/index.d.ts +24 -0
- package/dist/Hyperlink/index.js +20 -32
- package/dist/Hyperlink/index.js.map +1 -1
- package/dist/Icon/index.d.ts +4 -2
- package/dist/Icon/index.js +1 -1
- package/dist/Icon/index.js.map +1 -1
- package/dist/IconButton/index.d.ts +342 -0
- package/dist/IconButton/index.js +18 -26
- package/dist/IconButton/index.js.map +1 -1
- package/dist/IconButton/index.scss +146 -0
- package/dist/Menu/index.scss +8 -0
- package/dist/Modal/ModalDialog.js +8 -4
- package/dist/Modal/ModalDialog.js.map +1 -1
- package/dist/Modal/ModalPopup.js +7 -1
- package/dist/Modal/ModalPopup.js.map +1 -1
- package/dist/Modal/_ModalDialog.scss +26 -2
- package/dist/Nav/index.scss +8 -0
- package/dist/Overlay/index.d.ts +128 -0
- package/dist/Overlay/index.js +8 -2
- package/dist/Overlay/index.js.map +1 -1
- package/dist/PageBanner/index.scss +2 -2
- package/dist/Pagination/pagination-bootstrap.scss +9 -0
- package/dist/Popover/index.scss +1 -1
- package/dist/ProductTour/Checkpoint.scss +1 -1
- package/dist/ProgressBar/bootstrap-progress.scss +20 -5
- package/dist/ProgressBar/index.scss +3 -3
- package/dist/Stepper/index.scss +1 -1
- package/dist/Sticky/index.scss +12 -0
- package/dist/Toast/index.scss +13 -1
- package/dist/Tooltip/index.d.ts +7 -0
- package/dist/Tooltip/index.js.map +1 -1
- package/dist/Tooltip/index.scss +16 -0
- package/dist/core.css +914 -470
- package/dist/core.css.map +1 -1
- package/dist/core.min.css +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +7 -7
- package/dist/light.css +2035 -1315
- package/dist/light.css.map +1 -1
- package/dist/light.min.css +1 -1
- package/dist/setupTest.d.ts +2 -0
- package/dist/setupTest.js.map +1 -0
- package/dist/utils/types/bootstrap.d.ts +39 -0
- package/dist/utils/types/bootstrap.js +2 -0
- package/dist/utils/types/bootstrap.js.map +1 -0
- package/lib/build-tokens.js +67 -31
- package/package.json +11 -8
- package/src/Annotation/index.scss +16 -0
- package/src/Button/{Button.test.jsx → Button.test.tsx} +14 -2
- package/src/Button/__snapshots__/{Button.test.jsx.snap → Button.test.tsx.snap} +19 -2
- package/src/Button/{index.jsx → index.tsx} +58 -16
- package/src/Card/CardDeck.jsx +0 -3
- package/src/Card/README.md +0 -31
- package/src/Card/index.scss +6 -6
- package/src/Carousel/index.scss +24 -1
- package/src/Chip/{Chip.test.jsx → Chip.test.tsx} +5 -7
- package/src/Chip/ChipIcon.tsx +8 -8
- package/src/Chip/{constants.js → constants.ts} +1 -1
- package/src/Chip/index.tsx +6 -8
- package/src/ChipCarousel/index.tsx +0 -2
- package/src/CloseButton/index.scss +8 -0
- package/src/ColorPicker/index.scss +1 -1
- package/src/DataTable/index.scss +12 -0
- package/src/Dropdown/dropdown-bootstrap.scss +6 -0
- package/src/Dropzone/index.scss +34 -0
- package/src/Form/_FormText.scss +1 -1
- package/src/Form/_bootstrap-custom-forms.scss +40 -0
- package/src/Form/_index.scss +9 -0
- package/src/Form/_mixins.scss +22 -0
- package/src/Hyperlink/{Hyperlink.test.jsx → Hyperlink.test.tsx} +21 -10
- package/src/Hyperlink/{index.jsx → index.tsx} +41 -37
- package/src/Icon/index.d.ts +4 -2
- package/src/Icon/index.jsx +1 -1
- package/src/IconButton/{IconButton.test.jsx → IconButton.test.tsx} +24 -3
- package/src/IconButton/__snapshots__/IconButton.test.tsx.snap +90 -0
- package/src/IconButton/index.scss +146 -0
- package/src/IconButton/{index.jsx → index.tsx} +66 -26
- package/src/Menu/index.scss +8 -0
- package/src/Modal/ModalDialog.jsx +7 -3
- package/src/Modal/ModalPopup.jsx +9 -1
- package/src/Modal/_ModalDialog.scss +26 -2
- package/src/Modal/modal-dialog.mdx +95 -6
- package/src/Modal/tests/ModalDialog.test.jsx +2 -0
- package/src/Modal/tests/ModalPopupNoMock.test.jsx +29 -0
- package/src/Nav/index.scss +8 -0
- package/src/Overlay/{index.jsx → index.tsx} +13 -8
- package/src/PageBanner/index.scss +2 -2
- package/src/Pagination/pagination-bootstrap.scss +9 -0
- package/src/Popover/index.scss +1 -1
- package/src/ProductTour/Checkpoint.scss +1 -1
- package/src/ProgressBar/bootstrap-progress.scss +20 -5
- package/src/ProgressBar/index.scss +3 -3
- package/src/Stepper/index.scss +1 -1
- package/src/Sticky/index.scss +12 -0
- package/src/Toast/index.scss +13 -1
- package/src/Tooltip/index.scss +16 -0
- package/src/Tooltip/{index.jsx → index.tsx} +9 -3
- package/src/index.d.ts +5 -5
- package/src/index.js +7 -7
- package/src/{setupTest.js → setupTest.ts} +1 -0
- package/src/utils/types/bootstrap.test.tsx +86 -0
- package/src/utils/types/bootstrap.ts +43 -0
- package/styles/css/core/abstraction-variables.css +44 -0
- package/styles/css/core/custom-media-breakpoints.css +3 -4
- package/styles/css/core/index.css +2 -1
- package/styles/css/core/variables.css +494 -430
- package/styles/css/themes/light/abstraction-variables.css +304 -0
- package/styles/css/themes/light/index.css +1 -0
- package/styles/css/themes/light/utility-classes.css +2 -3
- package/styles/css/themes/light/variables.css +1753 -1334
- package/styles/scss/core/_typography.scss +16 -4
- package/styles/scss/core/_utilities.scss +7 -3
- package/styles/scss/core/_variables.scss +43 -30
- package/styles/scss/core/core.scss +1 -0
- package/tokens/src/core/alias/size.json +6 -5
- package/tokens/src/core/components/ActionRow.json +3 -2
- package/tokens/src/core/components/Alert.json +12 -10
- package/tokens/src/core/components/Annotation.json +9 -7
- package/tokens/src/core/components/Avatar.json +9 -9
- package/tokens/src/core/components/AvatarButton.json +4 -3
- package/tokens/src/core/components/Badge.json +12 -9
- package/tokens/src/core/components/Breadcrumb.json +7 -5
- package/tokens/src/core/components/Bubble.json +4 -3
- package/tokens/src/core/components/Button/core.json +35 -59
- package/tokens/src/core/components/Card.json +33 -44
- package/tokens/src/core/components/Carousel.json +39 -13
- package/tokens/src/core/components/Chip.json +13 -21
- package/tokens/src/core/components/ChipCarousel.json +4 -5
- package/tokens/src/core/components/CloseButton.json +2 -6
- package/tokens/src/core/components/Code.json +9 -8
- package/tokens/src/core/components/Collapsible.json +10 -13
- package/tokens/src/core/components/ColorPicker.json +3 -2
- package/tokens/src/core/components/Container.json +6 -5
- package/tokens/src/core/components/DataTable.json +17 -9
- package/tokens/src/core/components/Dropdown.json +24 -29
- package/tokens/src/core/components/Dropzone.json +5 -7
- package/tokens/src/core/components/Form/other.json +5 -4
- package/tokens/src/core/components/Form/size.json +72 -119
- package/tokens/src/core/components/Form/spacing.json +39 -83
- package/tokens/src/core/components/Form/transition.json +43 -7
- package/tokens/src/core/components/Form/typography.json +24 -88
- package/tokens/src/core/components/Icon.json +6 -5
- package/tokens/src/core/components/IconButton.json +4 -7
- package/tokens/src/core/components/Image.json +7 -6
- package/tokens/src/core/components/Menu.json +14 -12
- package/tokens/src/core/components/Modal.json +26 -21
- package/tokens/src/core/components/Nav.json +14 -16
- package/tokens/src/core/components/Navbar.json +15 -30
- package/tokens/src/core/components/Pagination.json +23 -24
- package/tokens/src/core/components/Popover.json +18 -14
- package/tokens/src/core/components/ProductTour.json +8 -14
- package/tokens/src/core/components/ProgressBar.json +29 -14
- package/tokens/src/core/components/SearchField.json +7 -9
- package/tokens/src/core/components/SelectableBox.json +4 -3
- package/tokens/src/core/components/Sheet.json +3 -2
- package/tokens/src/core/components/Spinner.json +9 -7
- package/tokens/src/core/components/Stack.json +2 -1
- package/tokens/src/core/components/Stepper.json +12 -14
- package/tokens/src/core/components/Sticky.json +2 -1
- package/tokens/src/core/components/Tab.json +8 -7
- package/tokens/src/core/components/Tabs.json +5 -5
- package/tokens/src/core/components/Toast.json +11 -8
- package/tokens/src/core/components/Tooltip.json +13 -11
- package/tokens/src/core/components/general/caret.json +5 -3
- package/tokens/src/core/components/general/headings.json +5 -4
- package/tokens/src/core/components/general/hr.json +3 -2
- package/tokens/src/core/components/general/input.json +19 -19
- package/tokens/src/core/components/general/link.json +13 -12
- package/tokens/src/core/components/general/list.json +9 -6
- package/tokens/src/core/components/general/text.json +6 -12
- package/tokens/src/core/global/breakpoints.json +25 -6
- package/tokens/src/core/global/elevation.json +55 -13
- package/tokens/src/core/global/other.json +5 -1
- package/tokens/src/core/global/spacing.json +70 -17
- package/tokens/src/core/global/transition.json +41 -4
- package/tokens/src/core/global/typography.json +248 -53
- package/tokens/src/core/utilities/color.json +35 -4
- package/tokens/src/themes/light/alias/color.json +276 -75
- package/tokens/src/themes/light/components/Alert.json +15 -26
- package/tokens/src/themes/light/components/Annotation.json +27 -13
- package/tokens/src/themes/light/components/Avatar.json +2 -1
- package/tokens/src/themes/light/components/Badge.json +57 -122
- package/tokens/src/themes/light/components/Breadcrumb.json +6 -5
- package/tokens/src/themes/light/components/Bubble.json +9 -8
- package/tokens/src/themes/light/components/Button/brand.json +171 -119
- package/tokens/src/themes/light/components/Button/core.json +8 -9
- package/tokens/src/themes/light/components/Button/danger.json +171 -112
- package/tokens/src/themes/light/components/Button/dark.json +188 -106
- package/tokens/src/themes/light/components/Button/info.json +186 -112
- package/tokens/src/themes/light/components/Button/light.json +186 -110
- package/tokens/src/themes/light/components/Button/primary.json +178 -116
- package/tokens/src/themes/light/components/Button/secondary.json +166 -132
- package/tokens/src/themes/light/components/Button/success.json +176 -117
- package/tokens/src/themes/light/components/Button/tertiary.json +34 -60
- package/tokens/src/themes/light/components/Button/warning.json +164 -128
- package/tokens/src/themes/light/components/Card.json +10 -21
- package/tokens/src/themes/light/components/Carousel.json +12 -11
- package/tokens/src/themes/light/components/Chip.json +14 -26
- package/tokens/src/themes/light/components/CloseButton.json +12 -2
- package/tokens/src/themes/light/components/Code.json +7 -9
- package/tokens/src/themes/light/components/DataTable.json +7 -11
- package/tokens/src/themes/light/components/Dropdown.json +17 -20
- package/tokens/src/themes/light/components/Dropzone.json +49 -11
- package/tokens/src/themes/light/components/Form/color.json +101 -155
- package/tokens/src/themes/light/components/Form/elevation.json +38 -42
- package/tokens/src/themes/light/components/Form/other.json +44 -41
- package/tokens/src/themes/light/components/IconButton.json +408 -256
- package/tokens/src/themes/light/components/Image.json +7 -4
- package/tokens/src/themes/light/components/Menu.json +12 -10
- package/tokens/src/themes/light/components/Modal.json +22 -12
- package/tokens/src/themes/light/components/Nav.json +82 -94
- package/tokens/src/themes/light/components/Navbar.json +32 -76
- package/tokens/src/themes/light/components/OverflowScroll.json +3 -1
- package/tokens/src/themes/light/components/PageBanner.json +11 -10
- package/tokens/src/themes/light/components/Pagination.json +19 -23
- package/tokens/src/themes/light/components/Popover.json +22 -27
- package/tokens/src/themes/light/components/ProductTour.json +9 -20
- package/tokens/src/themes/light/components/ProgressBar.json +12 -10
- package/tokens/src/themes/light/components/Scrollable.json +3 -3
- package/tokens/src/themes/light/components/SearchField.json +9 -9
- package/tokens/src/themes/light/components/Sheet.json +6 -7
- package/tokens/src/themes/light/components/Stepper.json +12 -17
- package/tokens/src/themes/light/components/Sticky.json +31 -6
- package/tokens/src/themes/light/components/Tab.json +47 -24
- package/tokens/src/themes/light/components/Toast.json +26 -14
- package/tokens/src/themes/light/components/Tooltip.json +25 -10
- package/tokens/src/themes/light/components/general/body.json +3 -2
- package/tokens/src/themes/light/components/general/headings.json +2 -1
- package/tokens/src/themes/light/components/general/hr.json +3 -6
- package/tokens/src/themes/light/components/general/input.json +11 -4
- package/tokens/src/themes/light/components/general/link.json +34 -43
- package/tokens/src/themes/light/components/general/list.json +15 -19
- package/tokens/src/themes/light/components/general/text.json +5 -6
- package/tokens/src/themes/light/global/color.json +1592 -867
- package/tokens/src/themes/light/global/elevation.json +481 -93
- package/tokens/style-dictionary.js +342 -144
- package/tokens/utils.js +176 -6
- package/src/IconButton/__snapshots__/IconButton.test.jsx.snap +0 -20
- package/tokens/src/core/global/display.json +0 -22
- /package/src/Button/{ButtonGroup.test.jsx → ButtonGroup.test.tsx} +0 -0
- /package/src/Button/{ButtonToolbar.test.jsx → ButtonToolbar.test.tsx} +0 -0
- /package/src/Button/__snapshots__/{ButtonGroup.test.jsx.snap → ButtonGroup.test.tsx.snap} +0 -0
- /package/src/Button/__snapshots__/{ButtonToolbar.test.jsx.snap → ButtonToolbar.test.tsx.snap} +0 -0
- /package/src/Chip/__snapshots__/{Chip.test.jsx.snap → Chip.test.tsx.snap} +0 -0
- /package/src/Tooltip/{Tooltip.test.jsx → Tooltip.test.tsx} +0 -0
package/tokens/utils.js
CHANGED
|
@@ -2,6 +2,142 @@ const fs = require('fs');
|
|
|
2
2
|
const readline = require('readline');
|
|
3
3
|
const path = require('path');
|
|
4
4
|
|
|
5
|
+
const visitedTokens = {};
|
|
6
|
+
|
|
7
|
+
const commonCssFiles = ['variables.css', 'abstraction-variables.css'];
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Finds a token by its path in the token tree.
|
|
11
|
+
* @param {string} path - The path to the token in the token tree.
|
|
12
|
+
* @returns {DesignToken} - The token object found at the specified path.
|
|
13
|
+
*/
|
|
14
|
+
function findTokenByPath(tokenPath, allTokens) {
|
|
15
|
+
const keys = tokenPath.split('.');
|
|
16
|
+
return keys.reduce((acc, key) => acc && acc[key], allTokens);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @typedef {object} ExtensionProperty
|
|
21
|
+
* @property {string} name - The name of the extension property.
|
|
22
|
+
* @property {(token: DesignToken) => boolean} filter - The filter function to determine
|
|
23
|
+
* if the token should be annotated.
|
|
24
|
+
* @property {(token: DesignToken) => boolean} referenceTokenFilter - The filter function to determine if
|
|
25
|
+
* the referenced token should be annotated.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @typedef {object} AnnotateReferencedTokenExtensionsArgs
|
|
30
|
+
* @property {DesignToken} token - The token object to annotate.
|
|
31
|
+
* @property {ExtensionProperty[]} extensionProperties - The properties to annotate the referenced token with.
|
|
32
|
+
* @property {object} sdUtils - The Style Dictionary utility functions.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Annotates referenced token $extensions with the specified properties.
|
|
37
|
+
* @param {AnnotateReferencedTokenExtensionsArgs} args - The arguments object.
|
|
38
|
+
*/
|
|
39
|
+
function annotateReferencedTokenExtensions({
|
|
40
|
+
token,
|
|
41
|
+
extensionProperties,
|
|
42
|
+
sdUtils,
|
|
43
|
+
dictionary,
|
|
44
|
+
}) {
|
|
45
|
+
const stack = [token]; // Stack to process tokens iteratively
|
|
46
|
+
|
|
47
|
+
while (stack.length > 0) {
|
|
48
|
+
const currentToken = stack.pop();
|
|
49
|
+
|
|
50
|
+
// Get all references for the current token
|
|
51
|
+
const references = sdUtils.getReferences(currentToken, dictionary);
|
|
52
|
+
extensionProperties.forEach(({ name: propertyName, filter: propertyFilter, referenceTokenFilter }) => {
|
|
53
|
+
if (!propertyFilter(token)) {
|
|
54
|
+
// Skip processing if the token does not match the filter for the property
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Iterate over each reference and mark the referenced token
|
|
59
|
+
references.forEach((foundReference) => {
|
|
60
|
+
const foundReferenceTokenPath = foundReference.ref.join('.');
|
|
61
|
+
if (visitedTokens[propertyName]?.has(foundReferenceTokenPath)) {
|
|
62
|
+
// Skip processing if the referenced token has already been marked
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (!referenceTokenFilter?.(foundReference)) {
|
|
67
|
+
// Filter the reference tokens to only include the ones that match the filter
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Directly access the referenced token from the returned reference object
|
|
72
|
+
const referencedToken = findTokenByPath(foundReferenceTokenPath, dictionary);
|
|
73
|
+
if (!referencedToken) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Mark the referenced token
|
|
78
|
+
referencedToken.$extensions = {
|
|
79
|
+
...referencedToken.$extensions,
|
|
80
|
+
'org.openedx.paragon': {
|
|
81
|
+
...referencedToken.$extensions?.['org.openedx.paragon'],
|
|
82
|
+
[propertyName]: true,
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
visitedTokens[propertyName].add(foundReferenceTokenPath);
|
|
87
|
+
|
|
88
|
+
if (sdUtils.usesReferences(referencedToken)) {
|
|
89
|
+
// Push the referenced token to the stack to process its references
|
|
90
|
+
stack.push(referencedToken);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Processes and updates tokens in place by annotating referenced tokens with extension properties.
|
|
99
|
+
* @typedef {object} ProcessAndUpdateTokensArgs
|
|
100
|
+
* @property {object} tokens - The tokens object to process.
|
|
101
|
+
* @property {ExtensionProperty[]} extensionProperties - The properties to annotate the referenced token with.
|
|
102
|
+
* @property {object} sdUtils - The Style Dictionary utility functions.
|
|
103
|
+
*/
|
|
104
|
+
function processAndUpdateTokens(tokens, extensionProperties, sdUtils, dictionary) {
|
|
105
|
+
Object.keys(tokens).forEach(async (key) => {
|
|
106
|
+
const token = tokens[key];
|
|
107
|
+
if (typeof token !== 'object') {
|
|
108
|
+
// Skip non-object tokens
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// If this is a group (nested tokens), recurse into it
|
|
113
|
+
if (!Object.prototype.hasOwnProperty.call(token, '$value')) {
|
|
114
|
+
processAndUpdateTokens(token, extensionProperties, sdUtils, dictionary);
|
|
115
|
+
} else if (sdUtils.usesReferences(token)) {
|
|
116
|
+
// Initialize the visited tokens for each extension property
|
|
117
|
+
extensionProperties.forEach((property) => {
|
|
118
|
+
visitedTokens[property.name] = new Set();
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// If the token uses reference(s), update the referenced token(s) $extensions metadata.
|
|
122
|
+
annotateReferencedTokenExtensions({
|
|
123
|
+
token,
|
|
124
|
+
extensionProperties,
|
|
125
|
+
sdUtils,
|
|
126
|
+
dictionary,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Recursively retrieves files with a specific extension from a given directory.
|
|
134
|
+
*
|
|
135
|
+
* @param {string} location - The path to the directory or file to start the search.
|
|
136
|
+
* @param {string} extension - The file extension to search for (e.g., '.js', '.css').
|
|
137
|
+
* @param {string[]} [files=[]] - An array to accumulate the file paths that match the extension.
|
|
138
|
+
* @param {string[]} [excludeDirectories=[]] - An array of directory names to exclude from the search.
|
|
139
|
+
* @returns {string[]} - An array of file paths that have the specified extension.
|
|
140
|
+
*/
|
|
5
141
|
function getFilesWithExtension(location, extension, files = [], excludeDirectories = []) {
|
|
6
142
|
const content = fs.statSync(location);
|
|
7
143
|
if (content.isDirectory()) {
|
|
@@ -17,6 +153,14 @@ function getFilesWithExtension(location, extension, files = [], excludeDirectori
|
|
|
17
153
|
return files;
|
|
18
154
|
}
|
|
19
155
|
|
|
156
|
+
/**
|
|
157
|
+
* Generates a mapping of SCSS variables to corresponding CSS variables.
|
|
158
|
+
*
|
|
159
|
+
* @param {string} prefix - The prefix used to build the CSS variable names (e.g., '--my-prefix').
|
|
160
|
+
* @param {Object} tokensObject - The object representing the design tokens, which may be nested.
|
|
161
|
+
* @param {Object} result - The object where the mapping of SCSS to CSS variables will be stored.
|
|
162
|
+
* @returns {Object} - The `result` object containing the SCSS-to-CSS variable mappings.
|
|
163
|
+
*/
|
|
20
164
|
function getSCSStoCSSMap(prefix, tokensObject, result) {
|
|
21
165
|
Object.entries(tokensObject).forEach(([node, value]) => {
|
|
22
166
|
if (value?.constructor.name === 'Object') {
|
|
@@ -30,6 +174,16 @@ function getSCSStoCSSMap(prefix, tokensObject, result) {
|
|
|
30
174
|
return result;
|
|
31
175
|
}
|
|
32
176
|
|
|
177
|
+
/**
|
|
178
|
+
* Replaces variable usage in a file based on a provided mapping and direction.
|
|
179
|
+
*
|
|
180
|
+
* @param {string} filePath - The path to the file where variables should be replaced.
|
|
181
|
+
* @param {Object} variablesMap - A map of variables to their replacement values.
|
|
182
|
+
* @param {string} [direction='scss-to-css'] - The direction of the replacement, either `scss-to-css` or `css-to-scss`.
|
|
183
|
+
* - `scss-to-css`: Replaces SCSS variables (e.g., `$some-variable`) with CSS variables.
|
|
184
|
+
* - `css-to-scss`: Replaces CSS variables (e.g., `var(--some-variable)`) with SCSS variables.
|
|
185
|
+
* @returns {Promise<void>} - A promise that resolves when the file has been successfully processed and written.
|
|
186
|
+
*/
|
|
33
187
|
async function replaceVariablesUsage(filePath, variablesMap, direction = 'scss-to-css') {
|
|
34
188
|
let variableRegex;
|
|
35
189
|
let result = '';
|
|
@@ -162,8 +316,17 @@ async function transformInPath(location, variablesMap, transformType = 'definiti
|
|
|
162
316
|
}
|
|
163
317
|
}
|
|
164
318
|
|
|
165
|
-
|
|
166
|
-
|
|
319
|
+
/**
|
|
320
|
+
* Creates an `index.css` file that imports all other CSS files in a directory.
|
|
321
|
+
*
|
|
322
|
+
* @param {Object} options - The options for creating the `index.css` file.
|
|
323
|
+
* @param {string} [options.buildDir=path.resolve(__dirname, '../styles/css')]
|
|
324
|
+
* - The base directory where the CSS files are located.
|
|
325
|
+
* @param {boolean} options.isThemeVariant - A flag indicating whether the directory is for theme files.
|
|
326
|
+
* @param {string} options.themeVariant - The specific theme variant to be used (e.g., 'dark', 'light').
|
|
327
|
+
*/
|
|
328
|
+
function createIndexCssFile({ buildDir = path.resolve(__dirname, '../styles/css'), isThemeVariant, themeVariant }) {
|
|
329
|
+
const directoryPath = isThemeVariant ? `${buildDir}/themes/${themeVariant}` : `${buildDir}/core`;
|
|
167
330
|
|
|
168
331
|
fs.readdir(directoryPath, (errDir, files) => {
|
|
169
332
|
if (errDir) {
|
|
@@ -173,11 +336,17 @@ function createIndexCssFile({ buildDir = path.resolve(__dirname, '../styles/css'
|
|
|
173
336
|
}
|
|
174
337
|
|
|
175
338
|
const outputCssFiles = files.filter(file => file !== 'index.css');
|
|
176
|
-
// When creating themes, there are typically two files: one for utility classes and one for variables.
|
|
177
|
-
// It's organized them to allow variables be reading first.
|
|
178
|
-
if (isTheme) { outputCssFiles.reverse(); }
|
|
179
339
|
|
|
180
|
-
|
|
340
|
+
// For theme variants, files are ordered with variables first, abstraction variables second,
|
|
341
|
+
// and utility classes last. This ensures that variables are available before other files use them.
|
|
342
|
+
// For the core styles, custom media breakpoints replace utility classes in the order.
|
|
343
|
+
const sortOrder = isThemeVariant
|
|
344
|
+
? [...commonCssFiles, 'utility-classes.css']
|
|
345
|
+
: [...commonCssFiles, 'custom-media-breakpoints.css'];
|
|
346
|
+
|
|
347
|
+
const sortedCssFiles = outputCssFiles.sort((a, b) => sortOrder.indexOf(a) - sortOrder.indexOf(b));
|
|
348
|
+
|
|
349
|
+
const exportStatements = sortedCssFiles.map((file) => `@import "${file}";`);
|
|
181
350
|
|
|
182
351
|
const indexContent = `${exportStatements.join('\n')}\n`;
|
|
183
352
|
|
|
@@ -207,4 +376,5 @@ module.exports = {
|
|
|
207
376
|
getSCSStoCSSMap,
|
|
208
377
|
transformInPath,
|
|
209
378
|
composeBreakpointName,
|
|
379
|
+
processAndUpdateTokens,
|
|
210
380
|
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`<IconButton /> renders with required props 1`] = `
|
|
4
|
-
<button
|
|
5
|
-
aria-label="alternative"
|
|
6
|
-
className="btn-icon btn-icon-primary btn-icon-md"
|
|
7
|
-
onClick={[Function]}
|
|
8
|
-
type="button"
|
|
9
|
-
>
|
|
10
|
-
<span
|
|
11
|
-
className="btn-icon__icon-container"
|
|
12
|
-
>
|
|
13
|
-
<span
|
|
14
|
-
aria-hidden={true}
|
|
15
|
-
className="btn-icon__icon"
|
|
16
|
-
id="Icon1"
|
|
17
|
-
/>
|
|
18
|
-
</span>
|
|
19
|
-
</button>
|
|
20
|
-
`;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"typography": {
|
|
3
|
-
"display": {
|
|
4
|
-
"line-height": {
|
|
5
|
-
"base": { "value": "1", "type": "dimension", "source": "$display-line-height", "description": "Standard line height." },
|
|
6
|
-
"mobile": { "value": "3.5rem", "type": "dimension", "source": "$display-mobile-line-height", "description": "Mobile line height." }
|
|
7
|
-
},
|
|
8
|
-
"1": { "value": "3.75rem", "type": "dimension", "source": "$display1-size", "description": "Font size for heading of level 1." },
|
|
9
|
-
"2": { "value": "4.875rem", "type": "dimension", "source": "$display2-size", "description": "Font size for heading of level 2." },
|
|
10
|
-
"3": { "value": "5.625rem", "type": "dimension", "source": "$display3-size", "description": "Font size for heading of level 3." },
|
|
11
|
-
"4": { "value": "7.5rem", "type": "dimension", "source": "$display4-size", "description": "Font size for heading of level 4." },
|
|
12
|
-
"mobile": { "value": "3.25rem", "type": "dimension", "source": "$display-mobile-size", "description": "Font size for mobile devices." },
|
|
13
|
-
"weight": {
|
|
14
|
-
"1": { "value": "{typography.font.weight.bold}", "type": "fontWeight", "source": "$display1-weight", "description": "Font weight of level 1." },
|
|
15
|
-
"2": { "value": "{typography.font.weight.bold}", "type": "fontWeight", "source": "$display2-weight", "description": "Font weight of level 2." },
|
|
16
|
-
"3": { "value": "{typography.font.weight.bold}", "type": "fontWeight", "source": "$display3-weight", "description": "Font weight of level 3." },
|
|
17
|
-
"4": { "value": "{typography.font.weight.bold}", "type": "fontWeight", "source": "$display4-weight", "description": "Font weight of level 4." }
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
"print-page-size": { "value": "a3", "type": "dimension", "source": "$print-page-size" }
|
|
21
|
-
}
|
|
22
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/src/Button/__snapshots__/{ButtonToolbar.test.jsx.snap → ButtonToolbar.test.tsx.snap}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|