From 98c7f824e80eeeb4344d3c528d54f639ec4158ce Mon Sep 17 00:00:00 2001 From: Volpeon Date: Mon, 28 Feb 2022 14:03:13 +0100 Subject: Added badge --- src/_objects.scss | 1 + src/objects/_badge.scss | 41 +++++++++++++++++++++++++++++++++++++++++ tpl/index.pug | 11 +++++++++++ tpl/objects/badge.pug | 11 +++++++++++ 4 files changed, 64 insertions(+) create mode 100644 src/objects/_badge.scss create mode 100644 tpl/objects/badge.pug diff --git a/src/_objects.scss b/src/_objects.scss index 1b23d44..4049101 100644 --- a/src/_objects.scss +++ b/src/_objects.scss @@ -1,6 +1,7 @@ @use 'objects/icon'; @use 'objects/heading'; @use 'objects/rule'; +@use 'objects/badge'; @use 'objects/button'; @use 'objects/text-field'; @use 'objects/field-label'; diff --git a/src/objects/_badge.scss b/src/objects/_badge.scss new file mode 100644 index 0000000..cb35d39 --- /dev/null +++ b/src/objects/_badge.scss @@ -0,0 +1,41 @@ +@use 'iro-sass/src/index' as iro; +@use '../functions' as fn; + +@include iro.props-namespace('badge') { + @include iro.props-store(( + --dims: ( + --pad-x: fn.global-dim(--size --75), + --pad-y: fn.global-dim(--size --50), + --rounding: 3px, + --font-size: fn.global-dim(--font-size --75), + ), + ), 'dims'); + + @include iro.props-store(( + --colors: ( + --bg: fn.global-color(--obj-hi), + --label: fn.global-color(--fg-lo), + --accent: ( + --bg: fn.global-color(--accent --primary --bg), + --label: fn.global-color(--accent --primary --fg), + ) + ), + ), 'colors'); + + @include iro.bem-object(iro.props-namespace()) { + display: inline-block; + padding: fn.dim(--pad-y) fn.dim(--pad-x); + border-radius: fn.dim(--rounding); + background-color: fn.color(--bg); + color: fn.color(--label); + font-size: fn.dim(--font-size); + font-weight: 500; + line-height: 1; + text-align: center; + + @include iro.bem-modifier('accent') { + background-color: fn.color(--accent --bg); + color: fn.color(--accent --label); + } + } +} diff --git a/tpl/index.pug b/tpl/index.pug index ed538df..4926889 100644 --- a/tpl/index.pug +++ b/tpl/index.pug @@ -5,6 +5,7 @@ include layouts/container.pug include objects/heading.pug include objects/rule.pug +include objects/badge.pug include objects/button.pug include objects/text-field.pug include objects/field-label.pug @@ -98,6 +99,16 @@ html //----------------------------------------- + +h1-heading('xl')= 'Badge' + +rule('medium') + + +box + +badge= '100' + = ' ' + +badge('accent')= 'new' + + //----------------------------------------- + +h1-heading('xl')= 'Button' +rule('medium') diff --git a/tpl/objects/badge.pug b/tpl/objects/badge.pug new file mode 100644 index 0000000..e0d8c44 --- /dev/null +++ b/tpl/objects/badge.pug @@ -0,0 +1,11 @@ +mixin badge(variant) + - + let classes = { + 'o-badge': true, + } + if (variant) { + classes['o-badge--' + variant] = true + } + + div(class=classes) + block -- cgit v1.2.3-70-g09d2