@openedx/paragon 23.7.0 → 23.9.0

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.
@@ -96,6 +96,11 @@ const COMMANDS = {
96
96
  Can be provided as a comma-separated list (e.g., "light,dark") or multiple arguments (e.g., "-t light -t dark").`,
97
97
  defaultValue: 'light',
98
98
  },
99
+ {
100
+ name: '--exclude-core',
101
+ description: 'Exclude core from the token build.',
102
+ defaultValue: false,
103
+ },
99
104
  {
100
105
  name: '-v, --verbose',
101
106
  description: 'Enable verbose logging.',
@@ -142,6 +147,11 @@ const COMMANDS = {
142
147
  description: 'Path to the theme\'s core SCSS file, defaults to Paragon\'s core.scss.',
143
148
  defaultValue: 'styles/scss/core/core.scss',
144
149
  },
150
+ {
151
+ name: '--excludeCore',
152
+ description: 'Exclude core from the SCSS build.',
153
+ defaultValue: false,
154
+ },
145
155
  {
146
156
  name: '--themesPath',
147
157
  description: `Path to the directory that contains themes' files. Expects directory to have following structure:
@@ -143,4 +143,18 @@ describe('buildScssCommand', () => {
143
143
  expect.any(Object),
144
144
  );
145
145
  });
146
+
147
+ it('should exclude core properly', () => {
148
+ buildScssCommand(['--excludeCore']);
149
+
150
+ expect(sass.compile).not.toHaveBeenCalledWith(
151
+ expect.stringContaining('core.scss'),
152
+ expect.any(Object),
153
+ );
154
+
155
+ expect(fs.readdirSync).toHaveBeenCalledWith(
156
+ expect.stringContaining('themes'),
157
+ expect.objectContaining({ withFileTypes: true }),
158
+ );
159
+ });
146
160
  });
@@ -63,6 +63,25 @@ describe('buildTokensCommand', () => {
63
63
  }));
64
64
  });
65
65
 
66
+ it('should handle the exclude-core flag', async () => {
67
+ await buildTokensCommand(['--exclude-core']);
68
+
69
+ // only light theme, not core
70
+ expect(StyleDictionary).toHaveBeenCalledTimes(1);
71
+ const callArgs = StyleDictionary.mock.calls[0][0];
72
+ for (const file of callArgs.platforms.css.files) {
73
+ expect(file.destination).toContain('themes/light');
74
+ }
75
+
76
+ // Verify only light theme index files are created
77
+ expect(createIndexCssFile).toHaveBeenCalledTimes(1);
78
+ expect(createIndexCssFile).toHaveBeenCalledWith(expect.objectContaining({
79
+ buildDir: defaultBuildDir,
80
+ isThemeVariant: true,
81
+ themeVariant: 'light',
82
+ }));
83
+ });
84
+
66
85
  it('should use custom build path', async () => {
67
86
  const customBuildDir = './custom-build/';
68
87
  await buildTokensCommand(['--build-dir', customBuildDir]);
package/lib/build-scss.js CHANGED
@@ -154,6 +154,7 @@ const compileAndWriteStyleSheets = ({
154
154
  function buildScssCommand(commandArgs) {
155
155
  const defaultArgs = {
156
156
  corePath: path.resolve(process.cwd(), 'styles/scss/core/core.scss'),
157
+ excludeCore: false,
157
158
  themesPath: path.resolve(process.cwd(), 'styles/css/themes'),
158
159
  outDir: './dist',
159
160
  defaultThemeVariants: 'light',
@@ -161,17 +162,20 @@ function buildScssCommand(commandArgs) {
161
162
 
162
163
  const {
163
164
  corePath,
165
+ excludeCore,
164
166
  themesPath,
165
167
  outDir,
166
168
  defaultThemeVariants,
167
- } = minimist(commandArgs, { default: defaultArgs });
169
+ } = minimist(commandArgs, { default: defaultArgs, boolean: ['excludeCore'] });
168
170
 
169
171
  // Core CSS
170
- compileAndWriteStyleSheets({
171
- name: 'core',
172
- stylesPath: corePath,
173
- outDir,
174
- });
172
+ if (!excludeCore) {
173
+ compileAndWriteStyleSheets({
174
+ name: 'core',
175
+ stylesPath: corePath,
176
+ outDir,
177
+ });
178
+ }
175
179
 
176
180
  // Theme Variants CSS
177
181
  fs.readdirSync(themesPath, { withFileTypes: true })
@@ -22,6 +22,7 @@ async function buildTokensCommand(commandArgs) {
22
22
  'build-dir': './build/',
23
23
  'source-tokens-only': false,
24
24
  'output-references': true,
25
+ 'exclude-core': false,
25
26
  verbose: false,
26
27
  };
27
28
 
@@ -38,12 +39,13 @@ async function buildTokensCommand(commandArgs) {
38
39
  'output-references': outputReferences,
39
40
  themes,
40
41
  verbose,
42
+ 'exclude-core': excludeCore,
41
43
  } = minimist(
42
44
  commandArgs,
43
45
  {
44
46
  alias,
45
47
  default: defaultParams,
46
- boolean: ['source-tokens-only', 'output-references', 'verbose'],
48
+ boolean: ['source-tokens-only', 'output-references', 'exclude-core', 'verbose'],
47
49
  },
48
50
  );
49
51
 
@@ -144,17 +146,19 @@ async function buildTokensCommand(commandArgs) {
144
146
  },
145
147
  });
146
148
 
147
- // Create list of style-dictionary configurations to build (core + theme variants)
148
- const configs = [
149
- { config: coreConfig },
150
- ...parsedThemes.map((themeVariant) => {
151
- const config = getStyleDictionaryConfig(themeVariant);
152
- return {
153
- config,
154
- themeVariant,
155
- };
156
- }),
157
- ];
149
+ // Create list of style-dictionary configurations to build
150
+ const configs = [];
151
+
152
+ // Add core if it isn't excluded
153
+ if (!excludeCore) {
154
+ configs.push({ config: coreConfig });
155
+ }
156
+
157
+ // Add theme variants
158
+ for (const themeVariant of parsedThemes) {
159
+ const config = getStyleDictionaryConfig(themeVariant);
160
+ configs.push({ config, themeVariant });
161
+ }
158
162
 
159
163
  // Build tokens for each configuration
160
164
  await Promise.all(configs.map(async ({ config, themeVariant }) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openedx/paragon",
3
- "version": "23.7.0",
3
+ "version": "23.9.0",
4
4
  "description": "Accessible, responsive UI component library based on Bootstrap.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",