diff options
author | Volpeon <git@volpeon.ink> | 2024-11-19 07:55:19 +0100 |
---|---|---|
committer | Volpeon <git@volpeon.ink> | 2024-11-19 07:55:19 +0100 |
commit | 4d8853016f43d6d8ddcaf532d4742dfa0d2e308c (patch) | |
tree | 0d8c8a2a6d954750b4faa898cb66b0ae03b6174f | |
parent | Fix navbar variable id (diff) | |
download | iro-design-4d8853016f43d6d8ddcaf532d4742dfa0d2e308c.tar.gz iro-design-4d8853016f43d6d8ddcaf532d4742dfa0d2e308c.tar.bz2 iro-design-4d8853016f43d6d8ddcaf532d4742dfa0d2e308c.zip |
Navbar: Better icon integration
-rw-r--r-- | package.json | 2 | ||||
-rw-r--r-- | src/objects/_navbar.scss | 28 | ||||
-rw-r--r-- | src/objects/_navbar.vars.scss | 7 | ||||
-rw-r--r-- | tpl/objects/navbar.pug | 11 | ||||
-rw-r--r-- | tpl/views/navbar.pug | 6 |
5 files changed, 36 insertions, 18 deletions
diff --git a/package.json b/package.json index ff42d59..cc74db1 100644 --- a/package.json +++ b/package.json | |||
@@ -12,7 +12,7 @@ | |||
12 | "build": "npm run build:app && npm run build:style && npm run build:icons && npm run build:assets", | 12 | "build": "npm run build:app && npm run build:style && npm run build:icons && npm run build:assets", |
13 | "build:assets": "cp -r static/* public/", | 13 | "build:assets": "cp -r static/* public/", |
14 | "build:app": "pug tpl/index.pug -p tpl --out public/", | 14 | "build:app": "pug tpl/index.pug -p tpl --out public/", |
15 | "build:icons": "node node_modules/iro-icons/scripts/create_sprite.js image video volume-2 arrow-right check trash bookmark cog logout tags lock user chevron-left chevron-right hash x send smile repeat heart star arrow-corner-down-left public/icons.svg", | 15 | "build:icons": "node node_modules/iro-icons/scripts/create_sprite.js image video volume-2 arrow-right arrow-left check trash bookmark cog logout tags lock user chevron-left chevron-right hash x send smile repeat heart star arrow-corner-down-left public/icons.svg", |
16 | "build:style": "sass --load-path=node_modules src_demo/index.scss public/style.css", | 16 | "build:style": "sass --load-path=node_modules src_demo/index.scss public/style.css", |
17 | "lint:style": "stylelint \"src/**/*.scss\"", | 17 | "lint:style": "stylelint \"src/**/*.scss\"", |
18 | "fix:style": "stylelint \"src/**/*.scss\" --fix", | 18 | "fix:style": "stylelint \"src/**/*.scss\" --fix", |
diff --git a/src/objects/_navbar.scss b/src/objects/_navbar.scss index af3406a..d245e2e 100644 --- a/src/objects/_navbar.scss +++ b/src/objects/_navbar.scss | |||
@@ -15,7 +15,11 @@ | |||
15 | display: flex; | 15 | display: flex; |
16 | block-size: props.get(vars.$block-size); | 16 | block-size: props.get(vars.$block-size); |
17 | 17 | ||
18 | @include bem.elem('item-label') { | 18 | @include bem.elem('item-content-text') { |
19 | margin-inline: props.get(vars.$item--pad-i-label); | ||
20 | } | ||
21 | |||
22 | @include bem.elem('item-content') { | ||
19 | position: relative; | 23 | position: relative; |
20 | padding-block: props.get(vars.$item--pad-b); | 24 | padding-block: props.get(vars.$item--pad-b); |
21 | padding-inline: props.get(vars.$item--pad-i); | 25 | padding-inline: props.get(vars.$item--pad-i); |
@@ -60,13 +64,13 @@ | |||
60 | &:focus-visible { | 64 | &:focus-visible { |
61 | color: props.get(vars.$default-theme, --hover, --label-color); | 65 | color: props.get(vars.$default-theme, --hover, --label-color); |
62 | 66 | ||
63 | @include bem.elem('item-label') { | 67 | @include bem.elem('item-content') { |
64 | background-color: props.get(vars.$default-theme, --hover, --bg-color); | 68 | background-color: props.get(vars.$default-theme, --hover, --bg-color); |
65 | } | 69 | } |
66 | } | 70 | } |
67 | 71 | ||
68 | &:focus-visible { | 72 | &:focus-visible { |
69 | @include bem.elem('item-label') { | 73 | @include bem.elem('item-content') { |
70 | &::after { | 74 | &::after { |
71 | display: block; | 75 | display: block; |
72 | } | 76 | } |
@@ -76,7 +80,7 @@ | |||
76 | &:active { | 80 | &:active { |
77 | color: props.get(vars.$default-theme, --active, --label-color); | 81 | color: props.get(vars.$default-theme, --active, --label-color); |
78 | 82 | ||
79 | @include bem.elem('item-label') { | 83 | @include bem.elem('item-content') { |
80 | background-color: props.get(vars.$default-theme, --active, --bg-color); | 84 | background-color: props.get(vars.$default-theme, --active, --bg-color); |
81 | } | 85 | } |
82 | } | 86 | } |
@@ -86,7 +90,7 @@ | |||
86 | font-weight: bold; | 90 | font-weight: bold; |
87 | color: props.get(vars.$default-theme, --selected, --disabled, --label-color); | 91 | color: props.get(vars.$default-theme, --selected, --disabled, --label-color); |
88 | 92 | ||
89 | @include bem.elem('item-label') { | 93 | @include bem.elem('item-content') { |
90 | background-color: props.get(vars.$default-theme, --selected, --disabled, --bg-color); | 94 | background-color: props.get(vars.$default-theme, --selected, --disabled, --bg-color); |
91 | } | 95 | } |
92 | 96 | ||
@@ -95,7 +99,7 @@ | |||
95 | &:enabled { | 99 | &:enabled { |
96 | color: props.get(vars.$default-theme, --selected, --label-color); | 100 | color: props.get(vars.$default-theme, --selected, --label-color); |
97 | 101 | ||
98 | @include bem.elem('item-label') { | 102 | @include bem.elem('item-content') { |
99 | background-color: props.get(vars.$default-theme, --selected, --bg-color); | 103 | background-color: props.get(vars.$default-theme, --selected, --bg-color); |
100 | } | 104 | } |
101 | 105 | ||
@@ -103,7 +107,7 @@ | |||
103 | &:focus-visible { | 107 | &:focus-visible { |
104 | color: props.get(vars.$default-theme, --selected, --hover, --label-color); | 108 | color: props.get(vars.$default-theme, --selected, --hover, --label-color); |
105 | 109 | ||
106 | @include bem.elem('item-label') { | 110 | @include bem.elem('item-content') { |
107 | background-color: props.get(vars.$default-theme, --selected, --hover, --bg-color); | 111 | background-color: props.get(vars.$default-theme, --selected, --hover, --bg-color); |
108 | } | 112 | } |
109 | } | 113 | } |
@@ -111,7 +115,7 @@ | |||
111 | &:active { | 115 | &:active { |
112 | color: props.get(vars.$default-theme, --selected, --active, --label-color); | 116 | color: props.get(vars.$default-theme, --selected, --active, --label-color); |
113 | 117 | ||
114 | @include bem.elem('item-label') { | 118 | @include bem.elem('item-content') { |
115 | background-color: props.get(vars.$default-theme, --selected, --active, --bg-color); | 119 | background-color: props.get(vars.$default-theme, --selected, --active, --bg-color); |
116 | } | 120 | } |
117 | } | 121 | } |
@@ -148,7 +152,7 @@ | |||
148 | @include bem.is('selected') { | 152 | @include bem.is('selected') { |
149 | color: props.get(vars.$default-theme, --quiet, --selected, --disabled, --label-color); | 153 | color: props.get(vars.$default-theme, --quiet, --selected, --disabled, --label-color); |
150 | 154 | ||
151 | @include bem.elem('item-label') { | 155 | @include bem.elem('item-content') { |
152 | background-color: props.get(vars.$default-theme, --quiet, --selected, --disabled, --bg-color); | 156 | background-color: props.get(vars.$default-theme, --quiet, --selected, --disabled, --bg-color); |
153 | } | 157 | } |
154 | 158 | ||
@@ -157,7 +161,7 @@ | |||
157 | &:enabled { | 161 | &:enabled { |
158 | color: props.get(vars.$default-theme, --quiet, --selected, --label-color); | 162 | color: props.get(vars.$default-theme, --quiet, --selected, --label-color); |
159 | 163 | ||
160 | @include bem.elem('item-label') { | 164 | @include bem.elem('item-content') { |
161 | background-color: props.get(vars.$default-theme, --quiet, --selected, --bg-color); | 165 | background-color: props.get(vars.$default-theme, --quiet, --selected, --bg-color); |
162 | } | 166 | } |
163 | 167 | ||
@@ -165,7 +169,7 @@ | |||
165 | &:focus-visible { | 169 | &:focus-visible { |
166 | color: props.get(vars.$default-theme, --quiet, --selected, --hover, --label-color); | 170 | color: props.get(vars.$default-theme, --quiet, --selected, --hover, --label-color); |
167 | 171 | ||
168 | @include bem.elem('item-label') { | 172 | @include bem.elem('item-content') { |
169 | background-color: props.get(vars.$default-theme, --quiet, --selected, --hover, --bg-color); | 173 | background-color: props.get(vars.$default-theme, --quiet, --selected, --hover, --bg-color); |
170 | } | 174 | } |
171 | } | 175 | } |
@@ -173,7 +177,7 @@ | |||
173 | &:active { | 177 | &:active { |
174 | color: props.get(vars.$default-theme, --quiet, --selected, --active, --label-color); | 178 | color: props.get(vars.$default-theme, --quiet, --selected, --active, --label-color); |
175 | 179 | ||
176 | @include bem.elem('item-label') { | 180 | @include bem.elem('item-content') { |
177 | background-color: props.get(vars.$default-theme, --quiet, --selected, --active, --bg-color); | 181 | background-color: props.get(vars.$default-theme, --quiet, --selected, --active, --bg-color); |
178 | } | 182 | } |
179 | } | 183 | } |
diff --git a/src/objects/_navbar.vars.scss b/src/objects/_navbar.vars.scss index 5839eff..da280fd 100644 --- a/src/objects/_navbar.vars.scss +++ b/src/objects/_navbar.vars.scss | |||
@@ -6,9 +6,10 @@ | |||
6 | $block-size: props.def(--o-navbar--block-size, props.get(core.$size--800)) !default; | 6 | $block-size: props.def(--o-navbar--block-size, props.get(core.$size--800)) !default; |
7 | $spacing: props.def(--o-navbar--spacing, props.get(core.$size--200)) !default; | 7 | $spacing: props.def(--o-navbar--spacing, props.get(core.$size--200)) !default; |
8 | 8 | ||
9 | $item--pad-i: props.def(--o-navbar--item--pad-i, props.get(core.$size--175)) !default; | 9 | $item--pad-i: props.def(--o-navbar--item--pad-i, props.get(core.$size--150)) !default; |
10 | $item--pad-b: props.def(--o-navbar--item--pad-b, props.get(core.$size--40)) !default; | 10 | $item--pad-i-label: props.def(--o-action-button--pad-i-label, props.get(core.$size--25)) !default; |
11 | $item--font-size: props.def(--o-navbar--item--font-size, props.get(core.$font-size--75)) !default; | 11 | $item--pad-b: props.def(--o-navbar--item--pad-b, props.get(core.$size--40)) !default; |
12 | $item--font-size: props.def(--o-navbar--item--font-size, props.get(core.$font-size--75)) !default; | ||
12 | 13 | ||
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-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--border-offset: props.def(--o-navbar--key-focus--border-offset, props.get(core.$key-focus--border-offset)) !default; |
diff --git a/tpl/objects/navbar.pug b/tpl/objects/navbar.pug index bca8c90..5c7642c 100644 --- a/tpl/objects/navbar.pug +++ b/tpl/objects/navbar.pug | |||
@@ -26,5 +26,12 @@ mixin navbar-item | |||
26 | } | 26 | } |
27 | 27 | ||
28 | #{!!attributes.tag ? attributes.tag : 'button'}(class=classes)&attributes(attributes) | 28 | #{!!attributes.tag ? attributes.tag : 'button'}(class=classes)&attributes(attributes) |
29 | .o-navbar__item-label | 29 | .o-navbar__item-content |
30 | block | 30 | if attributes.icon |
31 | +icon(attributes.icon) | ||
32 | = ' ' | ||
33 | span.o-navbar__item-content-text | ||
34 | block | ||
35 | if attributes.postIcon | ||
36 | = ' ' | ||
37 | +icon(attributes.postIcon) | ||
diff --git a/tpl/views/navbar.pug b/tpl/views/navbar.pug index 03f1591..345a22b 100644 --- a/tpl/views/navbar.pug +++ b/tpl/views/navbar.pug | |||
@@ -11,3 +11,9 @@ mixin view-navbar | |||
11 | +navbar-item= 'Home' | 11 | +navbar-item= 'Home' |
12 | +navbar-item(selected=true)= 'Art' | 12 | +navbar-item(selected=true)= 'Art' |
13 | +navbar-item= 'Emojis' | 13 | +navbar-item= 'Emojis' |
14 | |||
15 | .c-box | ||
16 | +navbar(quiet=true) | ||
17 | +navbar-item(selected=true icon="arrow-left")= 'Home' | ||
18 | +navbar-item= 'Art' | ||
19 | +navbar-item= 'Emojis' | ||