From 27616aff3eaa1fb8baecfcfec1f0542473d1fb36 Mon Sep 17 00:00:00 2001 From: Volpeon Date: Tue, 15 Feb 2022 18:57:05 +0100 Subject: Added lightbox --- src/_apply-vars.scss | 6 ++++++ src/_objects.scss | 1 + src/_utils.scss | 5 +++++ src/layouts/_container.scss | 5 ----- src/objects/_backdrop.scss | 1 + src/objects/_lightbox.scss | 35 +++++++++++++++++++++++++++++++++++ tpl/index.pug | 10 ++++++++++ tpl/layouts/container.pug | 2 +- tpl/objects/backdrop.pug | 12 +++++++++++- tpl/objects/lightbox.pug | 5 +++++ 10 files changed, 75 insertions(+), 7 deletions(-) create mode 100644 src/objects/_lightbox.scss create mode 100644 tpl/objects/lightbox.pug diff --git a/src/_apply-vars.scss b/src/_apply-vars.scss index 10bcb5c..66ad9b7 100644 --- a/src/_apply-vars.scss +++ b/src/_apply-vars.scss @@ -28,3 +28,9 @@ @include iro.props-assign('palette-dark-raised'); } } + +@include iro.bem-theme('dark') { + @include iro.props-assign('colors'); + @include iro.props-assign('colors-dark'); + @include iro.props-assign('palette-dark'); +} diff --git a/src/_objects.scss b/src/_objects.scss index 45415f1..1b23d44 100644 --- a/src/_objects.scss +++ b/src/_objects.scss @@ -14,3 +14,4 @@ @use 'objects/menu'; @use 'objects/backdrop'; @use 'objects/dialog'; +@use 'objects/lightbox'; diff --git a/src/_utils.scss b/src/_utils.scss index 89aabd2..69885ba 100644 --- a/src/_utils.scss +++ b/src/_utils.scss @@ -34,6 +34,11 @@ $dirs: ( position: relative; } +@include iro.bem-utility('themed') { + background-color: fn.global-color(--bg); + color: fn.global-color(--fg); +} + @each $dir, $suffix in $dirs { @include iro.bem-utility('m#{$dir}-auto') { margin#{$suffix}: auto; diff --git a/src/layouts/_container.scss b/src/layouts/_container.scss index b8fc879..26ba16f 100644 --- a/src/layouts/_container.scss +++ b/src/layouts/_container.scss @@ -79,11 +79,6 @@ } } - @include iro.bem-modifier('themed') { - background-color: fn.global-color(--bg); - color: fn.global-color(--fg); - } - @include iro.bem-modifier('in-page') { margin-top: fn.dim(--in-page-spacing-y); margin-bottom: fn.dim(--in-page-spacing-y); diff --git a/src/objects/_backdrop.scss b/src/objects/_backdrop.scss index 5957ffa..9ab140e 100644 --- a/src/objects/_backdrop.scss +++ b/src/objects/_backdrop.scss @@ -40,5 +40,6 @@ flex-direction: column; padding: fn.dim(--pad-y) fn.dim(--pad-x); background-color: fn.color(--bg); + color: fn.global-color(--fg); } } diff --git a/src/objects/_lightbox.scss b/src/objects/_lightbox.scss new file mode 100644 index 0000000..3ba9744 --- /dev/null +++ b/src/objects/_lightbox.scss @@ -0,0 +1,35 @@ +@use 'iro-sass/src/index' as iro; +@use '../functions' as fn; + +@include iro.props-namespace('lightbox') { + @include iro.props-store(( + --dims: ( + + ), + ), 'dims'); + + @include iro.bem-object(iro.props-namespace()) { + display: contents; + + @include iro.bem-elem('header') { + display: flex; + box-sizing: border-box; + flex: 0 0 auto; + align-items: center; + width: 100%; + } + + @include iro.bem-elem('img') { + align-self: center; + max-width: 100%; + min-height: 0; + max-height: 100%; + margin-top: auto; + margin-bottom: auto; + } + + @include iro.bem-elem('close-btn') { + margin-left: auto; + } + } +} diff --git a/tpl/index.pug b/tpl/index.pug index a073280..fde71fd 100644 --- a/tpl/index.pug +++ b/tpl/index.pug @@ -19,6 +19,7 @@ include objects/action-menu.pug include objects/menu.pug include objects/backdrop.pug include objects/dialog.pug +include objects/lightbox.pug mixin box +container(padX=true padY=true inPage=true theme="raised") @@ -547,4 +548,13 @@ html p= loremIpsum p= loremIpsum + //----------------------------------------- + + +h1-heading('xl')= 'Lightbox' + +rule('medium') + + +box + +backdrop(class='t-dark' center=true) + +lightbox('avatar.png') + diff --git a/tpl/layouts/container.pug b/tpl/layouts/container.pug index c64de11..0c9b6ec 100644 --- a/tpl/layouts/container.pug +++ b/tpl/layouts/container.pug @@ -7,7 +7,7 @@ mixin container 'l-container--narrow': attributes.narrow, 'l-container--sm-narrow': attributes.smNarrow, 'l-container--in-page': attributes.inPage, - 'l-container--themed': !!attributes.theme + 'u-themed': !!attributes.theme } if (!!attributes.theme) { classes['t-' + attributes.theme] = true diff --git a/tpl/objects/backdrop.pug b/tpl/objects/backdrop.pug index 5d0c9e8..3de1f99 100644 --- a/tpl/objects/backdrop.pug +++ b/tpl/objects/backdrop.pug @@ -1,3 +1,13 @@ mixin backdrop - .o-backdrop.u-p-static(style={ width: '100%', 'min-height': '5em', 'max-height': '40em' }) + - + let classes = { + 'o-backdrop': true, + 'u-p-relative': true, + 'o-backdrop--center': attributes.center + } + if (attributes.class) { + classes[attributes.class] = true; + } + + div(class=classes, style={ width: '100%', 'min-height': '5em', 'max-height': '40em' }) block diff --git a/tpl/objects/lightbox.pug b/tpl/objects/lightbox.pug new file mode 100644 index 0000000..ba68299 --- /dev/null +++ b/tpl/objects/lightbox.pug @@ -0,0 +1,5 @@ +mixin lightbox(src) + .o-lightbox + header.o-lightbox__header + +action-button(round=true quiet=true icon='x' class='o-lightbox__close-btn') + img.o-lightbox__img(src=src) -- cgit v1.2.3-70-g09d2