visualci-gallery 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,434 @@
1
+ /* visualci-gallery's default look. Each site keeps its own through the --vg-* variables: set them on .vg or any
2
+ * element around it to the site's colours, radii and type. The defaults sit on the root at no specificity, so any
3
+ * value a site sets wins, and they follow the text colour and the page's color-scheme (a custom property's
4
+ * currentColor is resolved where it's used).
5
+ *
6
+ * Each card holds every variant of its screen; only the chosen theme and size show (hidden lazy images never load).
7
+ * Before the script runs, the theme follows <html data-theme>, else the reader's setting. */
8
+ :where(:root) {
9
+ --vg-ink: currentColor;
10
+ --vg-ink-2: currentColor;
11
+ --vg-muted: color-mix(in srgb, currentColor 65%, transparent);
12
+ --vg-paper: Canvas;
13
+ --vg-paper-2: color-mix(in srgb, currentColor 5%, Canvas);
14
+ --vg-rule: color-mix(in srgb, currentColor 16%, transparent);
15
+ --vg-accent: LinkText;
16
+ --vg-radius-sm: 4px;
17
+ --vg-radius-md: 8px;
18
+ --vg-radius-lg: 12px;
19
+ --vg-shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 8px 24px rgb(0 0 0 / 0.08);
20
+ --vg-backdrop: rgb(0 0 0 / 0.6);
21
+ /* The strip's scroll buttons, over a screenshot. */
22
+ --vg-float-shadow: 0 0 0 1px rgb(0 0 0 / 0.08), 0 2px 10px rgb(0 0 0 / 0.3);
23
+ --vg-rule-width: 1px;
24
+ --vg-gap: 1.5rem;
25
+ --vg-card-min: 22rem;
26
+ --vg-phone-card-min: 9.5rem;
27
+ --vg-desktop-ratio: 1440 / 900;
28
+ --vg-phone-ratio: 390 / 844;
29
+ --vg-contain-padding: 7%;
30
+ --vg-contain-shadow: drop-shadow(0 0.5rem 1rem rgb(0 0 0 / 0.18));
31
+ --vg-title-size: 2rem;
32
+ --vg-group-title-size: 1.5rem;
33
+ --vg-card-title-size: 1.125rem;
34
+ --vg-small: 0.875rem;
35
+ --vg-duration: 150ms;
36
+ --vg-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
37
+ }
38
+ .vg {
39
+ display: block;
40
+ min-width: 0;
41
+ }
42
+ .vg *,
43
+ .vg *::before,
44
+ .vg *::after {
45
+ box-sizing: border-box;
46
+ }
47
+ .vg :where(h1, h2, h3, h4, h5, h6, p, ul, li) {
48
+ margin: 0;
49
+ }
50
+ /* A host page's article styles (`.content h2 { margin: … }`, `.content ul { padding-left: … }`, `.content li + li`)
51
+ * outrank an element reset, so each of the gallery's own elements is set again by class, inside .vg. */
52
+ .vg .vg-title,
53
+ .vg .vg-group-title,
54
+ .vg .vg-card,
55
+ .vg .vg-card-title,
56
+ .vg .vg-caption,
57
+ .vg .vg-box-title,
58
+ .vg .vg-see-all,
59
+ .vg .vg-credit {
60
+ margin: 0;
61
+ padding: 0;
62
+ }
63
+ .vg .vg-grid {
64
+ margin: 0;
65
+ padding: 0;
66
+ list-style: none;
67
+ }
68
+ /* Long names break rather than push the page sideways. */
69
+ .vg :where(.vg-title, .vg-group-title, .vg-card-title, .vg-caption, .vg-box-title, [role="tab"]) {
70
+ overflow-wrap: anywhere;
71
+ }
72
+
73
+ .vg .vg-title {
74
+ font-size: var(--vg-title-size);
75
+ font-weight: 650;
76
+ margin-bottom: calc(var(--vg-gap) * 1.33);
77
+ }
78
+
79
+ .vg-tabs {
80
+ display: flex;
81
+ flex-wrap: wrap;
82
+ gap: 0.25rem;
83
+ border-bottom: var(--vg-rule-width) solid var(--vg-rule);
84
+ margin-bottom: calc(var(--vg-gap) * 1.33);
85
+ }
86
+ .vg-tabs [role="tab"] {
87
+ font: inherit;
88
+ font-weight: 600;
89
+ color: var(--vg-muted);
90
+ background: none;
91
+ border: 0;
92
+ border-bottom: 2px solid transparent;
93
+ padding: 0.5rem 1rem;
94
+ margin-bottom: calc(-1 * var(--vg-rule-width));
95
+ cursor: pointer;
96
+ }
97
+ .vg-tabs [role="tab"]:hover {
98
+ color: var(--vg-ink);
99
+ }
100
+ .vg-tabs [role="tab"][aria-selected="true"] {
101
+ color: var(--vg-ink);
102
+ border-bottom-color: var(--vg-accent);
103
+ }
104
+
105
+ .vg-bar,
106
+ .vg-box-bar {
107
+ display: flex;
108
+ flex-wrap: wrap;
109
+ align-items: center;
110
+ justify-content: space-between;
111
+ gap: 0.75rem 1.5rem;
112
+ }
113
+ .vg-bar {
114
+ margin-bottom: calc(var(--vg-gap) * 1.33);
115
+ }
116
+ .vg-group-title {
117
+ font-size: var(--vg-group-title-size);
118
+ font-weight: 600;
119
+ }
120
+ .vg-controls {
121
+ display: flex;
122
+ flex-wrap: wrap;
123
+ align-items: center;
124
+ gap: 0.5rem;
125
+ }
126
+ .vg-seg {
127
+ display: inline-flex;
128
+ padding: 2px;
129
+ border: var(--vg-rule-width) solid var(--vg-rule);
130
+ border-radius: 999px;
131
+ background: var(--vg-paper-2);
132
+ }
133
+ .vg-seg[hidden],
134
+ .vg-seg button[hidden] {
135
+ display: none;
136
+ }
137
+ .vg-seg button,
138
+ .vg-icon {
139
+ font: inherit;
140
+ font-size: var(--vg-small);
141
+ font-weight: 500;
142
+ color: var(--vg-ink-2);
143
+ background: none;
144
+ border: 0;
145
+ border-radius: 999px;
146
+ padding: 0.25rem 1rem;
147
+ cursor: pointer;
148
+ min-height: 2.25rem;
149
+ }
150
+ .vg-seg button[aria-pressed="true"] {
151
+ background: var(--vg-paper);
152
+ color: var(--vg-ink);
153
+ box-shadow: 0 0 0 var(--vg-rule-width) var(--vg-rule);
154
+ }
155
+ .vg-icon {
156
+ font-size: 1.25rem;
157
+ line-height: 1;
158
+ min-width: 2.25rem;
159
+ padding: 0;
160
+ border: var(--vg-rule-width) solid var(--vg-rule);
161
+ }
162
+ .vg-seg button:focus-visible,
163
+ .vg-icon:focus-visible,
164
+ .vg-thumb:focus-visible,
165
+ .vg-tabs [role="tab"]:focus-visible,
166
+ .vg-credit a:focus-visible,
167
+ .vg-see-all a:focus-visible {
168
+ outline: 2px solid var(--vg-accent);
169
+ outline-offset: 2px;
170
+ }
171
+
172
+ .vg-grid {
173
+ list-style: none;
174
+ padding: 0;
175
+ display: grid;
176
+ gap: calc(var(--vg-gap) * 1.33) var(--vg-gap);
177
+ grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--vg-card-min)), 1fr));
178
+ }
179
+ .vg[data-vg-size="phone"] .vg-grid {
180
+ grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--vg-phone-card-min)), 1fr));
181
+ gap: var(--vg-gap) calc(var(--vg-gap) * 0.67);
182
+ }
183
+ .vg-card {
184
+ min-width: 0;
185
+ }
186
+ .vg-thumb {
187
+ display: block;
188
+ color: inherit;
189
+ text-decoration: none;
190
+ width: 100%;
191
+ padding: 0;
192
+ border: var(--vg-rule-width) solid var(--vg-rule);
193
+ border-radius: var(--vg-radius-md);
194
+ background: var(--vg-paper-2);
195
+ overflow: hidden;
196
+ cursor: zoom-in;
197
+ aspect-ratio: var(--vg-desktop-ratio);
198
+ box-shadow: var(--vg-shadow);
199
+ transition: transform var(--vg-duration) var(--vg-ease);
200
+ }
201
+ .vg[data-vg-size="phone"] .vg-thumb {
202
+ aspect-ratio: var(--vg-phone-ratio);
203
+ }
204
+ .vg-thumb:hover {
205
+ transform: translateY(-2px);
206
+ }
207
+ .vg .vg-card-title {
208
+ margin-top: 0.75rem;
209
+ font-size: var(--vg-card-title-size);
210
+ font-weight: 600;
211
+ color: var(--vg-ink);
212
+ }
213
+ .vg .vg-caption {
214
+ margin-top: 0.25rem;
215
+ font-size: var(--vg-small);
216
+ color: var(--vg-muted);
217
+ }
218
+ .vg[data-vg-size="phone"] .vg-caption {
219
+ display: none;
220
+ }
221
+
222
+ /* Which variant shows. */
223
+ .vg-img {
224
+ display: none;
225
+ width: 100%;
226
+ height: 100%;
227
+ object-fit: cover;
228
+ object-position: top;
229
+ }
230
+ /* A group shown whole (a Mac app's windows): centred in its card with room around it. */
231
+ .vg-card[data-vg-fit="contain"] .vg-img {
232
+ object-fit: contain;
233
+ object-position: center;
234
+ padding: var(--vg-contain-padding);
235
+ box-sizing: border-box;
236
+ filter: var(--vg-contain-shadow);
237
+ }
238
+ .vg-missing {
239
+ place-items: center;
240
+ padding: 1rem;
241
+ font-size: var(--vg-small);
242
+ color: var(--vg-muted);
243
+ text-align: center;
244
+ }
245
+ /* A screen with no shot at this size isn't shown at it. */
246
+ .vg[data-vg-size="desktop"] .vg-card:not([data-vg-sizes~="desktop"]),
247
+ .vg[data-vg-size="phone"] .vg-card:not([data-vg-sizes~="phone"]) {
248
+ display: none;
249
+ }
250
+ .vg[data-vg-size="desktop"] .vg-img[data-vg-size="desktop"],
251
+ .vg[data-vg-size="phone"] .vg-img[data-vg-size="phone"] {
252
+ display: block;
253
+ }
254
+ .vg[data-vg-size="desktop"] .vg-missing[data-vg-size="desktop"],
255
+ .vg[data-vg-size="phone"] .vg-missing[data-vg-size="phone"] {
256
+ display: grid;
257
+ }
258
+ .vg[data-vg-theme="light"] .vg-img:not([data-vg-theme~="light"]),
259
+ .vg[data-vg-theme="dark"] .vg-img:not([data-vg-theme~="dark"]) {
260
+ display: none;
261
+ }
262
+ /* Before the script runs: the page's <html data-theme> when it's set, else the reader's setting. */
263
+ :root[data-theme="light"] .vg:not([data-vg-theme]) .vg-img:not([data-vg-theme~="light"]),
264
+ :root[data-theme="dark"] .vg:not([data-vg-theme]) .vg-img:not([data-vg-theme~="dark"]) {
265
+ display: none;
266
+ }
267
+ @media not all and (prefers-color-scheme: dark) {
268
+ :root:not([data-theme="light"]):not([data-theme="dark"]) .vg:not([data-vg-theme]) .vg-img:not([data-vg-theme~="light"]) {
269
+ display: none;
270
+ }
271
+ }
272
+ @media (prefers-color-scheme: dark) {
273
+ :root:not([data-theme="light"]):not([data-theme="dark"]) .vg:not([data-vg-theme]) .vg-img:not([data-vg-theme~="dark"]) {
274
+ display: none;
275
+ }
276
+ }
277
+
278
+ /* The strip: one row that scrolls sideways, snapping to each card, with a button at each end. */
279
+ .vg-strip {
280
+ position: relative;
281
+ min-width: 0;
282
+ }
283
+ .vg .vg-track {
284
+ display: grid;
285
+ grid-auto-flow: column;
286
+ grid-auto-columns: var(--vg-strip-card, min(22.5rem, 80%));
287
+ grid-template-columns: none;
288
+ overflow-x: auto;
289
+ overscroll-behavior-x: contain;
290
+ scroll-snap-type: x mandatory;
291
+ scroll-padding-inline: 0.25rem;
292
+ padding: 0.25rem 0.25rem 0.75rem;
293
+ scrollbar-width: thin;
294
+ }
295
+ .vg[data-vg-size="phone"] .vg-track {
296
+ grid-auto-columns: var(--vg-strip-phone-card, min(11rem, 45%));
297
+ grid-template-columns: none;
298
+ }
299
+ .vg-track .vg-card {
300
+ scroll-snap-align: start;
301
+ }
302
+ .vg-strip .vg-icon {
303
+ position: absolute;
304
+ top: calc(50% - 1.5rem);
305
+ z-index: 1;
306
+ background: var(--vg-paper);
307
+ box-shadow: var(--vg-float-shadow);
308
+ }
309
+ .vg-strip-prev {
310
+ left: 0.25rem;
311
+ }
312
+ .vg-strip-next {
313
+ right: 0.25rem;
314
+ }
315
+ .vg-strip .vg-icon:disabled {
316
+ visibility: hidden;
317
+ }
318
+ .vg .vg-see-all {
319
+ margin-top: 1rem;
320
+ text-align: center;
321
+ }
322
+ .vg-see-all a {
323
+ color: var(--vg-accent);
324
+ font-weight: 500;
325
+ }
326
+
327
+ .vg .vg-credit {
328
+ margin-top: calc(var(--vg-gap) * 2);
329
+ font-size: var(--vg-small);
330
+ color: var(--vg-muted);
331
+ text-align: center;
332
+ }
333
+ .vg-credit a {
334
+ color: inherit;
335
+ }
336
+
337
+ .vg-error {
338
+ margin: 2rem 0;
339
+ color: var(--vg-muted);
340
+ text-align: center;
341
+ }
342
+
343
+ /* The full-size view: the screen's whole image inside the dialog. */
344
+ .vg-box {
345
+ width: min(100vw - 2rem, 92rem);
346
+ max-width: none;
347
+ max-height: calc(100dvh - 2rem);
348
+ padding: 0;
349
+ border: var(--vg-rule-width) solid var(--vg-rule);
350
+ border-radius: var(--vg-radius-lg);
351
+ background: var(--vg-paper);
352
+ color: var(--vg-ink-2);
353
+ box-shadow: var(--vg-shadow);
354
+ }
355
+ .vg-box[open] {
356
+ display: flex;
357
+ flex-direction: column;
358
+ }
359
+ .vg-box::backdrop {
360
+ background: var(--vg-backdrop);
361
+ }
362
+ .vg-box-bar {
363
+ padding: 0.75rem 1rem;
364
+ border-bottom: var(--vg-rule-width) solid var(--vg-rule);
365
+ }
366
+ .vg-box-title {
367
+ flex: 1;
368
+ font-size: 1.25rem;
369
+ font-weight: 600;
370
+ color: var(--vg-ink);
371
+ }
372
+ /* On a narrow screen the header is two rows: the title with ‹ › × beside it, then the switches. */
373
+ @media (max-width: 40rem) {
374
+ .vg-box-bar {
375
+ column-gap: 0.5rem;
376
+ }
377
+ .vg-box-bar .vg-controls {
378
+ display: contents;
379
+ }
380
+ .vg-box-bar .vg-icon {
381
+ order: 1;
382
+ }
383
+ .vg-box-bar:has(.vg-seg:not([hidden]))::after {
384
+ content: "";
385
+ order: 2;
386
+ flex-basis: 100%;
387
+ }
388
+ .vg-box-bar .vg-seg {
389
+ order: 3;
390
+ }
391
+ }
392
+ .vg-box-view {
393
+ overflow: auto;
394
+ overscroll-behavior: contain;
395
+ padding: 1rem;
396
+ background: var(--vg-paper-2);
397
+ min-height: 0;
398
+ flex: 1;
399
+ }
400
+ .vg-box-view img {
401
+ display: block;
402
+ margin: 0 auto;
403
+ max-width: 100%;
404
+ height: auto;
405
+ border-radius: var(--vg-radius-sm);
406
+ border: var(--vg-rule-width) solid var(--vg-rule);
407
+ }
408
+ .vg-box-view[data-vg-size="phone"] img {
409
+ max-width: min(100%, 390px);
410
+ }
411
+ /* A shot of one screen (a phone's, a window) fits the view whole; a full-page capture scrolls. */
412
+ .vg-box[data-vg-fit] {
413
+ height: calc(100dvh - 2rem);
414
+ }
415
+ .vg-box-view[data-vg-fit] {
416
+ display: flex;
417
+ align-items: center;
418
+ justify-content: center;
419
+ }
420
+ .vg-box-view[data-vg-fit] img {
421
+ width: auto;
422
+ max-height: 100%;
423
+ object-fit: contain;
424
+ }
425
+ .vg-box-view .vg-missing {
426
+ display: grid;
427
+ min-height: 12rem;
428
+ }
429
+
430
+ @media (prefers-reduced-motion: reduce) {
431
+ .vg-thumb {
432
+ transition: none;
433
+ }
434
+ }
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module VisualCI
4
+ module Gallery
5
+ # In a view: `<%= visualci_gallery(manifest, title: nil, screens: SCREENS) %>`.
6
+ module Helper
7
+ def visualci_gallery(manifest, **options)
8
+ Gallery.render(manifest, **options).html_safe # rubocop:disable Rails/OutputSafety -- escaped by the renderer
9
+ end
10
+ end
11
+
12
+ # Adds the helper to every view and serves app/assets (visualci_gallery.js and visualci_gallery.css, the JS
13
+ # library's ES5 build and stylesheet, copied in when the gem is built) to the asset pipeline.
14
+ class Engine < ::Rails::Engine
15
+ initializer 'visualci_gallery.helper' do
16
+ ActiveSupport.on_load(:action_view) { include VisualCI::Gallery::Helper }
17
+ end
18
+
19
+ # Sprockets compiles only the files it's told to in production; Propshaft serves every asset path as it is, and
20
+ # its config.assets has no precompile list (an OrderedOptions answers nil for it).
21
+ initializer 'visualci_gallery.assets' do |app|
22
+ assets = app.config.respond_to?(:assets) ? app.config.assets : nil
23
+ assets.precompile += %w[visualci_gallery.js visualci_gallery.css] if assets && assets.precompile.is_a?(Array)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,139 @@
1
+ # frozen_string_literal: true
2
+
3
+ module VisualCI
4
+ module Gallery
5
+ # The contract's markup from a model (SPEC.md, "The markup"): a port of the JS library's render.ts, line for line.
6
+ class Renderer
7
+ def initialize(model)
8
+ @m = model
9
+ @id = Gallery.escape(model['id'])
10
+ @below = model['title'].nil? ? 0 : 1
11
+ end
12
+
13
+ def call
14
+ out = []
15
+ size = @m['layout'] == 'strip' ? strip_size : @m['groups'][0]['sizes'][0]
16
+ out << %(<section class="vg" data-vg data-vg-layout="#{@m['layout']}" aria-label="#{esc(@m['label'])}" ) +
17
+ %(data-vg-size="#{size}"#{@m['themeSwitch'] ? '' : ' data-vg-theme-source="page"'}>)
18
+ out << "<#{h(0)} class=\"vg-title\">#{esc(@m['title'])}</#{h(0)}>" unless @m['title'].nil?
19
+ @m['layout'] == 'strip' ? strip(out) : grid(out)
20
+ if (see = @m['seeAll'])
21
+ out << %(<p class="vg-see-all"><a href="#{esc(see['href'])}">#{esc(see['text'])}</a></p>)
22
+ end
23
+ if @m['credit']
24
+ out << '<p class="vg-credit">Screenshots by <a href="https://visualci.com">VisualCI</a></p>'
25
+ end
26
+ out << %(<dialog class="vg-box" aria-labelledby="#{@id}-box-title">)
27
+ out << %(<div class="vg-box-bar"><#{h(@below)} class="vg-box-title" id="#{@id}-box-title"></#{h(@below)}>) +
28
+ '<div class="vg-controls">' +
29
+ (@m['themeSwitch'] ? themes : '') +
30
+ (@m['layout'] == 'grid' ? sizes(%w[desktop phone], ' vg-box-sizes') : '') +
31
+ '<button type="button" class="vg-icon" data-vg-step="-1" aria-label="Previous screen">‹</button>' \
32
+ '<button type="button" class="vg-icon" data-vg-step="1" aria-label="Next screen">›</button>' \
33
+ '</div>' \
34
+ '<button type="button" class="vg-icon" data-vg-close aria-label="Close">×</button>' \
35
+ '</div>'
36
+ out << '<div class="vg-box-view"></div>'
37
+ out << '</dialog>'
38
+ out << '</section>'
39
+ "#{out.join("\n")}\n"
40
+ end
41
+
42
+ private
43
+
44
+ def esc(text) = Gallery.escape(text)
45
+
46
+ def h(offset) = "h#{[@m['headingLevel'] + offset, 6].min}"
47
+
48
+ def themes
49
+ '<div class="vg-seg" role="group" aria-label="Theme">' \
50
+ '<button type="button" data-vg-set-theme="light" aria-pressed="false">Light</button>' \
51
+ '<button type="button" data-vg-set-theme="dark" aria-pressed="false">Dark</button>' \
52
+ '</div>'
53
+ end
54
+
55
+ def sizes(list, extra = '')
56
+ %(<div class="vg-seg#{extra}" role="group" aria-label="Screen size">) +
57
+ list.map { |s| %(<button type="button" data-vg-set-size="#{s}" aria-pressed="false">#{SIZE_LABEL[s]}</button>) }.join +
58
+ '</div>'
59
+ end
60
+
61
+ def image(title, v, themes)
62
+ alt = "#{title}, #{SIZE_LABEL[v['size']].downcase}, #{themes.join(' and ')}"
63
+ %(<img class="vg-img" data-vg-size="#{v['size']}" data-vg-theme="#{themes.join(' ')}" src="#{esc(v['url'])}") +
64
+ (v['url2x'] ? %( data-src-2x="#{esc(v['url2x'])}") : '') +
65
+ %( width="#{v['width']}" height="#{v['height']}" alt="#{esc(alt)}" loading="lazy" decoding="async">)
66
+ end
67
+
68
+ def card(sc, sizes, heading, caption, fit)
69
+ imgs = []
70
+ shown = []
71
+ first = nil
72
+ sizes.each do |size|
73
+ at = sc['variants'].select { |v| v['size'] == size }
74
+ next if at.empty?
75
+
76
+ shown << size
77
+ first ||= at[0]
78
+ # Every size has both themes (the model refuses a screen without); the same image for both is shown once.
79
+ if at[0]['url'] == at[1]['url'] && at[0]['url2x'] == at[1]['url2x']
80
+ imgs << image(sc['title'], at[0], %w[light dark])
81
+ else
82
+ at.each { |v| imgs << image(sc['title'], v, [v['theme']]) }
83
+ end
84
+ end
85
+ %(<li class="vg-card" data-vg-screen="#{esc(sc['key'])}" data-vg-sizes="#{shown.join(' ')}") +
86
+ (fit == 'contain' ? ' data-vg-fit="contain"' : '') + '>' +
87
+ %(<a class="vg-thumb" href="#{esc(first['url'])}" data-vg-open aria-label="#{esc(sc['title'])}: view full size">) +
88
+ imgs.join + '</a>' +
89
+ %(<#{heading} class="vg-card-title">#{esc(sc['title'])}</#{heading}>) +
90
+ (caption && !sc['caption'].nil? ? %(<p class="vg-caption">#{esc(sc['caption'])}</p>) : '') +
91
+ '</li>'
92
+ end
93
+
94
+ def grid(out)
95
+ groups = @m['groups']
96
+ tabs = groups.length > 1
97
+ if tabs
98
+ out << %(<div class="vg-tabs" role="tablist" aria-label="#{esc(@m['label'])}">)
99
+ groups.each_with_index do |g, i|
100
+ out << %(<button type="button" role="tab" id="#{@id}-tab-#{g['slug']}" aria-controls="#{@id}-panel-#{g['slug']}") +
101
+ %( aria-selected="#{i.zero?}" tabindex="#{i.zero? ? 0 : -1}">#{esc(g['name'])}</button>)
102
+ end
103
+ out << '</div>'
104
+ end
105
+ groups.each_with_index do |g, i|
106
+ out << %(<div class="vg-panel" id="#{@id}-panel-#{g['slug']}" data-vg-sizes="#{g['sizes'].join(' ')}") +
107
+ (tabs ? %( role="tabpanel" aria-labelledby="#{@id}-tab-#{g['slug']}") : '') +
108
+ (i.positive? ? ' hidden' : '') + '>'
109
+ controls = (@m['themeSwitch'] ? themes : '') + (g['sizes'].length > 1 ? sizes(g['sizes']) : '')
110
+ out << %(<div class="vg-bar"><#{h(@below)} class="vg-group-title">#{esc(g['title'])}</#{h(@below)}>) +
111
+ (controls.empty? ? '' : %(<div class="vg-controls">#{controls}</div>)) + '</div>'
112
+ out << '<ul class="vg-grid">'
113
+ g['screens'].each { |sc| out << card(sc, g['sizes'], h(@below + 1), true, g['fit']) }
114
+ out << '</ul>'
115
+ out << '</div>'
116
+ end
117
+ end
118
+
119
+ def strip_size
120
+ @m['groups'].any? { |g| g['sizes'].include?('desktop') } ? 'desktop' : 'phone'
121
+ end
122
+
123
+ def strip(out)
124
+ size = strip_size
125
+ out << %(<div class="vg-panel" id="#{@id}-strip" data-vg-sizes="#{size}">)
126
+ out << '<div class="vg-strip"><button type="button" class="vg-icon vg-strip-prev" data-vg-scroll="-1" aria-label="Scroll back">‹</button>'
127
+ out << '<ul class="vg-grid vg-track">'
128
+ @m['groups'].each do |g|
129
+ g['screens'].each do |sc|
130
+ out << card(sc, [size], h(@below), false, g['fit']) if sc['variants'].any? { |v| v['size'] == size }
131
+ end
132
+ end
133
+ out << '</ul>'
134
+ out << '<button type="button" class="vg-icon vg-strip-next" data-vg-scroll="1" aria-label="Scroll forward">›</button></div>'
135
+ out << '</div>'
136
+ end
137
+ end
138
+ end
139
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module VisualCI
4
+ module Gallery
5
+ VERSION = '0.1.0'
6
+ end
7
+ end