-
Notifications
You must be signed in to change notification settings - Fork 600
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
ThemeBuilder: Rework use customer variables #25383
Merged
Merged
Changes from 7 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d8b8aaa
Support set only changed variables
OlegKipchatov 51fa4d8
Update sass-embedded
OlegKipchatov 31691a3
Fix tests
OlegKipchatov 76a5029
Set 100% coverage
OlegKipchatov 47b3d1c
Use dictionary
OlegKipchatov 80dc9ee
Remove obsolete code
OlegKipchatov 19205b7
Revert test
OlegKipchatov dea7427
Fix spelling
OlegKipchatov a18f6e3
Merge remote-tracking branch 'origin/23_2' into 23_2
OlegKipchatov 9f7b9be
Update package-lock
OlegKipchatov 0be08eb
Rename 'override' to 'overriden'
OlegKipchatov 2d9c462
Rename 'overriden' to 'overridden'
OlegKipchatov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,11 @@ export default class MetadataGenerator { | |
return metaItems; | ||
} | ||
|
||
static getOverrideVariables(metaItems: MetaItem[]): string { | ||
const result = metaItems.map((item) => `${item.Key}: getCustomVar(("${item.Key}")) !default;`).join('\n'); | ||
return result; | ||
} | ||
|
||
static getMapFromMeta(metaItems: MetaItem[]): string { | ||
const result = metaItems.map((item) => `"${item.Key}": ${item.Key},\n`).join(''); | ||
return `(\n${result})`; | ||
|
@@ -64,22 +69,10 @@ export default class MetadataGenerator { | |
return fileName.includes('bundles'); | ||
} | ||
|
||
static getMainColorsFileTheme(fileName: string): string { | ||
const match = /widgets[/\\](material|generic)[/\\]_colors.scss/.exec(fileName); | ||
|
||
if (match === null) return null; | ||
|
||
return match[1]; | ||
} | ||
|
||
static getBundleContent(content: string): string { | ||
return content.replace(/(..\/widgets\/(material|generic))"/, '$1/tb_index"'); | ||
} | ||
|
||
static getMainColorsFileContent(content: string, theme: string): string { | ||
return content.replace(/\.\/variables/g, `tb_${theme}`); | ||
} | ||
|
||
clean(): void { | ||
this.metadata = { | ||
generic: [], | ||
|
@@ -105,14 +98,8 @@ export default class MetadataGenerator { | |
} | ||
|
||
let modifiedContent = content; | ||
const mainFileTheme = MetadataGenerator.getMainColorsFileTheme(filePath); | ||
|
||
if (mainFileTheme) { | ||
modifiedContent = MetadataGenerator.getMainColorsFileContent(content, mainFileTheme); | ||
} | ||
|
||
const metaItems = MetadataGenerator.getMetaItems(content); | ||
|
||
if (!metaItems.length) { | ||
return modifiedContent; | ||
} | ||
|
@@ -121,8 +108,9 @@ export default class MetadataGenerator { | |
this.fillMetaData(item, filePath); | ||
}); | ||
|
||
const overeideVariables = MetadataGenerator.getOverrideVariables(metaItems); | ||
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. Consolidate:
|
||
const collector = `$never-used: collector(${MetadataGenerator.getMapFromMeta(metaItems)});\n`; | ||
modifiedContent += collector; | ||
modifiedContent = overeideVariables + '\n\n' + modifiedContent + collector; | ||
|
||
return modifiedContent; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/devextreme-themebuilder/tests/data/scss/widgets/generic/_colors.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
packages/devextreme-themebuilder/tests/data/scss/widgets/generic/accordion/_colors.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Consolidate: