summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/index.scss2
-rw-r--r--src/layouts/_form.scss46
-rw-r--r--src/objects/_checkbox.scss1
-rw-r--r--src/objects/_radio.scss1
-rw-r--r--src/objects/_switch.scss1
-rw-r--r--tpl/index.pug34
-rw-r--r--tpl/objects/form.pug13
-rw-r--r--yarn.lock2
8 files changed, 99 insertions, 1 deletions
diff --git a/src/index.scss b/src/index.scss
index c945321..9f7f85e 100644
--- a/src/index.scss
+++ b/src/index.scss
@@ -16,6 +16,8 @@
16@import 'objects/checkbox'; 16@import 'objects/checkbox';
17@import 'objects/switch'; 17@import 'objects/switch';
18 18
19@import 'layouts/form';
20
19:root { 21:root {
20 @include iro.props-assign; 22 @include iro.props-assign;
21 @include iro.props-assign('light-palette'); 23 @include iro.props-assign('light-palette');
diff --git a/src/layouts/_form.scss b/src/layouts/_form.scss
new file mode 100644
index 0000000..9e6520f
--- /dev/null
+++ b/src/layouts/_form.scss
@@ -0,0 +1,46 @@
1@use 'iro-sass/src/index' as iro;
2
3@include iro.props-namespace('form') {
4 @include iro.props-store((
5 --dims: (
6 --item-spacing-y: iro.props-get(--dims --spacing --y --md, $global: true),
7 --label-spacing-x: iro.props-get(--dims --spacing --x --md, $global: true),
8 --hint-font-size: iro.props-get(--dims --font-size --sm, $global: true),
9 ),
10 ));
11
12 @include iro.bem-layout(iro.props-namespace()) {
13 display: grid;
14 grid-template-columns: auto 1fr;
15 grid-template-rows: auto;
16 align-items: baseline;
17 gap: iro.props-get(--dims --item-spacing-y) iro.props-get(--dims --label-spacing-x);
18
19 @include iro.bem-elem('item') {
20 display: contents;
21 }
22
23 @include iro.bem-elem('item-label') {
24 grid-column: 1;
25 }
26
27 @include iro.bem-elem('item-content') {
28 grid-column: 2;
29 }
30
31 @include iro.bem-modifier('labels-right') {
32 @include iro.bem-elem('item-label') {
33 text-align: right;
34 }
35 }
36
37 @include iro.bem-modifier('labels-above') {
38 display: flex;
39 flex-direction: column;
40
41 @include iro.bem-elem('item') {
42 display: block;
43 }
44 }
45 }
46}
diff --git a/src/objects/_checkbox.scss b/src/objects/_checkbox.scss
index 606b717..587321b 100644
--- a/src/objects/_checkbox.scss
+++ b/src/objects/_checkbox.scss
@@ -105,6 +105,7 @@
105 } 105 }
106 106
107 @include iro.bem-elem('label') { 107 @include iro.bem-elem('label') {
108 align-self: baseline;
108 margin-left: iro.props-get(--dims --label-gap); 109 margin-left: iro.props-get(--dims --label-gap);
109 } 110 }
110 111
diff --git a/src/objects/_radio.scss b/src/objects/_radio.scss
index bb32cdf..213b7c4 100644
--- a/src/objects/_radio.scss
+++ b/src/objects/_radio.scss
@@ -74,6 +74,7 @@
74 } 74 }
75 75
76 @include iro.bem-elem('label') { 76 @include iro.bem-elem('label') {
77 align-self: baseline;
77 margin-left: iro.props-get(--dims --label-gap); 78 margin-left: iro.props-get(--dims --label-gap);
78 } 79 }
79 80
diff --git a/src/objects/_switch.scss b/src/objects/_switch.scss
index 25125da..7d5d16d 100644
--- a/src/objects/_switch.scss
+++ b/src/objects/_switch.scss
@@ -80,6 +80,7 @@
80 } 80 }
81 81
82 @include iro.bem-elem('label') { 82 @include iro.bem-elem('label') {
83 align-self: baseline;
83 margin-left: iro.props-get(--dims --label-gap); 84 margin-left: iro.props-get(--dims --label-gap);
84 } 85 }
85 86
diff --git a/tpl/index.pug b/tpl/index.pug
index 8595be0..2ebb625 100644
--- a/tpl/index.pug
+++ b/tpl/index.pug
@@ -11,6 +11,7 @@ include objects/field-label.pug
11include objects/radio.pug 11include objects/radio.pug
12include objects/checkbox.pug 12include objects/checkbox.pug
13include objects/switch.pug 13include objects/switch.pug
14include objects/form.pug
14 15
15mixin box 16mixin box
16 +container(padX=true padY=true inPage=true theme="raised") 17 +container(padX=true padY=true inPage=true theme="raised")
@@ -268,3 +269,36 @@ html
268 +switch(accent=true disabled=true)= 'Cats' 269 +switch(accent=true disabled=true)= 'Cats'
269 +switch(accent=true disabled=true)= 'Dogs' 270 +switch(accent=true disabled=true)= 'Dogs'
270 +switch(accent=true checked=true disabled=true)= 'Foxes' 271 +switch(accent=true checked=true disabled=true)= 'Foxes'
272
273 //-----------------------------------------
274
275 +h1-heading(level='xl')= 'Form'
276 +rule(level='medium')
277
278 +box
279 +form
280 +form-item('Username')
281 +text-field(placeholder='Example: Volpeon')
282
283 +form-item('Password', 'At least 6 characters, all characters allowed')
284 +text-field(placeholder='Example: hunter2', type='password')
285
286 +form-item('Bio')
287 +text-field(placeholder='Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam...')
288
289 +form-item('Favorite animal')
290 +radio(name="form-demo-1" checked=true)= 'Foxes'
291 +radio(name="form-demo-1")= 'Other'
292
293 +form-item('Notification settings')
294 +switch= 'In-app notifications'
295 br
296 +switch= 'Desktop notifications'
297 br
298 +switch= 'Email notifications'
299
300 +form-item('')
301 +checkbox= 'I\'ve read and accept the terms and conditions'
302
303 +form-item('')
304 +a-button(variant='primary')= 'Register'
diff --git a/tpl/objects/form.pug b/tpl/objects/form.pug
new file mode 100644
index 0000000..496ed48
--- /dev/null
+++ b/tpl/objects/form.pug
@@ -0,0 +1,13 @@
1include field-label.pug
2
3mixin form
4 form(class={
5 'l-form': true,
6 'l-form--labels-right': attributes.labelsAlign === 'right',
7 'l-form--labels-above': attributes.labelsAlign === 'above'
8 })
9 block
10
11mixin form-item(label, hint=null)
12 +field-label(label, hint)(class='l-form__item' labelClass='l-form__item-label' contentClass='l-form__item-content')
13 block
diff --git a/yarn.lock b/yarn.lock
index b5d2cce..9653150 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1260,7 +1260,7 @@ internal-slot@^1.0.3:
1260 1260
1261"iro-sass@git+https://git.vulpes.one/git/iro-sass.git": 1261"iro-sass@git+https://git.vulpes.one/git/iro-sass.git":
1262 version "1.0.2" 1262 version "1.0.2"
1263 resolved "git+https://git.vulpes.one/git/iro-sass.git#bab633f8a6faf4be7cd4ebd16b1b5c270d95320a" 1263 resolved "git+https://git.vulpes.one/git/iro-sass.git#9f1653f2ab64ef8cb4c545416da4241baa481557"
1264 1264
1265is-arrayish@^0.2.1: 1265is-arrayish@^0.2.1:
1266 version "0.2.1" 1266 version "0.2.1"