-
Notifications
You must be signed in to change notification settings - Fork 673
Fluent-next: delivery artifacts to distribution and support accents #34767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feature/26_2_new_fluent_theme_with_design_tokens
Are you sure you want to change the base?
Changes from all commits
bb6fbac
eed52d8
c393cc3
cd15d28
10691f7
8fadfda
c8efba0
1709c73
f364bbe
54dfba0
b6c79cb
5ab457f
631bf3c
28439da
e64c4b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import * as fs from 'fs'; | ||
| import * as path from 'path'; | ||
|
|
||
| const scssRoot = path.resolve(__dirname, '..', 'scss'); | ||
| const designedAccentsDir = path.join(scssRoot, '_design-system', 'fluent', 'accents'); | ||
| const customAccentPath = path.join(scssRoot, 'widgets', 'fluent-next', 'accents', 'custom.css'); | ||
|
|
||
| const readSteps = (filePath: string): string[] => { | ||
| const content = fs.readFileSync(filePath, 'utf8'); | ||
| return [...content.matchAll(/--dxds-primary-(\d+)\s*:/g)].map((match) => match[1]); | ||
| }; | ||
|
|
||
| const readPrimaryDeclarations = (filePath: string): string[] => | ||
| fs.readFileSync(filePath, 'utf8').match(/--dxds-primary-\d+\s*:[^;]+;/g) ?? []; | ||
|
|
||
| const readStepColor = (filePath: string, step: string): string => { | ||
| const content = fs.readFileSync(filePath, 'utf8'); | ||
| const match = new RegExp(`--dxds-primary-${step}\\s*:\\s*(#[0-9a-f]{3,8})\\b`, 'i').exec(content); | ||
|
|
||
| if (!match) { | ||
| throw new Error(`No literal color for step ${step} in ${filePath}`); | ||
| } | ||
|
|
||
| return match[1]; | ||
| }; | ||
|
|
||
| const defaultPalettePath = path.join(designedAccentsDir, 'blue.scss'); | ||
|
|
||
| const designedPalettes = fs.readdirSync(designedAccentsDir) | ||
| .filter((name) => name.endsWith('.scss')) | ||
| .map((name) => ({ name, steps: readSteps(path.join(designedAccentsDir, name)) })); | ||
|
|
||
| describe('accents/custom.css', () => { | ||
| it('covers exactly the steps the designed palettes declare', () => { | ||
| const customAccentSteps = readSteps(customAccentPath); | ||
|
|
||
| expect(designedPalettes.length).toBeGreaterThan(0); | ||
| designedPalettes.forEach(({ name, steps }) => { | ||
| expect([name, customAccentSteps]).toEqual([name, steps]); | ||
| }); | ||
| }); | ||
|
|
||
| it('derives every step from --dx-accent-color-source instead of a literal color', () => { | ||
| const declarations = readPrimaryDeclarations(customAccentPath); | ||
|
|
||
| expect(declarations).toHaveLength(readSteps(defaultPalettePath).length); | ||
| declarations.forEach((declaration) => { | ||
| expect(declaration).toContain('oklch(from var(--dx-accent-color-source)'); | ||
| expect(declaration).not.toMatch(/#[0-9a-f]{3,8}\b/i); | ||
| }); | ||
| }); | ||
|
|
||
| it('resolves --dx-accent-color-source to the default blue accent when --dx-accent-color is unset', () => { | ||
| const defaultAccentColor = readStepColor(defaultPalettePath, '100'); | ||
|
|
||
| expect(fs.readFileSync(customAccentPath, 'utf8')) | ||
| .toContain(`--dx-accent-color-source: var(--dx-accent-color, ${defaultAccentColor});`); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1226,13 +1226,24 @@ | |
| "executor": "devextreme-nx-infra-plugin:scss-assemble", | ||
| "options": { | ||
| "scssPackagePath": "../devextreme-scss", | ||
| "outputDir": "./artifacts/npm/devextreme/scss" | ||
| "outputDir": "./artifacts/npm/devextreme/scss", | ||
| "exclude": [ | ||
| "widgets/fluent-next/**", | ||
| "_design-system/**", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [HIGH] This exclude keeps the token-derived sources out of devextreme/devextreme-internal, but the same sources still ship through a second channel: themebuilder's generate-metadata walks the whole devextreme-scss/scss tree into src/data/scss, and its only filter is filePath.includes('fluent-next') - _design-system/** doesn't match it. all:build: devextreme-themebuilder-26.2.0.tgz contains 19 data/scss/_design-system/** files (all 11 palettes, semantic tiers, and variables The fluent-next bundles are only saved by the name-substring accident, so the collector filter needs extending - ideally sharing one exclude list with this target. Related hygiene: saveScssFiles never cleans the destination, so stale files from earlier checkouts ship too when packing from a dev machine (my local tgz also had 8 leftover widgets/dxdsfluent/ files from before the rename)** |
||
| "bundles/dx.fluent-next.*.scss" | ||
| ] | ||
| }, | ||
| "configurations": { | ||
| "internal": { | ||
| "outputDir": "./artifacts/npm/devextreme-internal/scss" | ||
| } | ||
| }, | ||
| "dependsOn": [ | ||
| { | ||
| "projects": ["devextreme-scss"], | ||
| "target": "build:tokens" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The dependency generates _design-system, which this very target then excludes from the copy - I assume it's for input-hash determinism? A short comment would help. Meanwhile scss/bundles/*.scss, which IS shipped (.npmignore un-ignores it), isn't guaranteed by any dependency: a standalone nx run devextreme:build:npm:scss on a fresh clone silently packs without bundles. Pre-existing, but since we're adding dependencies here - worth considering. |
||
| } | ||
| ], | ||
| "inputs": [ | ||
| "{workspaceRoot}/packages/devextreme-scss/scss/**/*", | ||
| "{workspaceRoot}/packages/devextreme-scss/fonts/**/*", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| export interface ScssAssembleExecutorSchema { | ||
| scssPackagePath: string; | ||
| outputDir: string; | ||
| exclude?: string[]; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| export { default } from './scss-build.impl'; | ||
| export { findMissingThemeCss } from './scss-build.impl'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
configurations.internal inherits the same exclude, so devextreme-internal also ships without the fluent-next sources. Intended? If internal consumers should keep them, the internal configuration needs exclude: []; if not, fine - just confirming it's a decision, not an accident.