-
-
Notifications
You must be signed in to change notification settings - Fork 768
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
1,134 additions
and
1,121 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// | ||
// This script bakes and copies themes, then generates a corresponding Lit stylesheet in dist/themes | ||
// | ||
import chalk from 'chalk'; | ||
import commandLineArgs from 'command-line-args'; | ||
import fs from 'fs'; | ||
import { mkdirSync } from 'fs'; | ||
import { globbySync } from 'globby'; | ||
import path from 'path'; | ||
import prettier from 'prettier'; | ||
import stripComments from 'strip-css-comments'; | ||
|
||
const { outdir } = commandLineArgs({ name: 'outdir', type: String }); | ||
const files = globbySync('./src/themes/**/[!_]*.css'); | ||
const filesToEmbed = globbySync('./src/themes/**/_*.css'); | ||
const themesDir = path.join(outdir, 'themes'); | ||
const embeds = {}; | ||
|
||
console.log('Generating stylesheets'); | ||
|
||
mkdirSync(themesDir, { recursive: true }); | ||
|
||
try { | ||
// Gather an object containing the source of all files named "_filename.css" so we can embed them later | ||
filesToEmbed.forEach(file => { | ||
embeds[path.basename(file)] = fs.readFileSync(file, 'utf8'); | ||
}); | ||
|
||
// Loop through each theme file, copying the .css and generating a .js version for Lit users | ||
files.forEach(file => { | ||
let source = fs.readFileSync(file, 'utf8'); | ||
|
||
// If the source has "/* _filename.css */" in it, replace it with the embedded styles | ||
Object.keys(embeds).forEach(key => { | ||
source = source.replace(`/* ${key} */`, embeds[key]); | ||
}); | ||
|
||
const css = prettier.format(stripComments(source), { | ||
parser: 'css' | ||
}); | ||
|
||
let js = prettier.format( | ||
` | ||
import { css } from 'lit'; | ||
export default css\` | ||
${css} | ||
\`; | ||
`, | ||
{ parser: 'babel-ts' } | ||
); | ||
|
||
const cssFile = path.join(themesDir, path.basename(file)); | ||
const jsFile = path.join(themesDir, path.basename(file).replace('.css', '.styles.js')); | ||
|
||
fs.writeFileSync(cssFile, css, 'utf8'); | ||
fs.writeFileSync(jsFile, js, 'utf8'); | ||
}); | ||
} catch (err) { | ||
console.error(chalk.red('Error generating stylesheets!')); | ||
console.error(err); | ||
} |
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 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,25 @@ | ||
/* | ||
* This file contains utility classes that can't be contained in a component and must be applied to the light DOM. None | ||
* of the rules in this stylesheet should target component tags or HTML tags, and all classes *must* start with ".sl-" | ||
* to reduce the possibility of collisions. | ||
*/ | ||
|
||
.sl-scroll-lock { | ||
overflow: hidden !important; | ||
} | ||
|
||
.sl-toast-stack { | ||
position: fixed; | ||
top: 0; | ||
right: 0; | ||
z-index: var(--sl-z-index-toast); | ||
width: 28rem; | ||
max-width: 100%; | ||
max-height: 100%; | ||
overflow: auto; | ||
} | ||
|
||
.sl-toast-stack sl-alert { | ||
--box-shadow: var(--sl-shadow-large); | ||
margin: var(--sl-spacing-medium); | ||
} |
Oops, something went wrong.