File tree Expand file tree Collapse file tree
builder-config/platform-web
builder-web-vanilla/export-inline-css-html-file Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ export interface WebAdditionalCssDeclarationConfig {
2+ declarations : CssDeclaration [ ] ;
3+ }
4+
5+ interface CssDeclaration {
6+ key : {
7+ name : string ;
8+ selector : "tag" | "id" | "class" ;
9+ } ;
10+ style : object ;
11+ }
Original file line number Diff line number Diff line change 11import { handle } from "@coli.codes/builder" ;
2- import { buildCssStandard } from "@coli.codes/css" ;
2+ import { buildCssStandard , CSSProperties } from "@coli.codes/css" ;
33import { ReservedKeywordPlatformPresets } from "@coli.codes/naming/reserved" ;
44import {
55 k ,
@@ -41,7 +41,20 @@ ${indenter(body, 2)}
4141</html>` ;
4242} ;
4343
44- export function export_inlined_css_html_file ( widget : JsxWidget ) {
44+ interface CssDeclaration {
45+ key : {
46+ name : string ;
47+ selector : "tag" | "id" | "class" ;
48+ } ;
49+ style : CSSProperties ;
50+ }
51+
52+ export function export_inlined_css_html_file (
53+ widget : JsxWidget ,
54+ config : {
55+ additional_css_declarations ?: CssDeclaration [ ] ;
56+ }
57+ ) {
4558 const componentName = widget . key . name ;
4659 const styledComponentNamer = new ScopedVariableNamer (
4760 widget . key . id ,
@@ -78,6 +91,8 @@ export function export_inlined_css_html_file(widget: JsxWidget) {
7891 } ;
7992 } )
8093 . filter ( ( s ) => s ) ;
94+
95+ // global vanilla default injected style
8196 css_declarations . push ( {
8297 key : {
8398 name : "*" ,
@@ -86,6 +101,11 @@ export function export_inlined_css_html_file(widget: JsxWidget) {
86101 style : k . user_agent_stylesheet_override_default ,
87102 } ) ;
88103
104+ // declare additional styles requested by user
105+ config . additional_css_declarations ?. forEach ( ( d ) => {
106+ css_declarations . push ( d ) ;
107+ } ) ;
108+
89109 const strfied_css = css_declarations
90110 . map ( ( css ) => {
91111 const selectors = {
Original file line number Diff line number Diff line change @@ -255,7 +255,7 @@ export async function designToVanilla({
255255 input . widget ,
256256 vanilla_config
257257 ) ;
258- const res = tovanilla . buildVanillaFile ( vanillawidget ) ;
258+ const res = tovanilla . buildVanillaFile ( vanillawidget , vanilla_config ) ;
259259
260260 // ------------------------------------------------------------------------
261261 // finilize temporary assets
Original file line number Diff line number Diff line change @@ -5,13 +5,18 @@ import { export_inlined_css_html_file } from "@web-builder/vanilla";
55import { JsxWidget } from "@web-builder/core" ;
66
77export function buildVanillaFile (
8- widget : JsxWidget
8+ widget : JsxWidget ,
9+ config : config . VanillaFrameworkConfig
910) : config . VanillaComponentOutput {
1011 if ( ! widget ) {
1112 throw "A valid reflect widget manifest should be passed as an input. none was passed." ;
1213 }
1314
14- const html = export_inlined_css_html_file ( widget ) ;
15+ const html = export_inlined_css_html_file ( widget , {
16+ additional_css_declarations :
17+ config . additional_css_declaration ?. declarations ,
18+ } ) ;
19+
1520 return {
1621 id : widget . key . id ,
1722 name : widget . key . name ,
You can’t perform that action at this time.
0 commit comments