From 9691ccf48f64dd0fac669ae51943907cc8da9b78 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Sun, 6 Feb 2022 20:23:11 +0100 Subject: Added status indicator and avatar --- src/objects/_avatar.scss | 89 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 src/objects/_avatar.scss (limited to 'src/objects/_avatar.scss') diff --git a/src/objects/_avatar.scss b/src/objects/_avatar.scss new file mode 100644 index 0000000..3bdfddc --- /dev/null +++ b/src/objects/_avatar.scss @@ -0,0 +1,89 @@ +@use 'iro-sass/src/index' as iro; +@use '../functions' as fn; + +@include iro.props-namespace('avatar') { + @include iro.props-store(( + --dims: ( + --size: iro.fn-px-to-rem(40px), + --size-sm: iro.fn-px-to-rem(30px), + --size-xs: iro.fn-px-to-rem(20px), + --indicator-size: fn.foreign-dim(--status-indicator, --size), + --indicator-spacing: iro.fn-px-to-rem(3px), + --rounding: 25%, + ), + ), 'dims'); + + @include iro.props-store(( + --colors: ( + --h: 354, + --s: 44%, + --l: 45%, + ), + ), 'colors'); + + @include iro.bem-object(iro.props-namespace()) { + display: inline-block; + position: relative; + font-size: 1rem; + font-style: normal; + + @include iro.bem-elem('status') { + position: absolute; + right: 0; + bottom: 0; + + @include iro.bem-next-elem('content') { + mask-image: radial-gradient( + circle calc(.5 * fn.dim(--indicator-size) + fn.dim(--indicator-spacing)) at + calc(100% - .5 * fn.dim(--indicator-size)) + calc(100% - .5 * fn.dim(--indicator-size)), + transparent 95%, + #fff + ); + } + } + + @include iro.bem-elem('content') { + display: block; + width: fn.dim(--size); + height: fn.dim(--size); + border-radius: fn.dim(--rounding); + background-color: hsl(fn.color(--h), fn.color(--s), fn.color(--l)); + color: #fff; + line-height: fn.dim(--size); + text-align: center; + } + + @include iro.bem-modifier('circle') { + @include iro.bem-elem('content') { + border-radius: 100%; + } + } + + @include iro.bem-modifier('placeholder') { + @include iro.bem-elem('content') { + background-color: hsl(0, 0%, fn.color(--l)); + } + } + + @include iro.bem-modifier('sm') { + font-size: iro.fn-px-to-rem(13px); + + @include iro.bem-elem('content') { + width: fn.dim(--size-sm); + height: fn.dim(--size-sm); + line-height: fn.dim(--size-sm); + } + } + + @include iro.bem-modifier('xs') { + font-size: iro.fn-px-to-rem(12px); + + @include iro.bem-elem('content') { + width: fn.dim(--size-xs); + height: fn.dim(--size-xs); + line-height: fn.dim(--size-xs); + } + } + } +} -- cgit v1.2.3-70-g09d2