diff options
| author | Volpeon <git@volpeon.ink> | 2024-06-26 09:19:02 +0200 |
|---|---|---|
| committer | Volpeon <git@volpeon.ink> | 2024-06-26 09:19:02 +0200 |
| commit | 4e87fb46f2958ae28bdcfbc469118f14297b4d26 (patch) | |
| tree | 4b1a6c99a5e2273487eb3cff9db5c60007241d20 | |
| parent | Action button styling (diff) | |
| download | iro-design-4e87fb46f2958ae28bdcfbc469118f14297b4d26.tar.gz iro-design-4e87fb46f2958ae28bdcfbc469118f14297b4d26.tar.bz2 iro-design-4e87fb46f2958ae28bdcfbc469118f14297b4d26.zip | |
Pill version for action button
| -rw-r--r-- | src/_config.scss | 3 | ||||
| -rw-r--r-- | src/objects/_action-button.scss | 69 | ||||
| -rw-r--r-- | src/objects/_button.scss | 5 | ||||
| -rw-r--r-- | tpl/objects/action-button.pug | 6 | ||||
| -rw-r--r-- | tpl/views/action-button.pug | 89 |
5 files changed, 125 insertions, 47 deletions
diff --git a/src/_config.scss b/src/_config.scss index 56a74e1..f4f43fd 100644 --- a/src/_config.scss +++ b/src/_config.scss | |||
| @@ -82,6 +82,9 @@ $semantic-colors-common: ( | |||
| 82 | --focus-raw: --accent, | 82 | --focus-raw: --accent, |
| 83 | --focus-static: --accent-static, | 83 | --focus-static: --accent-static, |
| 84 | 84 | ||
| 85 | --light: --white-transparent, | ||
| 86 | --shadow: --black-transparent, | ||
| 87 | |||
| 85 | --border-mute: --base --200, | 88 | --border-mute: --base --200, |
| 86 | --border: --base --300, | 89 | --border: --base --300, |
| 87 | --border-strong: --base --400, | 90 | --border-strong: --base --400, |
diff --git a/src/objects/_action-button.scss b/src/objects/_action-button.scss index 6286f4e..6dbdc2f 100644 --- a/src/objects/_action-button.scss +++ b/src/objects/_action-button.scss | |||
| @@ -1,14 +1,37 @@ | |||
| 1 | @use 'iro-sass/src/index' as iro; | 1 | @use 'iro-sass/src/index' as iro; |
| 2 | @use '../functions' as fn; | 2 | @use '../functions' as fn; |
| 3 | 3 | ||
| 4 | $sizes: 'sm' 'lg' 'xl' !default; | ||
| 5 | |||
| 4 | @include iro.props-namespace('action-button') { | 6 | @include iro.props-namespace('action-button') { |
| 5 | @include iro.props-store(( | 7 | @include iro.props-store(( |
| 6 | --dims: ( | 8 | --dims: ( |
| 7 | --line-height: 1.4, | 9 | --line-height: 1.4, |
| 8 | --pad-i: fn.global-dim(--size --100), | 10 | --pad-i: fn.global-dim(--size --150), |
| 11 | --pad-i-pill: fn.global-dim(--size --200), | ||
| 9 | --pad-b: fn.global-dim(--size --85), | 12 | --pad-b: fn.global-dim(--size --85), |
| 10 | --border: fn.global-dim(--border --thin), | 13 | --border: fn.global-dim(--border --thin), |
| 11 | --rounding: fn.global-dim(--rounding), | 14 | --rounding: fn.global-dim(--rounding), |
| 15 | --font-size: fn.global-dim(--font-size --100), | ||
| 16 | |||
| 17 | --sm: ( | ||
| 18 | --pad-i: fn.global-dim(--size --100), | ||
| 19 | --pad-i-pill: fn.global-dim(--size --150), | ||
| 20 | --pad-b: fn.global-dim(--size --40), | ||
| 21 | --font-size: fn.global-dim(--font-size --75), | ||
| 22 | ), | ||
| 23 | --lg: ( | ||
| 24 | --pad-i: fn.global-dim(--size --175), | ||
| 25 | --pad-i-pill: fn.global-dim(--size --225), | ||
| 26 | --pad-b: fn.global-dim(--size --115), | ||
| 27 | --font-size: fn.global-dim(--font-size --150), | ||
| 28 | ), | ||
| 29 | --xl: ( | ||
| 30 | --pad-i: fn.global-dim(--size --225), | ||
| 31 | --pad-i-pill: fn.global-dim(--size --300), | ||
| 32 | --pad-b: fn.global-dim(--size --150), | ||
| 33 | --font-size: fn.global-dim(--font-size --200), | ||
| 34 | ), | ||
| 12 | 35 | ||
| 13 | --key-focus: ( | 36 | --key-focus: ( |
| 14 | --border: fn.global-dim(--key-focus --border), | 37 | --border: fn.global-dim(--key-focus --border), |
| @@ -27,14 +50,14 @@ | |||
| 27 | --border: fn.global-color(--text-mute-more), | 50 | --border: fn.global-color(--text-mute-more), |
| 28 | ), | 51 | ), |
| 29 | --active: ( | 52 | --active: ( |
| 30 | --bg: fn.global-color(--border-mute), | 53 | --bg: fn.global-color(--border), |
| 31 | --label: fn.global-color(--heading), | 54 | --label: fn.global-color(--heading), |
| 32 | --border: fn.global-color(--text-mute-more), | 55 | --border: fn.global-color(--text-mute), |
| 33 | ), | 56 | ), |
| 34 | --disabled: ( | 57 | --disabled: ( |
| 35 | --bg: fn.global-color(--bg-l1), | 58 | --bg: fn.global-color(--bg-l1), |
| 36 | --label: fn.global-color(--border-strong), | 59 | --label: fn.global-color(--border-strong), |
| 37 | --border: fn.global-color(--border-mute), | 60 | --border: fn.global-color(--border), |
| 38 | ), | 61 | ), |
| 39 | --selected: ( | 62 | --selected: ( |
| 40 | --bg: fn.global-color(--text-mute), | 63 | --bg: fn.global-color(--text-mute), |
| @@ -73,7 +96,7 @@ | |||
| 73 | --label: fn.global-color(--heading), | 96 | --label: fn.global-color(--heading), |
| 74 | ), | 97 | ), |
| 75 | --disabled: ( | 98 | --disabled: ( |
| 76 | --label: fn.global-color(--text-disabled), | 99 | --label: fn.global-color(--border-strong), |
| 77 | ), | 100 | ), |
| 78 | ), | 101 | ), |
| 79 | ), | 102 | ), |
| @@ -92,7 +115,6 @@ | |||
| 92 | text-align: center; | 115 | text-align: center; |
| 93 | text-decoration: none; | 116 | text-decoration: none; |
| 94 | text-overflow: ellipsis; | 117 | text-overflow: ellipsis; |
| 95 | vertical-align: top; | ||
| 96 | white-space: nowrap; | 118 | white-space: nowrap; |
| 97 | 119 | ||
| 98 | &::after { | 120 | &::after { |
| @@ -137,7 +159,6 @@ | |||
| 137 | @include iro.bem-modifier('quiet') { | 159 | @include iro.bem-modifier('quiet') { |
| 138 | border-color: transparent; | 160 | border-color: transparent; |
| 139 | background-color: transparent; | 161 | background-color: transparent; |
| 140 | box-shadow: none; | ||
| 141 | color: fn.color(--quiet --disabled --label); | 162 | color: fn.color(--quiet --disabled --label); |
| 142 | 163 | ||
| 143 | &:link, | 164 | &:link, |
| @@ -145,21 +166,18 @@ | |||
| 145 | &:enabled { | 166 | &:enabled { |
| 146 | border-color: transparent; | 167 | border-color: transparent; |
| 147 | background-color: transparent; | 168 | background-color: transparent; |
| 148 | box-shadow: none; | ||
| 149 | color: fn.color(--quiet --label); | 169 | color: fn.color(--quiet --label); |
| 150 | 170 | ||
| 151 | &:hover, | 171 | &:hover, |
| 152 | &:focus-visible { | 172 | &:focus-visible { |
| 153 | border-color: transparent; | 173 | border-color: transparent; |
| 154 | background-color: fn.color(--quiet --hover --bg); | 174 | background-color: fn.color(--quiet --hover --bg); |
| 155 | box-shadow: none; | ||
| 156 | color: fn.color(--quiet --hover --label); | 175 | color: fn.color(--quiet --hover --label); |
| 157 | } | 176 | } |
| 158 | 177 | ||
| 159 | &:active { | 178 | &:active { |
| 160 | border-color: transparent; | 179 | border-color: transparent; |
| 161 | background-color: fn.color(--quiet --active --bg); | 180 | background-color: fn.color(--quiet --active --bg); |
| 162 | box-shadow: none; | ||
| 163 | color: fn.color(--quiet --active --label); | 181 | color: fn.color(--quiet --active --label); |
| 164 | } | 182 | } |
| 165 | } | 183 | } |
| @@ -192,10 +210,37 @@ | |||
| 192 | } | 210 | } |
| 193 | } | 211 | } |
| 194 | 212 | ||
| 195 | @include iro.bem-modifier('round') { | 213 | @include iro.bem-modifier('pill') { |
| 214 | padding-inline: fn.dim(--pad-i-pill); | ||
| 215 | border-radius: 100em; | ||
| 216 | |||
| 217 | &::after { | ||
| 218 | border-radius: 100em; | ||
| 219 | } | ||
| 220 | } | ||
| 221 | |||
| 222 | @each $size in $sizes { | ||
| 223 | @include iro.bem-modifier($size) { | ||
| 224 | padding-block: fn.dim(--#{$size} --pad-b); | ||
| 225 | padding-inline: fn.dim(--#{$size} --pad-i); | ||
| 226 | font-size: fn.dim(--#{$size} --font-size); | ||
| 227 | |||
| 228 | @include iro.bem-modifier('pill') { | ||
| 229 | padding-inline: fn.dim(--#{$size} --pad-i-pill); | ||
| 230 | } | ||
| 231 | } | ||
| 232 | } | ||
| 233 | |||
| 234 | @include iro.bem-modifier('icon') { | ||
| 196 | inline-size: calc(1em * fn.dim(--line-height) + 2 * fn.dim(--pad-b)); | 235 | inline-size: calc(1em * fn.dim(--line-height) + 2 * fn.dim(--pad-b)); |
| 197 | padding-inline: 0; | 236 | padding-inline: 0; |
| 198 | border-radius: 100em; | 237 | |
| 238 | @each $size in $sizes { | ||
| 239 | @include iro.bem-modifier($size) { | ||
| 240 | inline-size: calc(1em * fn.dim(--line-height) + 2 * fn.dim(--#{$size} --pad-b)); | ||
| 241 | padding-inline: 0; | ||
| 242 | } | ||
| 243 | } | ||
| 199 | } | 244 | } |
| 200 | } | 245 | } |
| 201 | } | 246 | } |
diff --git a/src/objects/_button.scss b/src/objects/_button.scss index 1c907c0..27d3726 100644 --- a/src/objects/_button.scss +++ b/src/objects/_button.scss | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | @use 'iro-sass/src/index' as iro; | 2 | @use 'iro-sass/src/index' as iro; |
| 3 | @use '../functions' as fn; | 3 | @use '../functions' as fn; |
| 4 | 4 | ||
| 5 | $sizes: 'sm' 'lg' 'xl' !default; | ||
| 5 | $themes: 'accent' 'negative' !default; | 6 | $themes: 'accent' 'negative' !default; |
| 6 | $static-themes: 'black' 'white' !default; | 7 | $static-themes: 'black' 'white' !default; |
| 7 | 8 | ||
| @@ -54,7 +55,6 @@ $static-themes: 'black' 'white' !default; | |||
| 54 | @include iro.bem-modifier('outline') { | 55 | @include iro.bem-modifier('outline') { |
| 55 | border-color: fn.color(list.join($key, --disabled --outline-border)); | 56 | border-color: fn.color(list.join($key, --disabled --outline-border)); |
| 56 | background-color: transparent; | 57 | background-color: transparent; |
| 57 | box-shadow: none; | ||
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | @include theme(static-#{$theme}); | 60 | @include theme(static-#{$theme}); |
| @@ -255,10 +255,9 @@ $static-themes: 'black' 'white' !default; | |||
| 255 | @include iro.bem-modifier('outline') { | 255 | @include iro.bem-modifier('outline') { |
| 256 | border-color: fn.color(--disabled --outline-border); | 256 | border-color: fn.color(--disabled --outline-border); |
| 257 | background-color: transparent; | 257 | background-color: transparent; |
| 258 | box-shadow: none; | ||
| 259 | } | 258 | } |
| 260 | 259 | ||
| 261 | @each $size in sm lg xl { | 260 | @each $size in $sizes { |
| 262 | @include iro.bem-modifier($size) { | 261 | @include iro.bem-modifier($size) { |
| 263 | padding-block: fn.dim(--#{$size} --pad-b); | 262 | padding-block: fn.dim(--#{$size} --pad-b); |
| 264 | padding-inline: fn.dim(--#{$size} --pad-i); | 263 | padding-inline: fn.dim(--#{$size} --pad-i); |
diff --git a/tpl/objects/action-button.pug b/tpl/objects/action-button.pug index c0d7582..976a646 100644 --- a/tpl/objects/action-button.pug +++ b/tpl/objects/action-button.pug | |||
| @@ -6,9 +6,13 @@ mixin action-button | |||
| 6 | 'o-action-button': true, | 6 | 'o-action-button': true, |
| 7 | 'u-d-block': attributes.block, | 7 | 'u-d-block': attributes.block, |
| 8 | 'o-action-button--quiet': attributes.quiet, | 8 | 'o-action-button--quiet': attributes.quiet, |
| 9 | 'o-action-button--round': attributes.round, | 9 | 'o-action-button--pill': attributes.pill, |
| 10 | 'o-action-button--icon': !!attributes.icon && !block, | ||
| 10 | 'is-selected': attributes.selected | 11 | 'is-selected': attributes.selected |
| 11 | } | 12 | } |
| 13 | if (attributes.size) { | ||
| 14 | classes['o-action-button--' + attributes.size] = true | ||
| 15 | } | ||
| 12 | if (attributes.class) { | 16 | if (attributes.class) { |
| 13 | classes[attributes.class] = true; | 17 | classes[attributes.class] = true; |
| 14 | } | 18 | } |
diff --git a/tpl/views/action-button.pug b/tpl/views/action-button.pug index 8fb4e58..2c94c68 100644 --- a/tpl/views/action-button.pug +++ b/tpl/views/action-button.pug | |||
| @@ -1,31 +1,63 @@ | |||
| 1 | mixin view-action-button | 1 | mixin view-action-button |
| 2 | +view('action-button', 'Action button') | 2 | +view('action-button', 'Action button') |
| 3 | .c-box | 3 | .c-box |
| 4 | +action-button(size='sm')= 'Idle' | ||
| 5 | = ' ' | ||
| 4 | +action-button= 'Idle' | 6 | +action-button= 'Idle' |
| 5 | = ' ' | 7 | = ' ' |
| 6 | +action-button(selected=true)= 'Selected' | 8 | +action-button(size='lg')= 'Idle' |
| 7 | = ' ' | 9 | = ' ' |
| 8 | +action-button(disabled=true)= 'Disabled' | 10 | +action-button(size='xl')= 'Idle' |
| 11 | |||
| 12 | .c-box | ||
| 13 | +action-button(icon='trash' size='sm') | ||
| 9 | = ' ' | 14 | = ' ' |
| 10 | +action-button(selected=true disabled=true)= 'Selected + disabled' | 15 | +action-button(icon='trash') |
| 11 | br | 16 | = ' ' |
| 12 | br | 17 | +action-button(icon='trash' size='lg') |
| 13 | +action-button(icon='trash')= 'Idle' | 18 | = ' ' |
| 19 | +action-button(icon='trash' size='xl') | ||
| 20 | |||
| 21 | .c-box | ||
| 22 | +action-button(pill=true size='sm')= 'Idle' | ||
| 14 | = ' ' | 23 | = ' ' |
| 15 | +action-button(icon='trash' selected=true)= 'Selected' | 24 | +action-button(pill=true)= 'Idle' |
| 16 | = ' ' | 25 | = ' ' |
| 17 | +action-button(icon='trash' disabled=true)= 'Disabled' | 26 | +action-button(pill=true size='lg')= 'Idle' |
| 27 | = ' ' | ||
| 28 | +action-button(pill=true size='xl')= 'Idle' | ||
| 29 | |||
| 30 | .c-box | ||
| 31 | +action-button(pill=true icon='trash' size='sm') | ||
| 32 | = ' ' | ||
| 33 | +action-button(pill=true icon='trash') | ||
| 34 | = ' ' | ||
| 35 | +action-button(pill=true icon='trash' size='lg') | ||
| 36 | = ' ' | ||
| 37 | +action-button(pill=true icon='trash' size='xl') | ||
| 38 | |||
| 39 | .c-box | ||
| 40 | +action-button= 'Label' | ||
| 41 | = ' ' | ||
| 42 | +action-button(icon='trash')= 'Label' | ||
| 18 | = ' ' | 43 | = ' ' |
| 19 | +action-button(icon='trash' selected=true disabled=true)= 'Selected + disabled' | ||
| 20 | br | ||
| 21 | br | ||
| 22 | +action-button(icon='trash') | 44 | +action-button(icon='trash') |
| 45 | |||
| 46 | .c-box | ||
| 47 | +action-button(quiet=true)= 'Label' | ||
| 48 | = ' ' | ||
| 49 | +action-button(quiet=true icon='trash')= 'Label' | ||
| 50 | = ' ' | ||
| 51 | +action-button(quiet=true icon='trash') | ||
| 52 | |||
| 53 | .c-box | ||
| 54 | +action-button= 'Idle' | ||
| 23 | = ' ' | 55 | = ' ' |
| 24 | +action-button(icon='trash' selected=true) | 56 | +action-button(selected=true)= 'Selected' |
| 25 | = ' ' | 57 | = ' ' |
| 26 | +action-button(icon='trash' disabled=true) | 58 | +action-button(disabled=true)= 'Disabled' |
| 27 | = ' ' | 59 | = ' ' |
| 28 | +action-button(icon='trash' selected=true disabled=true) | 60 | +action-button(selected=true disabled=true)= 'Selected + disabled' |
| 29 | 61 | ||
| 30 | .c-box | 62 | .c-box |
| 31 | +action-button(quiet=true )= 'Idle' | 63 | +action-button(quiet=true )= 'Idle' |
| @@ -35,26 +67,21 @@ mixin view-action-button | |||
| 35 | +action-button(quiet=true disabled=true)= 'Disabled' | 67 | +action-button(quiet=true disabled=true)= 'Disabled' |
| 36 | = ' ' | 68 | = ' ' |
| 37 | +action-button(quiet=true selected=true disabled=true)= 'Selected + disabled' | 69 | +action-button(quiet=true selected=true disabled=true)= 'Selected + disabled' |
| 38 | br | 70 | |
| 39 | br | 71 | .c-box |
| 40 | +action-button(quiet=true icon='trash')= 'Idle' | 72 | +action-button(pill=true)= 'Idle' |
| 41 | = ' ' | ||
| 42 | +action-button(quiet=true icon='trash' selected=true)= 'Selected' | ||
| 43 | = ' ' | ||
| 44 | +action-button(quiet=true icon='trash' disabled=true)= 'Disabled' | ||
| 45 | = ' ' | ||
| 46 | +action-button(quiet=true icon='trash' selected=true disabled=true)= 'Selected + disabled' | ||
| 47 | br | ||
| 48 | br | ||
| 49 | +action-button(quiet=true icon='trash') | ||
| 50 | = ' ' | 73 | = ' ' |
| 51 | +action-button(quiet=true icon='trash' selected=true) | 74 | +action-button(pill=true selected=true)= 'Selected' |
| 52 | = ' ' | 75 | = ' ' |
| 53 | +action-button(quiet=true icon='trash' disabled=true) | 76 | +action-button(pill=true disabled=true)= 'Disabled' |
| 54 | = ' ' | 77 | = ' ' |
| 55 | +action-button(quiet=true icon='trash' selected=true disabled=true) | 78 | +action-button(pill=true selected=true disabled=true)= 'Selected + disabled' |
| 56 | 79 | ||
| 57 | .c-box | 80 | .c-box |
| 58 | +action-button= 'Idle' | 81 | +action-button(pill=true quiet=true)= 'Idle' |
| 59 | = ' ' | 82 | = ' ' |
| 60 | +action-button(icon='trash') | 83 | +action-button(pill=true quiet=true selected=true)= 'Selected' |
| 84 | = ' ' | ||
| 85 | +action-button(pill=true quiet=true disabled=true)= 'Disabled' | ||
| 86 | = ' ' | ||
| 87 | +action-button(pill=true quiet=true selected=true disabled=true)= 'Selected + disabled' | ||
