diff --git a/examples/example.html b/examples/example.html deleted file mode 100644 index 93a1e8b..0000000 --- a/examples/example.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - Dreamland examples - - - - - - - - - - diff --git a/examples/index.css b/examples/index.css deleted file mode 100644 index c45dcef..0000000 --- a/examples/index.css +++ /dev/null @@ -1,21 +0,0 @@ -html { - padding: 0; - margin: 0; - width: 100vw; - height: 100vh; -} -body { - background-color: #191724; -} - -.box { - background-color: #1f1d2e; - border-radius: 25px; - padding: 2em; -} - -p, -h1 { - font-family: 'serif'; - color: #e0def4; -} diff --git a/examples/index.tsx b/examples/index.tsx deleted file mode 100644 index b4c1bd3..0000000 --- a/examples/index.tsx +++ /dev/null @@ -1,136 +0,0 @@ -function Counter() { - this.css = css` - display: flex; - justify-content: center; - align-items: center; - flex-direction: column; - - button { - border-radius: 5px; - border: none; - outline: none; - width: 10em; - height: 5em; - background-color: #f6c177; - } - - p { - font-size: 20px; - } - ` - - this.counter ??= 0 - - return ( -
-

Counter

-

Value: {use(this.counter)}

- -

- is {use(this.counter)} odd?{' '} - {use(this.counter, (p) => p % 2 == 1)} -

-
- ) -} -// -// function ToDoList() { -// let css = styled.new` -// self { -// color: #e0def4; -// display:flex; -// flex-direction:column; -// } -// -// .todoitem { -// display:flex; -// } -// ` -// -// this.tasks = []; -// this.text = "Enter a task here..."; -// -// let addTask = () => { -// if (!this.text) return; -// this.tasks = [...this.tasks, this.text]; -// this.text = ""; -// }; -// -// return ( -//
-//
-// addTask()} /> -// -//
-//
-//
-// {task} -// -//
-// } /> -//
-// ) -// } -// -// -// function Index() { -// let css = styled.new` -// h1 { -// font-size: 40px; -// text-align:center; -// } -// p { -// text-align:center; -// font-size:15px; -// } -// div { -// /* margin-bottom:3em; */ -// } -// examples { -// display: flex; -// justify-content: center; -// flex-direction: column; -// } -// `; -// -// this.c = 5; -// -// this.counterobj; -// -// return ( -//
-// -// {/*
*/} -// {/*

Dreamland Examples

*/} -// {/*

Some examples of dreamland.js components. Code is in examples/

*/} -// {/*
*/} -// {/* */} -// {/* */} -// {/* */} -// {/* */} -// {/* stuff: {use(this.counterobj.counter)} */} -// {/* */} -//
-// ); -// } - -window.addEventListener('load', () => { - document.body.appendChild() -}) - -let a = stateful({ - b: stateful({ c: stateful({ d: 0 }) }), - array: [ - [1, 2, 3], - [4, 5, 6], - [7, 8, 9], - ], -}) as any -let r = use(a.array[a.b.c.d][a.b.c.d]) - -handle(r, (v) => { - console.log(v) -}) diff --git a/src/css.js b/src/css.js index a8b6fb0..f56787f 100644 --- a/src/css.js +++ b/src/css.js @@ -23,23 +23,21 @@ export function css(strings, ...values) { let selfstr = '' // compat layer for older browsers. when css nesting stablizes this can be removed - for (; ;) { + for (;;) { let [first, ...rest] = str.split('\n') - if (first.trim().endsWith('{')) break; + if (first.trim().endsWith('{')) break selfstr += first + '\n' str = rest.join('\n') } styleElement.textContent = str - for (const rule of styleElement.sheet.cssRules) { rule.selectorText = `.${uid} ${rule.selectorText}` newstr += rule.cssText + '\n' } styleElement.textContent = `.${uid} {${selfstr}}` + '\n' + newstr - console.log(styleElement.textContent) cssmap[str] = uid return uid