summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVolpeon <git@volpeon.ink>2024-11-17 15:51:24 +0100
committerVolpeon <git@volpeon.ink>2024-11-17 15:51:24 +0100
commit4ef7ba48a68980c126b89bf5ba5a9ddac804f88f (patch)
treed0351997b3823d13c0cc94e717420dedecd6d65d
parentFix heading color (diff)
downloadiro-design-4ef7ba48a68980c126b89bf5ba5a9ddac804f88f.tar.gz
iro-design-4ef7ba48a68980c126b89bf5ba5a9ddac804f88f.tar.bz2
iro-design-4ef7ba48a68980c126b89bf5ba5a9ddac804f88f.zip
Add navbar
-rw-r--r--src/_iro-design.scss1
-rw-r--r--src/objects/_action-button.vars.scss8
-rw-r--r--src/objects/_navbar.scss165
-rw-r--r--src/objects/_navbar.vars.scss83
-rw-r--r--src_demo/index.scss1
-rw-r--r--tpl/index.pug3
-rw-r--r--tpl/objects/navbar.pug30
-rw-r--r--tpl/views/navbar.pug13
8 files changed, 300 insertions, 4 deletions
diff --git a/src/_iro-design.scss b/src/_iro-design.scss
index ac07846..6088344 100644
--- a/src/_iro-design.scss
+++ b/src/_iro-design.scss
@@ -56,6 +56,7 @@ $breakpoints: (
56@forward 'objects/icon' as o-icon--*; 56@forward 'objects/icon' as o-icon--*;
57@forward 'objects/lightbox' as o-lightbox--*; 57@forward 'objects/lightbox' as o-lightbox--*;
58@forward 'objects/menu' as o-menu--*; 58@forward 'objects/menu' as o-menu--*;
59@forward 'objects/navbar' as o-navbar--*;
59@forward 'objects/palette' as o-palette--*; 60@forward 'objects/palette' as o-palette--*;
60@forward 'objects/popover' as o-popover--*; 61@forward 'objects/popover' as o-popover--*;
61@forward 'objects/radio' as o-radio--*; 62@forward 'objects/radio' as o-radio--*;
diff --git a/src/objects/_action-button.vars.scss b/src/objects/_action-button.vars.scss
index 9de985a..8c3d510 100644
--- a/src/objects/_action-button.vars.scss
+++ b/src/objects/_action-button.vars.scss
@@ -5,7 +5,7 @@
5 5
6$line-height: props.def(--o-action-button--line-height, 1.4) !default; 6$line-height: props.def(--o-action-button--line-height, 1.4) !default;
7$pad-i: props.def(--o-action-button--pad-i, props.get(core.$size--150)) !default; 7$pad-i: props.def(--o-action-button--pad-i, props.get(core.$size--150)) !default;
8$pad-i-label: props.def(--o-button--pad-i-label, props.get(core.$size--50)) !default; 8$pad-i-label: props.def(--o-action-button--pad-i-label, props.get(core.$size--50)) !default;
9$pad-i-pill: props.def(--o-action-button--pad-i-pill, props.get(core.$size--200)) !default; 9$pad-i-pill: props.def(--o-action-button--pad-i-pill, props.get(core.$size--200)) !default;
10$pad-b: props.def(--o-action-button--pad-b, props.get(core.$size--85)) !default; 10$pad-b: props.def(--o-action-button--pad-b, props.get(core.$size--85)) !default;
11$border-width: props.def(--o-action-button--border-width, props.get(core.$border-width--thin)) !default; 11$border-width: props.def(--o-action-button--border-width, props.get(core.$border-width--thin)) !default;
@@ -13,19 +13,19 @@ $rounding: props.def(--o-action-button--rounding, props.get(core.$rounding))
13$font-size: props.def(--o-action-button--font-size, props.get(core.$font-size--100)) !default; 13$font-size: props.def(--o-action-button--font-size, props.get(core.$font-size--100)) !default;
14 14
15$pad-i--sm: props.def(--o-action-button--sm--pad-i, props.get(core.$size--100)) !default; 15$pad-i--sm: props.def(--o-action-button--sm--pad-i, props.get(core.$size--100)) !default;
16$pad-i-label--sm: props.def(--o-button--sm--pad-i-label, props.get(core.$size--25)) !default; 16$pad-i-label--sm: props.def(--o-action-button--sm--pad-i-label, props.get(core.$size--25)) !default;
17$pad-i-pill--sm: props.def(--o-action-button--sm--pad-i-pill, props.get(core.$size--150)) !default; 17$pad-i-pill--sm: props.def(--o-action-button--sm--pad-i-pill, props.get(core.$size--150)) !default;
18$pad-b--sm: props.def(--o-action-button--sm--pad-b, props.get(core.$size--40)) !default; 18$pad-b--sm: props.def(--o-action-button--sm--pad-b, props.get(core.$size--40)) !default;
19$font-size--sm: props.def(--o-action-button--sm--font-size, props.get(core.$font-size--75)) !default; 19$font-size--sm: props.def(--o-action-button--sm--font-size, props.get(core.$font-size--75)) !default;
20 20
21$pad-i--lg: props.def(--o-action-button--lg--pad-i, props.get(core.$size--175)) !default; 21$pad-i--lg: props.def(--o-action-button--lg--pad-i, props.get(core.$size--175)) !default;
22$pad-i-label--lg: props.def(--o-button--lg--pad-i-label, props.get(core.$size--100)) !default; 22$pad-i-label--lg: props.def(--o-action-button--lg--pad-i-label, props.get(core.$size--100)) !default;
23$pad-i-pill--lg: props.def(--o-action-button--lg--pad-i-pill, props.get(core.$size--250)) !default; 23$pad-i-pill--lg: props.def(--o-action-button--lg--pad-i-pill, props.get(core.$size--250)) !default;
24$pad-b--lg: props.def(--o-action-button--lg--pad-b, props.get(core.$size--115)) !default; 24$pad-b--lg: props.def(--o-action-button--lg--pad-b, props.get(core.$size--115)) !default;
25$font-size--lg: props.def(--o-action-button--lg--font-size, props.get(core.$font-size--150)) !default; 25$font-size--lg: props.def(--o-action-button--lg--font-size, props.get(core.$font-size--150)) !default;
26 26
27$pad-i--xl: props.def(--o-action-button--xl--pad-i, props.get(core.$size--225)) !default; 27$pad-i--xl: props.def(--o-action-button--xl--pad-i, props.get(core.$size--225)) !default;
28$pad-i-label--xl: props.def(--o-button--xl--pad-i-label, props.get(core.$size--150)) !default; 28$pad-i-label--xl: props.def(--o-action-button--xl--pad-i-label, props.get(core.$size--150)) !default;
29$pad-i-pill--xl: props.def(--o-action-button--xl--pad-i-pill, props.get(core.$size--300)) !default; 29$pad-i-pill--xl: props.def(--o-action-button--xl--pad-i-pill, props.get(core.$size--300)) !default;
30$pad-b--xl: props.def(--o-action-button--xl--pad-b, props.get(core.$size--150)) !default; 30$pad-b--xl: props.def(--o-action-button--xl--pad-b, props.get(core.$size--150)) !default;
31$font-size--xl: props.def(--o-action-button--xl--font-size, props.get(core.$font-size--200)) !default; 31$font-size--xl: props.def(--o-action-button--xl--font-size, props.get(core.$font-size--200)) !default;
diff --git a/src/objects/_navbar.scss b/src/objects/_navbar.scss
new file mode 100644
index 0000000..16cf804
--- /dev/null
+++ b/src/objects/_navbar.scss
@@ -0,0 +1,165 @@
1@use 'sass:map';
2@use 'sass:meta';
3@use 'sass:string';
4@use 'iro-sass/src/bem';
5@use 'iro-sass/src/props';
6@use '../props' as *;
7
8@forward 'navbar.vars';
9@use 'navbar.vars' as vars;
10
11@mixin styles {
12 @include materialize-at-root(meta.module-variables('vars'));
13
14 @include bem.object('navbar') {
15 display: flex;
16 block-size: props.get(vars.$block-size);
17
18 @include bem.modifier('adapt') {
19 block-size: 100%;
20 }
21
22 @include bem.elem('item-label') {
23 position: relative;
24 padding-block: props.get(vars.$item--pad-b);
25 padding-inline: props.get(vars.$item--pad-i);
26 font-size: props.get(vars.$item--font-size);
27 color: currentColor;
28 border-radius: 100em;
29
30 &::after {
31 position: absolute;
32 inset: calc(-1 * props.get(vars.$key-focus--border-offset));
33 z-index: 1;
34 display: none;
35 pointer-events: none;
36 content: '';
37 border-radius: 100em;
38 outline: props.get(vars.$default-theme, --key-focus, --border) solid props.get(vars.$key-focus--border-width);
39 box-shadow:
40 0
41 0
42 0
43 calc(props.get(vars.$key-focus--border-width) + props.get(vars.$key-focus--outline-width))
44 props.get(vars.$default-theme, --key-focus, --outline);
45 }
46 }
47
48 @include bem.elem('item') {
49 display: flex;
50 flex-direction: column;
51 align-items: center;
52 justify-content: center;
53 inline-size: 100%;
54 padding-inline: calc(.5 * props.get(vars.$spacing));
55 font-weight: 500;
56 color: props.get(vars.$default-theme, --disabled, --label-color);
57
58 &:link,
59 &:visited,
60 &:enabled {
61 color: props.get(vars.$default-theme, --label-color);
62
63 &:hover,
64 &:focus-visible {
65 color: props.get(vars.$default-theme, --hover, --label-color);
66
67 @include bem.elem('item-label') {
68 background-color: props.get(vars.$default-theme, --hover, --bg-color);
69 }
70 }
71
72 &:focus-visible {
73 @include bem.elem('item-label') {
74 &::after {
75 display: block;
76 }
77 }
78 }
79
80 &:active {
81 color: props.get(vars.$default-theme, --active, --label-color);
82
83 @include bem.elem('item-label') {
84 background-color: props.get(vars.$default-theme, --active, --bg-color);
85 }
86 }
87 }
88
89 @include bem.is('selected') {
90 font-weight: bold;
91 color: props.get(vars.$default-theme, --selected, --disabled, --label-color);
92
93 @include bem.elem('item-label') {
94 background-color: props.get(vars.$default-theme, --selected, --disabled, --bg-color);
95 }
96
97 &:link,
98 &:visited,
99 &:enabled {
100 color: props.get(vars.$default-theme, --selected, --label-color);
101
102 @include bem.elem('item-label') {
103 background-color: props.get(vars.$default-theme, --selected, --bg-color);
104 }
105
106 &:hover,
107 &:focus-visible {
108 color: props.get(vars.$default-theme, --selected, --hover, --label-color);
109
110 @include bem.elem('item-label') {
111 background-color: props.get(vars.$default-theme, --selected, --hover, --bg-color);
112 }
113 }
114
115 &:active {
116 color: props.get(vars.$default-theme, --selected, --active, --label-color);
117
118 @include bem.elem('item-label') {
119 background-color: props.get(vars.$default-theme, --selected, --active, --bg-color);
120 }
121 }
122 }
123 }
124 }
125
126 @include bem.modifier('quiet') {
127 @include bem.elem('item') {
128 @include bem.is('selected') {
129 color: props.get(vars.$default-theme, --quiet, --selected, --disabled, --label-color);
130
131 @include bem.elem('item-label') {
132 background-color: props.get(vars.$default-theme, --quiet, --selected, --disabled, --bg-color);
133 }
134
135 &:link,
136 &:visited,
137 &:enabled {
138 color: props.get(vars.$default-theme, --quiet, --selected, --label-color);
139
140 @include bem.elem('item-label') {
141 background-color: props.get(vars.$default-theme, --quiet, --selected, --bg-color);
142 }
143
144 &:hover,
145 &:focus-visible {
146 color: props.get(vars.$default-theme, --quiet, --selected, --hover, --label-color);
147
148 @include bem.elem('item-label') {
149 background-color: props.get(vars.$default-theme, --quiet, --selected, --hover, --bg-color);
150 }
151 }
152
153 &:active {
154 color: props.get(vars.$default-theme, --quiet, --selected, --active, --label-color);
155
156 @include bem.elem('item-label') {
157 background-color: props.get(vars.$default-theme, --quiet, --selected, --active, --bg-color);
158 }
159 }
160 }
161 }
162 }
163 }
164 }
165}
diff --git a/src/objects/_navbar.vars.scss b/src/objects/_navbar.vars.scss
new file mode 100644
index 0000000..dfd683a
--- /dev/null
+++ b/src/objects/_navbar.vars.scss
@@ -0,0 +1,83 @@
1@use 'sass:map';
2@use 'sass:string';
3@use 'iro-sass/src/props';
4@use '../core.vars' as core;
5
6$block-size: props.def(--o-navbar--block-size, props.get(core.$size--700)) !default;
7$spacing: props.def(--o-tabs--spacing, props.get(core.$size--400)) !default;
8
9$item--pad-i: props.def(--o-navbar--item--pad-i, props.get(core.$size--175)) !default;
10$item--pad-b: props.def(--o-navbar--item--pad-b, props.get(core.$size--40)) !default;
11$item--font-size: props.def(--o-navbar--item--font-size, props.get(core.$font-size--75)) !default;
12
13$key-focus--border-width: props.def(--o-navbar--key-focus--border-width, props.get(core.$key-focus--border-width)) !default;
14$key-focus--border-offset: props.def(--o-navbar--key-focus--border-offset, props.get(core.$key-focus--border-offset)) !default;
15$key-focus--outline-width: props.def(--o-navbar--key-focus--outline-width, props.get(core.$key-focus--outline-width)) !default;
16
17$default-theme-override: () !default;
18$default-theme: map.deep-merge((
19 --label-color: props.get(core.$theme, --text),
20
21 --hover: (
22 --bg-color: props.get(core.$theme, --border-mute),
23 --label-color: props.get(core.$theme, --heading),
24 ),
25
26 --active: (
27 --bg-color: props.get(core.$theme, --border),
28 --label-color: props.get(core.$theme, --heading),
29 ),
30
31 --disabled: (
32 --label-color: props.get(core.$theme, --border-strong),
33 ),
34
35 --key-focus: (
36 --label: props.get(core.$theme, --focus, --text),
37 --border: props.get(core.$theme, --focus, --border),
38 --outline: props.get(core.$theme, --focus, --outline),
39 ),
40
41 --selected: (
42 --bg-color: props.get(core.$theme, --heading),
43 --label-color: props.get(core.$theme, --base, --50),
44
45 --hover: (
46 --bg-color: props.get(core.$theme, --text),
47 --label-color: props.get(core.$theme, --base, --50),
48 ),
49
50 --active: (
51 --bg-color: props.get(core.$theme, --text-mute),
52 --label-color: props.get(core.$theme, --base, --50),
53 ),
54
55 --disabled: (
56 --bg-color: props.get(core.$theme, --border-mute),
57 --label-color: props.get(core.$theme, --border-strong),
58 ),
59 ),
60
61 --quiet: (
62 --selected: (
63 --bg-color: props.get(core.$theme, --accent, --200),
64 --label-color: props.get(core.$theme, --accent, --1100),
65
66 --hover: (
67 --bg-color: props.get(core.$theme, --accent, --300),
68 --label-color: props.get(core.$theme, --accent, --1200),
69 ),
70
71 --active: (
72 --bg-color: props.get(core.$theme, --accent, --400),
73 --label-color: props.get(core.$theme, --accent, --1300),
74 ),
75
76 --disabled: (
77 --bg-color: props.get(core.$theme, --accent, --200),
78 --label-color: props.get(core.$theme, --accent, --800),
79 ),
80 )
81 )
82), $default-theme-override) !default;
83$default-theme: props.def(--o-navbar, $default-theme, 'color');
diff --git a/src_demo/index.scss b/src_demo/index.scss
index 4b345dd..d9994e4 100644
--- a/src_demo/index.scss
+++ b/src_demo/index.scss
@@ -34,6 +34,7 @@
34@include iro.o-heading--styles; 34@include iro.o-heading--styles;
35@include iro.o-lightbox--styles; 35@include iro.o-lightbox--styles;
36@include iro.o-menu--styles; 36@include iro.o-menu--styles;
37@include iro.o-navbar--styles;
37@include iro.o-palette--styles; 38@include iro.o-palette--styles;
38@include iro.o-popover--styles; 39@include iro.o-popover--styles;
39@include iro.o-radio--styles; 40@include iro.o-radio--styles;
diff --git a/tpl/index.pug b/tpl/index.pug
index cccfb2a..7d73c75 100644
--- a/tpl/index.pug
+++ b/tpl/index.pug
@@ -24,6 +24,7 @@ include objects/avatar.pug
24include objects/card.pug 24include objects/card.pug
25include objects/popover.pug 25include objects/popover.pug
26include objects/menu.pug 26include objects/menu.pug
27include objects/navbar.pug
27include objects/side-nav.pug 28include objects/side-nav.pug
28include objects/icon-nav.pug 29include objects/icon-nav.pug
29include objects/emoji.pug 30include objects/emoji.pug
@@ -76,6 +77,7 @@ include views/avatar.pug
76include views/card.pug 77include views/card.pug
77include views/popover.pug 78include views/popover.pug
78include views/menu.pug 79include views/menu.pug
80include views/navbar.pug
79include views/side-nav.pug 81include views/side-nav.pug
80include views/icon-nav.pug 82include views/icon-nav.pug
81include views/backdrop.pug 83include views/backdrop.pug
@@ -124,6 +126,7 @@ html
124 +view-side-nav 126 +view-side-nav
125 +view-popover 127 +view-popover
126 +view-menu 128 +view-menu
129 +view-navbar
127 //+view-icon-nav 130 //+view-icon-nav
128 +view-backdrop 131 +view-backdrop
129 //+view-dialog 132 //+view-dialog
diff --git a/tpl/objects/navbar.pug b/tpl/objects/navbar.pug
new file mode 100644
index 0000000..bca8c90
--- /dev/null
+++ b/tpl/objects/navbar.pug
@@ -0,0 +1,30 @@
1include icon.pug
2include status-indicator.pug
3include action-button.pug
4
5mixin navbar
6 -
7 let classes = {
8 'o-navbar': true,
9 'o-navbar--quiet': attributes.quiet,
10 }
11 if (attributes.class) {
12 classes[attributes.class] = true;
13 }
14
15 div(class=classes)&attributes(attributes)
16 block
17
18mixin navbar-item
19 -
20 let classes = {
21 'o-navbar__item': true,
22 'is-selected': attributes.selected,
23 }
24 if (attributes.class) {
25 classes[attributes.class] = true;
26 }
27
28 #{!!attributes.tag ? attributes.tag : 'button'}(class=classes)&attributes(attributes)
29 .o-navbar__item-label
30 block
diff --git a/tpl/views/navbar.pug b/tpl/views/navbar.pug
new file mode 100644
index 0000000..03f1591
--- /dev/null
+++ b/tpl/views/navbar.pug
@@ -0,0 +1,13 @@
1mixin view-navbar
2 +view('navbar', 'Navbar')
3 .c-box
4 +navbar
5 +navbar-item= 'Home'
6 +navbar-item(selected=true)= 'Art'
7 +navbar-item= 'Emojis'
8
9 .c-box
10 +navbar(quiet=true)
11 +navbar-item= 'Home'
12 +navbar-item(selected=true)= 'Art'
13 +navbar-item= 'Emojis'