diff options
| -rw-r--r-- | src/index.scss | 3 | ||||
| -rw-r--r-- | src/objects/_button.scss | 173 | ||||
| -rw-r--r-- | tpl/index.pug | 47 | ||||
| -rw-r--r-- | tpl/layouts/container.pug | 6 | ||||
| -rw-r--r-- | tpl/objects/button.pug | 16 |
5 files changed, 235 insertions, 10 deletions
diff --git a/src/index.scss b/src/index.scss index 292785d..1d21d45 100644 --- a/src/index.scss +++ b/src/index.scss | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | 8 | ||
| 9 | @import 'objects/heading'; | 9 | @import 'objects/heading'; |
| 10 | @import 'objects/rule'; | 10 | @import 'objects/rule'; |
| 11 | @import 'objects/button'; | ||
| 11 | 12 | ||
| 12 | :root { | 13 | :root { |
| 13 | @include iro.props-assign; | 14 | @include iro.props-assign; |
| @@ -24,6 +25,7 @@ | |||
| 24 | } | 25 | } |
| 25 | 26 | ||
| 26 | @include iro.bem-theme('raised') { | 27 | @include iro.bem-theme('raised') { |
| 28 | @include iro.props-assign($root: --colors, $prefix: --colors); | ||
| 27 | @include iro.props-assign('light-raised'); | 29 | @include iro.props-assign('light-raised'); |
| 28 | 30 | ||
| 29 | @include iro.bem-multi('at-theme' 'grayscale', 'theme' 'grayscale') { | 31 | @include iro.bem-multi('at-theme' 'grayscale', 'theme' 'grayscale') { |
| @@ -39,6 +41,7 @@ | |||
| 39 | } | 41 | } |
| 40 | 42 | ||
| 41 | @include iro.bem-theme('raised') { | 43 | @include iro.bem-theme('raised') { |
| 44 | @include iro.props-assign('dark', $root: --colors, $prefix: --colors); | ||
| 42 | @include iro.props-assign('dark-raised'); | 45 | @include iro.props-assign('dark-raised'); |
| 43 | 46 | ||
| 44 | @include iro.bem-multi('at-theme' 'grayscale', 'theme' 'grayscale') { | 47 | @include iro.bem-multi('at-theme' 'grayscale', 'theme' 'grayscale') { |
diff --git a/src/objects/_button.scss b/src/objects/_button.scss new file mode 100644 index 0000000..5da1fbd --- /dev/null +++ b/src/objects/_button.scss | |||
| @@ -0,0 +1,173 @@ | |||
| 1 | @use 'iro-sass/src/index' as iro; | ||
| 2 | @use '../vars'; | ||
| 3 | @use '../mixins/typography'; | ||
| 4 | |||
| 5 | @mixin button-variant($variant) { | ||
| 6 | border-color: iro.props-get((--colors, --#{$variant}, --bg)); | ||
| 7 | background-color: iro.props-get((--colors, --#{$variant}, --bg)); | ||
| 8 | box-shadow: iro.props-get((--colors, --#{$variant}, --shadow)); | ||
| 9 | color: iro.props-get((--colors, --#{$variant}, --label)); | ||
| 10 | |||
| 11 | @include iro.bem-multi('&:link, &:visited', 'modifier' 'native') { | ||
| 12 | &:hover { | ||
| 13 | border-color: iro.props-get((--colors, --#{$variant}, --hover, --bg)); | ||
| 14 | background-color: iro.props-get((--colors, --#{$variant}, --hover, --bg)); | ||
| 15 | box-shadow: iro.props-get((--colors, --#{$variant}, --hover, --shadow)); | ||
| 16 | color: iro.props-get((--colors, --#{$variant}, --hover, --label)); | ||
| 17 | } | ||
| 18 | |||
| 19 | &:active { | ||
| 20 | border-color: iro.props-get((--colors, --#{$variant}, --active, --bg)); | ||
| 21 | background-color: iro.props-get((--colors, --#{$variant}, --active, --bg)); | ||
| 22 | box-shadow: iro.props-get((--colors, --#{$variant}, --active, --shadow)); | ||
| 23 | color: iro.props-get((--colors, --#{$variant}, --active, --label)); | ||
| 24 | } | ||
| 25 | } | ||
| 26 | |||
| 27 | @include iro.bem-modifier('outline') { | ||
| 28 | background-color: transparent; | ||
| 29 | box-shadow: none; | ||
| 30 | color: iro.props-get((--colors, --#{$variant}, --outline-label)); | ||
| 31 | } | ||
| 32 | } | ||
| 33 | |||
| 34 | @include iro.props-namespace('button') { | ||
| 35 | @include iro.props-store(( | ||
| 36 | --dims: ( | ||
| 37 | --padding-x: 1.2rem, | ||
| 38 | --padding-y: .5rem, | ||
| 39 | --rounding: 10em, | ||
| 40 | ), | ||
| 41 | --colors: ( | ||
| 42 | --any: ( | ||
| 43 | --disabled: ( | ||
| 44 | --bg: iro.props-get(--colors --obj-hi, $global: true), | ||
| 45 | --label: iro.props-get(--colors --fg-hi3, $global: true), | ||
| 46 | --shadow: 0 0 0 0 transparent, | ||
| 47 | ), | ||
| 48 | --key-focus: ( | ||
| 49 | --bg: transparent, | ||
| 50 | --label: iro.props-get(--colors --accent --primary-lo2, $global: true), | ||
| 51 | --border: iro.props-get(--colors --focus --fill, $global: true), | ||
| 52 | --shadow: iro.props-get(--colors --focus --shadow, $global: true), | ||
| 53 | ), | ||
| 54 | ), | ||
| 55 | --accent: ( | ||
| 56 | --bg: iro.props-get(--colors --accent --primary, $global: true), | ||
| 57 | --label: iro.props-get(--colors --accent --primary-fg, $global: true), | ||
| 58 | --outline-label: iro.props-get(--colors --accent --primary-lo2, $global: true), | ||
| 59 | --shadow: 0 0 0 0 transparent, | ||
| 60 | |||
| 61 | --hover: ( | ||
| 62 | --bg: iro.props-get(--colors --accent --primary-lo, $global: true), | ||
| 63 | --label: iro.props-get(--colors --accent --primary-fg, $global: true), | ||
| 64 | --shadow: 0 0 0 0 transparent, | ||
| 65 | ), | ||
| 66 | --active: ( | ||
| 67 | --bg: iro.props-get(--colors --accent --primary-lo2, $global: true), | ||
| 68 | --label: iro.props-get(--colors --accent --primary-fg, $global: true), | ||
| 69 | --shadow: 0 0 0 0 transparent, | ||
| 70 | ), | ||
| 71 | ), | ||
| 72 | --primary: ( | ||
| 73 | --bg: iro.props-get(--colors --fg, $global: true), | ||
| 74 | --label: iro.props-get(--colors --bg-hi2, $global: true), | ||
| 75 | --outline-label: iro.props-get(--colors --fg, $global: true), | ||
| 76 | --shadow: 0 0 0 0 transparent, | ||
| 77 | |||
| 78 | --hover: ( | ||
| 79 | --bg: iro.props-get(--colors --fg-lo, $global: true), | ||
| 80 | --label: iro.props-get(--colors --bg-hi2, $global: true), | ||
| 81 | --shadow: 0 0 0 0 transparent, | ||
| 82 | ), | ||
| 83 | --active: ( | ||
| 84 | --bg: iro.props-get(--colors --fg-lo, $global: true), | ||
| 85 | --label: iro.props-get(--colors --bg-hi2, $global: true), | ||
| 86 | --shadow: 0 0 0 0 transparent, | ||
| 87 | ), | ||
| 88 | ), | ||
| 89 | --secondary: ( | ||
| 90 | --bg: iro.props-get(--colors --obj-hi, $global: true), | ||
| 91 | --label: iro.props-get(--colors --fg, $global: true), | ||
| 92 | --outline-label: iro.props-get(--colors --fg, $global: true), | ||
| 93 | --shadow: 0 0 0 0 transparent, | ||
| 94 | |||
| 95 | --hover: ( | ||
| 96 | --bg: iro.props-get(--colors --obj, $global: true), | ||
| 97 | --label: iro.props-get(--colors --fg-lo, $global: true), | ||
| 98 | --shadow: 0 0 0 0 transparent, | ||
| 99 | ), | ||
| 100 | --active: ( | ||
| 101 | --bg: iro.props-get(--colors --obj-lo, $global: true), | ||
| 102 | --label: iro.props-get(--colors --fg-lo, $global: true), | ||
| 103 | --shadow: 0 0 0 0 transparent, | ||
| 104 | ), | ||
| 105 | ), | ||
| 106 | ), | ||
| 107 | )); | ||
| 108 | |||
| 109 | @include iro.bem-object(iro.props-namespace()) { | ||
| 110 | @include typography.set-font(vars.$font--main, (weight: 500)); | ||
| 111 | |||
| 112 | display: inline-block; | ||
| 113 | padding: iro.props-get(--dims --padding-y) iro.props-get(--dims --padding-x); | ||
| 114 | border: 2px solid transparent; | ||
| 115 | border-radius: iro.props-get(--dims --rounding); | ||
| 116 | line-height: 1; | ||
| 117 | text-align: center; | ||
| 118 | text-decoration: none; | ||
| 119 | |||
| 120 | @include iro.bem-modifier('block') { | ||
| 121 | display: block; | ||
| 122 | } | ||
| 123 | |||
| 124 | @include iro.bem-modifier('native') { | ||
| 125 | @include iro.bem-modifier('block') { | ||
| 126 | box-sizing: border-box; | ||
| 127 | width: 100%; | ||
| 128 | } | ||
| 129 | } | ||
| 130 | |||
| 131 | @include button-variant('secondary'); | ||
| 132 | |||
| 133 | @each $mod in ('accent' 'primary' 'secondary') { | ||
| 134 | @if $mod != 'secondary' { | ||
| 135 | @include iro.bem-modifier($mod) { | ||
| 136 | // sass-lint:disable-block function-name-format | ||
| 137 | @include button-variant($mod); | ||
| 138 | } | ||
| 139 | } | ||
| 140 | } | ||
| 141 | |||
| 142 | @include iro.bem-at-theme('keyboard') { | ||
| 143 | &:focus { | ||
| 144 | border-color: iro.props-get(--colors --any --key-focus --border); | ||
| 145 | background-color: iro.props-get(--colors --any --key-focus --bg); | ||
| 146 | box-shadow: iro.props-get(--colors --any --key-focus --shadow); | ||
| 147 | color: iro.props-get(--colors --any --key-focus --label); | ||
| 148 | } | ||
| 149 | } | ||
| 150 | |||
| 151 | @include iro.bem-is('disabled') { | ||
| 152 | border-color: iro.props-get(--colors --any --disabled --bg); | ||
| 153 | background-color: iro.props-get(--colors --any --disabled --bg); | ||
| 154 | box-shadow: iro.props-get(--colors --any --disabled --shadow); | ||
| 155 | color: iro.props-get(--colors --any --disabled --label); | ||
| 156 | |||
| 157 | @include iro.bem-multi('&:link, &:visited', 'modifier' 'native') { | ||
| 158 | &:hover, | ||
| 159 | &:active { | ||
| 160 | border-color: iro.props-get(--colors --any --disabled --bg); | ||
| 161 | background-color: iro.props-get(--colors --any --disabled --bg); | ||
| 162 | box-shadow: iro.props-get(--colors --any --disabled --shadow); | ||
| 163 | color: iro.props-get(--colors --any --disabled --label); | ||
| 164 | } | ||
| 165 | } | ||
| 166 | |||
| 167 | @include iro.bem-modifier('outline') { | ||
| 168 | background-color: transparent; | ||
| 169 | box-shadow: none; | ||
| 170 | } | ||
| 171 | } | ||
| 172 | } | ||
| 173 | } | ||
diff --git a/tpl/index.pug b/tpl/index.pug index c63e9f1..47dbc55 100644 --- a/tpl/index.pug +++ b/tpl/index.pug | |||
| @@ -2,13 +2,14 @@ | |||
| 2 | let loremIpsum = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat' | 2 | let loremIpsum = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat' |
| 3 | 3 | ||
| 4 | include layouts/container.pug | 4 | include layouts/container.pug |
| 5 | |||
| 5 | include objects/heading.pug | 6 | include objects/heading.pug |
| 6 | include objects/rule.pug | 7 | include objects/rule.pug |
| 8 | include objects/button.pug | ||
| 7 | 9 | ||
| 8 | mixin box | 10 | mixin box |
| 9 | .t-raised | 11 | +container(padX=true padY=true inPage=true theme="raised") |
| 10 | +container(padH=true padV=true inPage=true themed=true) | 12 | block |
| 11 | block | ||
| 12 | 13 | ||
| 13 | 14 | ||
| 14 | doctype html | 15 | doctype html |
| @@ -17,11 +18,11 @@ html | |||
| 17 | meta(charset='utf-8') | 18 | meta(charset='utf-8') |
| 18 | meta(name='viewport' content='width=device-width, initial-scale=1') | 19 | meta(name='viewport' content='width=device-width, initial-scale=1') |
| 19 | title iro-design | 20 | title iro-design |
| 20 | link(rel="stylesheet", href="style.css") | 21 | link(rel="stylesheet" href="style.css") |
| 21 | script(src="script.js") | 22 | script(src="script.js") |
| 22 | 23 | ||
| 23 | body(class='t-lighter') | 24 | body(class='t-lighter') |
| 24 | +container(padH=true padV=true narrow=true) | 25 | +container(padX=true padY=true narrow=true) |
| 25 | 26 | ||
| 26 | +h1-heading(level='xl')= 'Heading' | 27 | +h1-heading(level='xl')= 'Heading' |
| 27 | +rule(level='medium') | 28 | +rule(level='medium') |
| @@ -58,3 +59,35 @@ html | |||
| 58 | +rule(level='strong')= 'Strong' | 59 | +rule(level='strong')= 'Strong' |
| 59 | +rule(level='medium')= 'Medium' | 60 | +rule(level='medium')= 'Medium' |
| 60 | +rule(level='faint')= 'Faint' | 61 | +rule(level='faint')= 'Faint' |
| 62 | |||
| 63 | //----------------------------------------- | ||
| 64 | |||
| 65 | +h1-heading(level='xl')= 'Button' | ||
| 66 | +rule(level='medium') | ||
| 67 | |||
| 68 | +box | ||
| 69 | +a-button(variant='accent')= 'Button' | ||
| 70 | = ' ' | ||
| 71 | +a-button(variant='accent' disabled=true)= 'Button' | ||
| 72 | = ' ' | ||
| 73 | +a-button(variant='accent' outline=true)= 'Button' | ||
| 74 | = ' ' | ||
| 75 | +a-button(variant='accent' outline=true disabled=true)= 'Button' | ||
| 76 | br | ||
| 77 | br | ||
| 78 | +a-button(variant='primary')= 'Button' | ||
| 79 | = ' ' | ||
| 80 | +a-button(variant='primary' disabled=true)= 'Button' | ||
| 81 | = ' ' | ||
| 82 | +a-button(variant='primary' outline=true)= 'Button' | ||
| 83 | = ' ' | ||
| 84 | +a-button(variant='primary' outline=true disabled=true)= 'Button' | ||
| 85 | br | ||
| 86 | br | ||
| 87 | +a-button(variant='secondary')= 'Button' | ||
| 88 | = ' ' | ||
| 89 | +a-button(variant='secondary' disabled=true)= 'Button' | ||
| 90 | = ' ' | ||
| 91 | +a-button(variant='secondary' outline=true)= 'Button' | ||
| 92 | = ' ' | ||
| 93 | +a-button(variant='secondary' outline=true disabled=true)= 'Button' | ||
diff --git a/tpl/layouts/container.pug b/tpl/layouts/container.pug index 9dde2d6..c64de11 100644 --- a/tpl/layouts/container.pug +++ b/tpl/layouts/container.pug | |||
| @@ -2,12 +2,12 @@ mixin container | |||
| 2 | - | 2 | - |
| 3 | let classes = { | 3 | let classes = { |
| 4 | 'l-container': true, | 4 | 'l-container': true, |
| 5 | 'l-container--pad-h': attributes.padH, | 5 | 'l-container--pad-x': attributes.padX, |
| 6 | 'l-container--pad-v': attributes.padV, | 6 | 'l-container--pad-y': attributes.padY, |
| 7 | 'l-container--narrow': attributes.narrow, | 7 | 'l-container--narrow': attributes.narrow, |
| 8 | 'l-container--sm-narrow': attributes.smNarrow, | 8 | 'l-container--sm-narrow': attributes.smNarrow, |
| 9 | 'l-container--in-page': attributes.inPage, | 9 | 'l-container--in-page': attributes.inPage, |
| 10 | 'l-container--themed': attributes.themed | 10 | 'l-container--themed': !!attributes.theme |
| 11 | } | 11 | } |
| 12 | if (!!attributes.theme) { | 12 | if (!!attributes.theme) { |
| 13 | classes['t-' + attributes.theme] = true | 13 | classes['t-' + attributes.theme] = true |
diff --git a/tpl/objects/button.pug b/tpl/objects/button.pug new file mode 100644 index 0000000..243ff58 --- /dev/null +++ b/tpl/objects/button.pug | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | mixin a-button | ||
| 2 | - | ||
| 3 | let classes = { | ||
| 4 | 'o-button': true, | ||
| 5 | 'o-button--block': attributes.block, | ||
| 6 | 'o-button--outline': attributes.outline, | ||
| 7 | 'is-disabled': attributes.disabled | ||
| 8 | } | ||
| 9 | if (attributes.variant) { | ||
| 10 | classes['o-button--' + attributes.variant] = true | ||
| 11 | } | ||
| 12 | |||
| 13 | let href = attributes.disabled ? null : '#'; | ||
| 14 | |||
| 15 | a(class=classes href=href) | ||
| 16 | block | ||
