This repository has been archived by the owner on Oct 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add --for flag destructuration
- Loading branch information
Showing
21 changed files
with
482 additions
and
354 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import type { Bundle, Component, StyleBundle } from '../../.d.ts'; | ||
import { Utils } from '../Utils.ts'; | ||
|
||
// TODO comments here | ||
export default abstract class StyleDocument extends Utils { | ||
static renderElement(styleBundle: StyleBundle, bundle: Bundle, component: Component): string { | ||
let result = ''; | ||
const entries = Array.from(styleBundle.mapDocument.entries()) | ||
entries.forEach(([selector, parent]: [string, any]) => { | ||
result += `${selector} { `; | ||
const { childs } = parent; | ||
childs.forEach((item: any) => { | ||
const propsEntries = Object.entries(item.properties.props); | ||
const props = propsEntries.length ? propsEntries.map(([name, value]) => `${name}: ${value};`).join('') : null; | ||
if (props) { | ||
result += `${item.selector} { ${props} } `; | ||
} | ||
}); | ||
result += `} `; | ||
}); | ||
return result; | ||
} | ||
static saveElement(styleBundle: StyleBundle, bundle: Bundle, component: Component, opts: { item: any }): void { | ||
const { item } = opts; | ||
if (!styleBundle.mapDocument.has(item.isDocument)) styleBundle.mapDocument.set(item.isDocument, { childs: [item] }); | ||
else { | ||
const doc = styleBundle.mapDocument.get(item.isDocument); | ||
doc.childs.push(item); | ||
} | ||
} | ||
} |
Oops, something went wrong.