Skip to content

Commit 053aaa9

Browse files
committed
Add touch-friendly collage layout modal and unify selection flow
1 parent 8a93f7c commit 053aaa9

File tree

4 files changed

+106
-37
lines changed

4 files changed

+106
-37
lines changed

assets/js/core.js

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,6 +1384,15 @@ const photoBooth = (function () {
13841384

13851385
$('.takeCollage, .newcollage').on('click', function (e) {
13861386
e.preventDefault();
1387+
console.log('Collage button clicked');
1388+
if (config.collage.enabled && config.collage.allow_selection && $('#collageSelectorModal').length) {
1389+
console.log('Opening collage selector modal');
1390+
$('#collageSelectorModal').data('pending-start', true);
1391+
$('#collageSelectorModal').removeClass('hidden').attr('aria-hidden', 'false');
1392+
$(this).trigger('blur');
1393+
return;
1394+
}
1395+
console.log('Starting collage without selection');
13871396
api.thrill(PhotoStyle.COLLAGE);
13881397
$(this).trigger('blur');
13891398
});
@@ -1590,16 +1599,32 @@ const photoBooth = (function () {
15901599
config.collage.enabled &&
15911600
config.collage.allow_selection
15921601
) {
1593-
document.getElementById('collageSelect').addEventListener('change', function () {
1594-
const selectedOption = this.options[this.selectedIndex];
1595-
const limit = selectedOption.dataset.limit;
1596-
const layout = selectedOption.value;
1602+
const collageModal = $('#collageSelectorModal');
1603+
const closeBtn = $('#collageSelectorClose');
1604+
const optionButtons = $('.collageSelector__option');
1605+
1606+
// Move modal to body so it isn't hidden by stage visibility
1607+
if (collageModal.length) {
1608+
$('body').append(collageModal.detach());
1609+
}
15971610

1611+
const setSelection = (layout, limit) => {
15981612
api.collageLayout = layout;
15991613
api.collageLimit = parseInt(limit, 10);
1614+
};
1615+
1616+
const closeModal = () => {
1617+
collageModal.addClass('hidden');
1618+
collageModal.attr('aria-hidden', 'true');
1619+
};
1620+
1621+
closeBtn.on('click', closeModal);
16001622

1601-
console.log('Collage layout updated:', api.collageLayout);
1602-
console.log('Collage limit updated:', api.collageLimit);
1623+
optionButtons.on('click', function () {
1624+
const button = $(this);
1625+
setSelection(button.data('layout'), button.data('limit'));
1626+
closeModal();
1627+
api.thrill(PhotoStyle.COLLAGE);
16031628
});
16041629
}
16051630

assets/sass/components/_button.scss

Lines changed: 49 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -120,31 +120,61 @@
120120
/**
121121
* Select menu
122122
*/
123-
#collageSelect {
124-
font-size: var(--button-font-size);
125-
font-weight: var(--button-font-weight);
126-
height: auto;
127-
min-height: 2rem;
128-
vertical-align: middle;
129-
border: var(--button-border-width) solid var(--button-border-color);
130-
background: var(--button-background);
131-
color: var(--button-color);
132-
padding: 0.2rem;
133-
align-items: center;
134-
justify-content: center;
123+
#collageSelector {
124+
width: 100%;
125+
margin-top: 0.75rem;
126+
}
135127

136-
&.focused,
137-
&:hover,
138-
&:focus {
139-
--button-background: var(--button-focus-background);
140-
}
128+
.collageSelector__trigger {
129+
justify-content: flex-start;
130+
gap: 0.5rem;
131+
width: 100%;
132+
}
133+
134+
.collageSelector__current {
135+
display: block;
136+
font-size: 0.9rem;
137+
opacity: 0.85;
138+
margin-top: 0.25rem;
139+
}
140+
141+
.collageSelector__options {
142+
display: grid;
143+
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
144+
gap: 0.75rem;
145+
width: 100%;
146+
}
147+
148+
.collageSelector__option {
149+
width: 100%;
150+
border: 1px solid var(--border-color);
151+
border-radius: 0.5rem;
152+
padding: 1rem;
153+
font-size: 1.05rem;
154+
text-align: left;
155+
background: #fff;
156+
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
157+
}
158+
159+
.collageSelector__option:focus,
160+
.collageSelector__option:hover,
161+
.collageSelector__option.is-selected {
162+
border-color: var(--primary-color);
163+
box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-color), #fff 70%);
164+
}
165+
166+
.collageSelector__limit {
167+
display: block;
168+
font-size: 0.85rem;
169+
opacity: 0.8;
170+
margin-top: 0.35rem;
141171
}
142172

143173
[data-ui-button='classic_rounded'],
144174
[data-ui-button='modern'],
145175
[data-ui-button='modern_squared'] {
146-
#collageSelect {
147-
border-radius: 0.625rem;
176+
.collageSelector__option {
177+
border-radius: 0.75rem;
148178
}
149179
}
150180

assets/sass/components/_modal.scss

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
--modal-font-size: 1rem;
99
--modal-line-height: 1.2;
1010
--modal-padding: 2rem;
11-
--modal-spacing: 2rem;
11+
--modal-spacing: 1.5rem;
12+
--modal-max-width: 960px;
1213

1314
--modal-button-color: var(--button-font-color);
1415
--modal-button-background: var(--primary-color);
@@ -45,11 +46,14 @@
4546
position: relative;
4647
color: var(--modal-color);
4748
background: var(--modal-background);
48-
max-width: calc(100dvw - var(--modal-spacing) * 2);
49+
width: min(var(--modal-max-width), calc(100dvw - var(--modal-spacing) * 2));
50+
max-width: min(var(--modal-max-width), calc(100dvw - var(--modal-spacing) * 2));
51+
min-width: min(640px, calc(100dvw - var(--modal-spacing) * 2));
4952
max-height: calc(100dvh - var(--modal-spacing) * 2);
5053
}
5154

5255
&-body {
56+
width: 100%;
5357
text-align: center;
5458
overflow-y: scroll;
5559
font-size: var(--modal-font-size);

template/components/collageSelection.php

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,39 @@ function renderCollageOptionsFromEnumWithLimit(array $collageConfig): string
88
{
99
$languageService = LanguageService::getInstance();
1010

11-
$html = '<div id="collageDiv">';
12-
$html .= '<p>' . $languageService->translate('selectCollageLayout') . '</p>';
13-
$html .= '<select id="collageSelect">';
11+
$html = '<div id="collageSelector">';
12+
$html .= '<div class="modal hidden" id="collageSelectorModal" aria-hidden="true" role="dialog" aria-labelledby="collageSelectorTitle">';
13+
$html .= '<div class="modal-inner">';
14+
$html .= '<div class="modal-body">';
15+
$html .= '<h3 id="collageSelectorTitle">' . $languageService->translate('selectCollageLayout') . '</h3>';
16+
$html .= '<div class="collageSelector__options">';
1417

1518
foreach (CollageLayoutEnum::cases() as $layout) {
1619
if (in_array($layout, $collageConfig['layouts_enabled'])) {
1720
$collageConfig['layout'] = $layout->value;
1821
$limitData = Collage::calculateLimit($collageConfig);
1922
$limit = $limitData['limit'];
2023

21-
$selected = ($layout->value === $collageConfig['layout']) ? ' selected' : '';
22-
2324
$html .= sprintf(
24-
'<option value="%s" data-limit="%d"%s>%s</option>',
25-
htmlspecialchars($layout->value, ENT_QUOTES, 'UTF-8'),
25+
'<button type="button" class="collageSelector__option cursor-pointer" data-layout="%s" data-limit="%d">' .
26+
'%s' .
27+
'<span class="collageSelector__limit">' .
28+
$languageService->translate('pictures') . ': %d' .
29+
'</span>' .
30+
'</button>',
31+
$layout->value,
2632
$limit,
27-
$selected,
28-
htmlspecialchars($layout->label(), ENT_QUOTES, 'UTF-8')
33+
$layout->label(),
34+
$limit
2935
);
3036
}
3137
}
3238

33-
$html .= '</select>';
39+
$html .= '</div>'; // options
40+
$html .= '</div>'; // body
41+
$html .= '<div class="modal-buttonbar">';
42+
$html .= '<button type="button" class="modal-button" id="collageSelectorClose">' . htmlspecialchars($languageService->translate('close'), ENT_QUOTES, 'UTF-8') . '</button>';
43+
$html .= '</div></div></div>';
3444
$html .= '</div>';
3545

3646
return $html;

0 commit comments

Comments
 (0)