diff options
Diffstat (limited to '')
| -rw-r--r-- | examples/counter/index.html | 11 | ||||
| -rw-r--r-- | examples/counter/style.css | 26 | ||||
| -rw-r--r-- | examples/form/index.html | 11 | ||||
| -rw-r--r-- | examples/form/signup.css | 77 | ||||
| -rw-r--r-- | examples/form/style.css | 40 | ||||
| -rw-r--r-- | examples/syntax-ideas.css | 16 | ||||
| -rw-r--r-- | examples/todo-list/style.css | 33 |
7 files changed, 214 insertions, 0 deletions
diff --git a/examples/counter/index.html b/examples/counter/index.html new file mode 100644 index 0000000..9aa89d2 --- /dev/null +++ b/examples/counter/index.html @@ -0,0 +1,11 @@ +<!doctype html> +<html lang="en"> + <head> + <title>Counter example</title> + <meta charset="UTF-8" /> + <link href="./style.css" rel="stylesheet" /> + </head> + <body> + <script async defer src="../../dist/index.js"></script> + </body> +</html> diff --git a/examples/counter/style.css b/examples/counter/style.css new file mode 100644 index 0000000..b60785f --- /dev/null +++ b/examples/counter/style.css @@ -0,0 +1,26 @@ +body { + --cssx-children: container todo-container; + --cssx-on-load: js(console.log('what have we done?!')); +} + +#container { + --cssx-children: counter btn-increment; + --count: '0'; +} + +#counter { +} +#counter::before { + content: 'Count: ' var(--count); +} + +#btn-increment { + display: inline-block; + padding: 0.5rem 1rem; + border: 1px solid gray; + + --cssx-on-click: update(container, --count, calc(var(--count) + 1)); +} +#btn-increment::after { + content: 'Increment'; +} diff --git a/examples/form/index.html b/examples/form/index.html new file mode 100644 index 0000000..618b21b --- /dev/null +++ b/examples/form/index.html @@ -0,0 +1,11 @@ +<!doctype html> +<html lang="en"> + <head> + <title>Register to this awesome website</title> + <meta charset="UTF-8" /> + <link href="./style.css" rel="stylesheet" /> + </head> + <body> + <script async defer src="../../dist/index.js"></script> + </body> +</html> diff --git a/examples/form/signup.css b/examples/form/signup.css new file mode 100644 index 0000000..1a5f3ff --- /dev/null +++ b/examples/form/signup.css @@ -0,0 +1,77 @@ +#signup-page-content { + border: 1px solid #888; + padding: 1rem; + max-width: 700px; + margin: 1rem auto; + + --cssx-disgustingly-set-innerhtml: "<h1 class= 'form-title'>Sign-<b>Up</b></h1>"; + + --cssx-children: form#form; + --count: '0'; +} + +.form-title { + font-size: 2rem; + padding: 0; + border-bottom: 1px solid gray; + font-weight: normal; + color: gray; +} +.form-title b { + font-weight: bold; + color: black; +} + +#form { + display: block; + + --cssx-on-submit: prevent-default() add-class(form, 'submitting') + request('/examples/') remove-class(form, 'submitting') + add-class(form, 'submitted'); + + --cssx-children: input#input-email input#input-password actions #message; +} +#form.submitted #message::after { + display: block; + content: 'Form submitted successfully'; +} +#form.submitting #submit-btn { + pointer-events: none; + opacity: 0.5; +} + +#form input { + display: block; + width: 100%; + padding: 0.4rem 0.8rem; + margin-top: 1rem; +} + +#input-email { + --cssx-on-mount: set-attr('type', 'email') set-attr('name', 'email') + set-attr('required', 'true') + set-attr('placeholder', 'Email. Eg:- mail@postbox.com'); +} + +#input-password { + --cssx-on-mount: set-attr('type', 'password') set-attr('name', 'password') + set-attr('required', 'true') + set-attr( + 'placeholder', + 'Password. Eg:- password, password1, password2, password123' + ); +} + +#actions { + text-align: right; + padding-top: 1rem; + --cssx-children: button#submit-btn; +} + +#submit-btn { + padding: 0.4rem 0.7rem; + --cssx-on-mount: set-attr('type', 'submit'); +} +#submit-btn::after { + content: 'Sign-Up'; +} diff --git a/examples/form/style.css b/examples/form/style.css new file mode 100644 index 0000000..113ab81 --- /dev/null +++ b/examples/form/style.css @@ -0,0 +1,40 @@ +body { + --cssx-children: button#signup-btn signup-page; +} +body * { + box-sizing: border-box; +} + +#signup-btn { + display: inline-block; + background: #5180e9; + color: #fff; + border: none; + outline: none; + padding: 0.5rem 1rem; + cursor: pointer; + + --cssx-on-mount: set-attr('type', 'button'); + + --cssx-on-click: add-class(signup-page, 'loading') + add-class(signup-btn, 'loading') delay(0.5s) + load-cssx(signup-page-content, './signup.css') + remove-class(signup-page, 'loading') remove-class(signup-btn, 'loading'); +} +#signup-btn::after { + content: 'Register now to start your free trail for $99'; +} +#signup-btn:hover { + opacity: 0.8; +} +#signup-btn.loading { + pointer-events: none; + opacity: 0.4; +} + +#signup-page { + --cssx-children: signup-page-content; +} +#signup-page.loading::after { + content: 'Loading...'; +} diff --git a/examples/syntax-ideas.css b/examples/syntax-ideas.css new file mode 100644 index 0000000..08ed310 --- /dev/null +++ b/examples/syntax-ideas.css @@ -0,0 +1,16 @@ + +body { + --cssx-children: element-1 element-2 element-3; +} + +#element-1 { + --cssx-on-click: js-eval('alert("clicked")'); +} +#element-2 { + --from-variable: "is here"; +} +#element-2::after { content: "My content: " var(--from-variable); } + +#element-3 { + --cssx-on-click: js-eval('alert("clicked")'); +} diff --git a/examples/todo-list/style.css b/examples/todo-list/style.css new file mode 100644 index 0000000..7533210 --- /dev/null +++ b/examples/todo-list/style.css @@ -0,0 +1,33 @@ +body { + --cssx-children: todo-container; +} + +#todo-container { + --cssx-children: todo-input todo-list; + --todo-list: list(); +} + +#todo-input { + --cssx-children: input-field submit-btn; +} + +#submit-btn { + --cssx-on-click: update( + todo-container, + --todo-list, + list-append(var(--todo-list), tuple(get-attr(input-field, value), false)) + ); +} +#submit-btn::after { + content: 'Submit'; +} + +#todo-list { + --cssx-iter-children: iter(var(--todo-list), --todo-item, todo-item); +} + +#todo-item { +} +#todo-item::after { + content: var(--todo-item); +} |
