-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(scss): export the theme as SCSS file (#231)
- Loading branch information
Showing
12 changed files
with
73 additions
and
36 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const fs = require('fs'); | ||
const sassGraph = require('sass-graph'); | ||
|
||
const graph = sassGraph.parseFile('./src/components/_index.scss'); | ||
|
||
const root = Object.keys(graph.index)[0]; | ||
|
||
const content = recursiveReadSCSS(root, graph.index[root]); | ||
|
||
fs.writeFileSync('./dist/theme.scss', content); | ||
|
||
function recursiveReadSCSS(branchId, branch) { | ||
if (branch.imports.length === 0) { | ||
return fs.readFileSync(branchId, 'utf8'); | ||
} | ||
const file = fs.readFileSync(branchId, 'utf8'); | ||
const sassFileContent = [] | ||
branch.imports.forEach((branchId) => { | ||
const content = recursiveReadSCSS(branchId, graph.index[branchId]); | ||
sassFileContent.push(content); | ||
}); | ||
// remove imports | ||
const contentWithoutImports = removeImportsFromFile(file) | ||
sassFileContent.push(contentWithoutImports); | ||
return sassFileContent.join('\n'); | ||
} | ||
|
||
|
||
function removeImportsFromFile(fileContent) { | ||
const lines = fileContent.split(/\r\n|\r|\n/g); | ||
|
||
return lines.filter((line) => { | ||
return !line.match(/@import\s/i) | ||
}).join('\n'); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@import '../node_modules/@elastic/eui/src/global_styling/functions/index'; | ||
@import '../node_modules/@elastic/eui/src/global_styling/variables/index'; | ||
@import '../node_modules/@elastic/eui/src/global_styling/mixins/index'; | ||
@import '../node_modules/@elastic/eui/src/components/tool_tip/variables'; | ||
@import '../node_modules/@elastic/eui/src/components/tool_tip/mixins'; |
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 was deleted.
Oops, something went wrong.
This file was deleted.
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
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 |
---|---|---|
@@ -1,11 +1,6 @@ | ||
@import '../node_modules/@elastic/eui/src/themes/eui/eui_colors_dark'; | ||
|
||
// These are Chart variable overwrites used only for this theme. | ||
@import 'style/themes/colors_dark'; | ||
|
||
@import '../node_modules/@elastic/eui/src/global_styling/functions/index'; | ||
@import '../node_modules/@elastic/eui/src/global_styling/variables/index'; | ||
@import '../node_modules/@elastic/eui/src/global_styling/mixins/index'; | ||
@import 'eui_imports'; | ||
|
||
// Components | ||
@import 'components/index'; |
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 |
---|---|---|
@@ -1,11 +1,6 @@ | ||
@import '../node_modules/@elastic/eui/src/themes/eui/eui_colors_light'; | ||
|
||
// This is the default Charts theme. | ||
@import 'style/themes/colors_light'; | ||
|
||
@import '../node_modules/@elastic/eui/src/global_styling/functions/index'; | ||
@import '../node_modules/@elastic/eui/src/global_styling/variables/index'; | ||
@import '../node_modules/@elastic/eui/src/global_styling/mixins/index'; | ||
@import 'eui_imports'; | ||
|
||
// Components | ||
@import 'components/index'; |
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