diff options
author | Volpeon <git@volpeon.ink> | 2024-10-26 10:38:06 +0200 |
---|---|---|
committer | Volpeon <git@volpeon.ink> | 2024-10-26 10:38:06 +0200 |
commit | 6d303e5cef9c3a3c77294b79c4907ec69943226f (patch) | |
tree | 8b5ac983cbce581de49647aaf5036d7c1f087ad8 | |
parent | Update (diff) | |
download | iro-design-6d303e5cef9c3a3c77294b79c4907ec69943226f.tar.gz iro-design-6d303e5cef9c3a3c77294b79c4907ec69943226f.tar.bz2 iro-design-6d303e5cef9c3a3c77294b79c4907ec69943226f.zip |
Lightbox fallback without :target
-rw-r--r-- | src/objects/_lightbox.scss | 101 | ||||
-rw-r--r-- | tpl/objects/backdrop.pug | 5 | ||||
-rw-r--r-- | tpl/objects/lightbox.pug | 8 | ||||
-rw-r--r-- | tpl/views/lightbox.pug | 14 |
4 files changed, 60 insertions, 68 deletions
diff --git a/src/objects/_lightbox.scss b/src/objects/_lightbox.scss index 02714d7..5562696 100644 --- a/src/objects/_lightbox.scss +++ b/src/objects/_lightbox.scss | |||
@@ -12,17 +12,8 @@ | |||
12 | @include materialize-at-root(meta.module-variables('vars')); | 12 | @include materialize-at-root(meta.module-variables('vars')); |
13 | 13 | ||
14 | @include bem.object('lightbox') { | 14 | @include bem.object('lightbox') { |
15 | box-sizing: border-box; | 15 | flex: 1 1 auto; |
16 | display: grid; | 16 | min-block-size: 0; |
17 | flex: 1 1 auto; | ||
18 | grid-template-areas: | ||
19 | 'header header header' | ||
20 | 'prev content next' | ||
21 | 'thumbnails thumbnails thumbnails' | ||
22 | 'footer footer footer'; | ||
23 | grid-template-rows: auto minmax(0, 1fr) auto auto; | ||
24 | grid-template-columns: auto minmax(0, 1fr) auto; | ||
25 | min-block-size: 0; | ||
26 | 17 | ||
27 | @include bem.elem('header') { | 18 | @include bem.elem('header') { |
28 | display: flex; | 19 | display: flex; |
@@ -34,56 +25,17 @@ | |||
34 | 25 | ||
35 | @include bem.elem('img') { | 26 | @include bem.elem('img') { |
36 | box-sizing: border-box; | 27 | box-sizing: border-box; |
37 | display: none; | 28 | display: block; |
38 | grid-area: content; | 29 | grid-area: content; |
39 | place-self: center; | 30 | place-self: center; |
40 | max-inline-size: 100%; | 31 | max-inline-size: 100%; |
41 | max-block-size: 100%; | 32 | max-block-size: 80vh; |
42 | padding: props.get(vars.$pad); | 33 | padding: props.get(vars.$pad); |
43 | 34 | margin-inline: auto; | |
44 | @include bem.sibling-elem('img') { | ||
45 | @include bem.modifier('default') { | ||
46 | display: block; | ||
47 | |||
48 | @include bem.next-elem('nav-btn') { | ||
49 | display: block; | ||
50 | |||
51 | @include bem.next-elem('nav-btn') { | ||
52 | display: block; | ||
53 | } | ||
54 | } | ||
55 | } | ||
56 | } | ||
57 | |||
58 | @include bem.multi('&:target', 'is' 'visible') { | ||
59 | display: block; | ||
60 | |||
61 | @include bem.next-elem('nav-btn') { | ||
62 | display: block; | ||
63 | |||
64 | @include bem.next-elem('nav-btn') { | ||
65 | display: block; | ||
66 | } | ||
67 | } | ||
68 | |||
69 | @include bem.sibling-elem('img') { | ||
70 | @include bem.modifier('default') { | ||
71 | display: none; | ||
72 | |||
73 | @include bem.next-elem('nav-btn') { | ||
74 | display: none; | ||
75 | |||
76 | @include bem.next-elem('nav-btn') { | ||
77 | display: none; | ||
78 | } | ||
79 | } | ||
80 | } | ||
81 | } | ||
82 | } | ||
83 | } | 35 | } |
84 | 36 | ||
85 | @include bem.elem('thumbnails') { | 37 | @include bem.elem('thumbnails') { |
86 | display: flex; | 38 | display: none; |
87 | grid-area: thumbnails; | 39 | grid-area: thumbnails; |
88 | gap: props.get(vars.$thumbnail--spacing); | 40 | gap: props.get(vars.$thumbnail--spacing); |
89 | padding: props.get(vars.$pad); | 41 | padding: props.get(vars.$pad); |
@@ -91,14 +43,6 @@ | |||
91 | overflow: auto; | 43 | overflow: auto; |
92 | } | 44 | } |
93 | 45 | ||
94 | @include bem.elem('footer') { | ||
95 | display: flex; | ||
96 | grid-area: footer; | ||
97 | align-items: flex-start; | ||
98 | padding-block: 0 props.get(vars.$pad); | ||
99 | padding-inline: props.get(vars.$pad); | ||
100 | } | ||
101 | |||
102 | @include bem.elem('thumbnail') { | 46 | @include bem.elem('thumbnail') { |
103 | position: relative; | 47 | position: relative; |
104 | flex: 0 0 auto; | 48 | flex: 0 0 auto; |
@@ -163,6 +107,7 @@ | |||
163 | } | 107 | } |
164 | 108 | ||
165 | @include bem.elem('close-btn') { | 109 | @include bem.elem('close-btn') { |
110 | display: none; | ||
166 | flex: 0 0 auto; | 111 | flex: 0 0 auto; |
167 | margin-block-start: calc(-.5 * props.get(vars.$pad)); | 112 | margin-block-start: calc(-.5 * props.get(vars.$pad)); |
168 | margin-inline: auto calc(-.5 * props.get(vars.$pad)); | 113 | margin-inline: auto calc(-.5 * props.get(vars.$pad)); |
@@ -205,6 +150,38 @@ | |||
205 | } | 150 | } |
206 | } | 151 | } |
207 | 152 | ||
153 | @include bem.modifier('interactive') { | ||
154 | display: grid; | ||
155 | grid-template-areas: | ||
156 | 'header header header' | ||
157 | 'prev content next' | ||
158 | 'thumbnails thumbnails thumbnails'; | ||
159 | grid-template-rows: auto minmax(0, 1fr) auto auto; | ||
160 | grid-template-columns: auto minmax(0, 1fr) auto; | ||
161 | |||
162 | @include bem.elem('img') { | ||
163 | display: none; | ||
164 | max-block-size: 100%; | ||
165 | margin-inline: 0; | ||
166 | |||
167 | @include bem.multi('&:target', 'is' 'visible') { | ||
168 | display: block; | ||
169 | } | ||
170 | } | ||
171 | |||
172 | @include bem.elem('thumbnails') { | ||
173 | display: flex; | ||
174 | } | ||
175 | |||
176 | @include bem.elem('close-btn') { | ||
177 | display: block; | ||
178 | } | ||
179 | |||
180 | @include bem.elem('nav-btn') { | ||
181 | display: block; | ||
182 | } | ||
183 | } | ||
184 | |||
208 | @each $theme in map.keys(props.get(vars.$static-themes)) { | 185 | @each $theme in map.keys(props.get(vars.$static-themes)) { |
209 | @include bem.modifier(string.slice($theme, 3)) { | 186 | @include bem.modifier(string.slice($theme, 3)) { |
210 | color: props.get(vars.$static-themes, $theme, --text); | 187 | color: props.get(vars.$static-themes, $theme, --text); |
diff --git a/tpl/objects/backdrop.pug b/tpl/objects/backdrop.pug index 227700c..f577961 100644 --- a/tpl/objects/backdrop.pug +++ b/tpl/objects/backdrop.pug | |||
@@ -8,7 +8,10 @@ mixin backdrop | |||
8 | classes[attributes.class] = true; | 8 | classes[attributes.class] = true; |
9 | } | 9 | } |
10 | 10 | ||
11 | let styles = { width: '100%', 'min-height': '5em', 'max-height': '40em' } | 11 | let styles = { width: '100%', 'min-height': '5em' } |
12 | if (attributes.maxHeight) { | ||
13 | styles['max-height'] = '40em'; | ||
14 | } | ||
12 | if (attributes.pad) { | 15 | if (attributes.pad) { |
13 | styles['padding'] = '2em'; | 16 | styles['padding'] = '2em'; |
14 | } | 17 | } |
diff --git a/tpl/objects/lightbox.pug b/tpl/objects/lightbox.pug index 02a3200..85c468f 100644 --- a/tpl/objects/lightbox.pug +++ b/tpl/objects/lightbox.pug | |||
@@ -4,6 +4,7 @@ mixin lightbox(images) | |||
4 | - | 4 | - |
5 | let classes = { | 5 | let classes = { |
6 | 'o-lightbox': true, | 6 | 'o-lightbox': true, |
7 | 'o-lightbox--interactive': attributes.interactive, | ||
7 | } | 8 | } |
8 | let linksClasses = { | 9 | let linksClasses = { |
9 | 's-links': true, | 10 | 's-links': true, |
@@ -19,15 +20,14 @@ mixin lightbox(images) | |||
19 | div(class=linksClasses) | 20 | div(class=linksClasses) |
20 | block | 21 | block |
21 | +action-button(theme=attributes.theme pill=true quiet=true icon='x' class='o-lightbox__close-btn') | 22 | +action-button(theme=attributes.theme pill=true quiet=true icon='x' class='o-lightbox__close-btn') |
23 | |||
22 | each img, i in images | 24 | each img, i in images |
23 | img.o-lightbox__img(src=images[i] id='image-' + i) | 25 | img(src=images[i] id=('image-' + i) class=`o-lightbox__img ${attributes.interactive && !i ? 'is-visible' : ''}`) |
24 | +action-button(theme=attributes.theme pill=true quiet=true icon='chevron-left' class='o-lightbox__nav-btn o-lightbox__nav-btn--prev') | ||
25 | +action-button(theme=attributes.theme pill=true quiet=true icon='chevron-right' class='o-lightbox__nav-btn o-lightbox__nav-btn--next') | ||
26 | 26 | ||
27 | img.o-lightbox__img.o-lightbox__img--default(src=images[0]) | ||
28 | if images.length > 1 | 27 | if images.length > 1 |
29 | +action-button(theme=attributes.theme pill=true quiet=true icon='chevron-left' class='o-lightbox__nav-btn o-lightbox__nav-btn--prev') | 28 | +action-button(theme=attributes.theme pill=true quiet=true icon='chevron-left' class='o-lightbox__nav-btn o-lightbox__nav-btn--prev') |
30 | +action-button(theme=attributes.theme pill=true quiet=true icon='chevron-right' class='o-lightbox__nav-btn o-lightbox__nav-btn--next') | 29 | +action-button(theme=attributes.theme pill=true quiet=true icon='chevron-right' class='o-lightbox__nav-btn o-lightbox__nav-btn--next') |
30 | |||
31 | .o-lightbox__thumbnails | 31 | .o-lightbox__thumbnails |
32 | each img, i in images | 32 | each img, i in images |
33 | - classes = i === 0 ? 'is-selected' : '' | 33 | - classes = i === 0 ? 'is-selected' : '' |
diff --git a/tpl/views/lightbox.pug b/tpl/views/lightbox.pug index 4eb234a..7e366c0 100644 --- a/tpl/views/lightbox.pug +++ b/tpl/views/lightbox.pug | |||
@@ -1,5 +1,5 @@ | |||
1 | mixin view-lightbox | 1 | mixin view-lightbox |
2 | +view('lightbox', 'Lightbox') | 2 | +view('lightbox', 'Lightbox')(wide=true) |
3 | .c-box | 3 | .c-box |
4 | +lightbox(['avatar.png', 'ava_feralbot.png', 'volpeon_spooky.png']) | 4 | +lightbox(['avatar.png', 'ava_feralbot.png', 'volpeon_spooky.png']) |
5 | = "Let's try multiple links! " | 5 | = "Let's try multiple links! " |
@@ -37,3 +37,15 @@ mixin view-lightbox | |||
37 | = ' ' | 37 | = ' ' |
38 | a(href="https://mk.vulpes.one/files/081e0684-08dc-4a42-b810-b0ac63ec7d06") | 38 | a(href="https://mk.vulpes.one/files/081e0684-08dc-4a42-b810-b0ac63ec7d06") |
39 | = "https://mk.vulpes.one/files/081e0684-08dc-4a42-b810-b0ac63ec7d06" | 39 | = "https://mk.vulpes.one/files/081e0684-08dc-4a42-b810-b0ac63ec7d06" |
40 | |||
41 | +backdrop(maxHeight=true) | ||
42 | +lightbox(['avatar.png', 'ava_feralbot.png', 'volpeon_spooky.png'])(theme='static-white' interactive=true) | ||
43 | = "Let's try multiple links! " | ||
44 | a(href="https://mk.vulpes.one/files/3023f361-124a-4c80-bb69-9535e47c2925") | ||
45 | = "https://mk.vulpes.one/files/3023f361-124a-4c80-bb69-9535e47c2925" | ||
46 | = ' ' | ||
47 | a(href="https://mk.vulpes.one/files/741dcfd3-6a26-48ae-8985-d0c3ccca016c") | ||
48 | = "https://mk.vulpes.one/files/741dcfd3-6a26-48ae-8985-d0c3ccca016c" | ||
49 | = ' ' | ||
50 | a(href="https://mk.vulpes.one/files/081e0684-08dc-4a42-b810-b0ac63ec7d06") | ||
51 | = "https://mk.vulpes.one/files/081e0684-08dc-4a42-b810-b0ac63ec7d06" | ||