@brilo/base-blocks 0.1.57 → 0.1.60
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.
- package/build/.tsbuildinfo +1 -1
- package/build/blocks/column/column-item/factory.d.ts.map +1 -1
- package/build/blocks/column/column-item/factory.js +2 -1
- package/build/blocks/column/column-item/icon.d.ts +2 -0
- package/build/blocks/column/column-item/icon.d.ts.map +1 -0
- package/build/blocks/column/column-item/icon.js +2 -0
- package/build/blocks/column/column-item/index.d.ts.map +1 -1
- package/build/blocks/column/column-item/index.js +2 -0
- package/build/blocks/food-menu/food-menu-group/FoodMenuPreview.d.ts +6 -0
- package/build/blocks/food-menu/food-menu-group/FoodMenuPreview.d.ts.map +1 -0
- package/build/blocks/food-menu/food-menu-group/FoodMenuPreview.js +167 -0
- package/build/blocks/food-menu/food-menu-group/FoodMenuSelectModal.d.ts +7 -0
- package/build/blocks/food-menu/food-menu-group/FoodMenuSelectModal.d.ts.map +1 -0
- package/build/blocks/food-menu/food-menu-group/FoodMenuSelectModal.js +56 -0
- package/build/blocks/food-menu/food-menu-group/constants.d.ts +8 -0
- package/build/blocks/food-menu/food-menu-group/constants.d.ts.map +1 -0
- package/build/blocks/food-menu/food-menu-group/constants.js +7 -0
- package/build/blocks/food-menu/food-menu-group/edit.d.ts +7 -0
- package/build/blocks/food-menu/food-menu-group/edit.d.ts.map +1 -0
- package/build/blocks/food-menu/food-menu-group/edit.js +36 -0
- package/build/blocks/food-menu/food-menu-group/factory.d.ts +4 -0
- package/build/blocks/food-menu/food-menu-group/factory.d.ts.map +1 -0
- package/build/blocks/food-menu/food-menu-group/factory.js +57 -0
- package/build/blocks/food-menu/food-menu-group/icon.d.ts +2 -0
- package/build/blocks/food-menu/food-menu-group/icon.d.ts.map +1 -0
- package/build/blocks/food-menu/food-menu-group/icon.js +2 -0
- package/build/blocks/food-menu/food-menu-group/index.d.ts +6 -0
- package/build/blocks/food-menu/food-menu-group/index.d.ts.map +1 -0
- package/build/blocks/food-menu/food-menu-group/index.js +7 -0
- package/build/blocks/food-menu/food-menu-group/types.d.ts +19 -0
- package/build/blocks/food-menu/food-menu-group/types.d.ts.map +1 -0
- package/build/blocks/food-menu/food-menu-group/types.js +1 -0
- package/build/blocks/form/form-group/index.js +1 -1
- package/build/blocks/gallery/gallery-group/constants.d.ts +1 -19
- package/build/blocks/gallery/gallery-group/constants.d.ts.map +1 -1
- package/build/blocks/gallery/gallery-group/constants.js +1 -8
- package/build/blocks/gallery/gallery-group/edit.d.ts.map +1 -1
- package/build/blocks/gallery/gallery-group/edit.js +3 -19
- package/build/blocks/gallery/gallery-group/index.js +1 -1
- package/build/blocks/gallery/gallery-item/index.js +1 -1
- package/build/blocks/gallery/gallery-strip-group/constants.d.ts +34 -0
- package/build/blocks/gallery/gallery-strip-group/constants.d.ts.map +1 -0
- package/build/blocks/gallery/gallery-strip-group/constants.js +17 -0
- package/build/blocks/gallery/gallery-strip-group/edit.d.ts +7 -0
- package/build/blocks/gallery/gallery-strip-group/edit.d.ts.map +1 -0
- package/build/blocks/gallery/gallery-strip-group/edit.js +34 -0
- package/build/blocks/gallery/gallery-strip-group/factory.d.ts +5 -0
- package/build/blocks/gallery/gallery-strip-group/factory.d.ts.map +1 -0
- package/build/blocks/gallery/gallery-strip-group/factory.js +28 -0
- package/build/blocks/gallery/gallery-strip-group/index.d.ts +5 -0
- package/build/blocks/gallery/gallery-strip-group/index.d.ts.map +1 -0
- package/build/blocks/gallery/gallery-strip-group/index.js +7 -0
- package/build/blocks/gallery/gallery-strip-group/types.d.ts +18 -0
- package/build/blocks/gallery/gallery-strip-group/types.d.ts.map +1 -0
- package/build/blocks/gallery/gallery-strip-group/types.js +1 -0
- package/build/blocks/groups/text-and-media-group/index.d.ts.map +1 -1
- package/build/blocks/groups/text-and-media-group/index.js +2 -0
- package/build/blocks/hero/hero-item/index.js +1 -1
- package/build/blocks/review/review-summary-item/constants.d.ts +3 -0
- package/build/blocks/review/review-summary-item/constants.d.ts.map +1 -0
- package/build/blocks/review/review-summary-item/constants.js +2 -0
- package/build/blocks/review/review-summary-item/edit.d.ts +6 -0
- package/build/blocks/review/review-summary-item/edit.d.ts.map +1 -0
- package/build/blocks/review/review-summary-item/edit.js +17 -0
- package/build/blocks/review/review-summary-item/factory.d.ts +5 -0
- package/build/blocks/review/review-summary-item/factory.d.ts.map +1 -0
- package/build/blocks/review/review-summary-item/factory.js +23 -0
- package/build/blocks/review/review-summary-item/index.d.ts +5 -0
- package/build/blocks/review/review-summary-item/index.d.ts.map +1 -0
- package/build/blocks/review/review-summary-item/index.js +5 -0
- package/build/blocks/review/review-summary-item/types.d.ts +11 -0
- package/build/blocks/review/review-summary-item/types.d.ts.map +1 -0
- package/build/blocks/review/review-summary-item/types.js +1 -0
- package/build/blocks/urgency/urgency-item/constants.d.ts +56 -0
- package/build/blocks/urgency/urgency-item/constants.d.ts.map +1 -0
- package/build/blocks/urgency/urgency-item/constants.js +32 -0
- package/build/blocks/urgency/urgency-item/edit.d.ts +7 -0
- package/build/blocks/urgency/urgency-item/edit.d.ts.map +1 -0
- package/build/blocks/urgency/urgency-item/edit.js +83 -0
- package/build/blocks/urgency/urgency-item/factory.d.ts +5 -0
- package/build/blocks/urgency/urgency-item/factory.d.ts.map +1 -0
- package/build/blocks/urgency/urgency-item/factory.js +31 -0
- package/build/blocks/urgency/urgency-item/index.d.ts +5 -0
- package/build/blocks/urgency/urgency-item/index.d.ts.map +1 -0
- package/build/blocks/urgency/urgency-item/index.js +5 -0
- package/build/blocks/urgency/urgency-item/types.d.ts +22 -0
- package/build/blocks/urgency/urgency-item/types.d.ts.map +1 -0
- package/build/blocks/urgency/urgency-item/types.js +1 -0
- package/build/components/EntitySelectModal/EntitySelectModal.d.ts +6 -0
- package/build/components/EntitySelectModal/EntitySelectModal.d.ts.map +1 -1
- package/build/components/EntitySelectModal/EntitySelectModal.js +3 -2
- package/build/components/GalleryImagesAppender/index.d.ts +5 -0
- package/build/components/GalleryImagesAppender/index.d.ts.map +1 -0
- package/build/components/GalleryImagesAppender/index.js +12 -0
- package/build/constants.d.ts +19 -0
- package/build/constants.d.ts.map +1 -1
- package/build/constants.js +8 -0
- package/build/index.d.ts +8 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +4 -0
- package/build/utils/plural.d.ts +3 -0
- package/build/utils/plural.d.ts.map +1 -0
- package/build/utils/plural.js +7 -0
- package/package.json +1 -1
- package/src/blocks/column/column-item/factory.tsx +2 -1
- package/src/blocks/column/column-item/icon.tsx +10 -0
- package/src/blocks/column/column-item/index.ts +2 -0
- package/src/blocks/food-menu/food-menu-group/FoodMenuPreview.tsx +380 -0
- package/src/blocks/food-menu/food-menu-group/FoodMenuSelectModal.tsx +69 -0
- package/src/blocks/food-menu/food-menu-group/constants.ts +9 -0
- package/src/blocks/food-menu/food-menu-group/edit.tsx +153 -0
- package/src/blocks/food-menu/food-menu-group/editor.scss +269 -0
- package/src/blocks/food-menu/food-menu-group/factory.tsx +66 -0
- package/src/blocks/food-menu/food-menu-group/icon.tsx +8 -0
- package/src/blocks/food-menu/food-menu-group/index.ts +17 -0
- package/src/blocks/food-menu/food-menu-group/types.ts +21 -0
- package/src/blocks/form/form-group/index.ts +1 -1
- package/src/blocks/gallery/gallery-group/constants.ts +1 -8
- package/src/blocks/gallery/gallery-group/edit.tsx +3 -39
- package/src/blocks/gallery/gallery-group/editor.scss +0 -12
- package/src/blocks/gallery/gallery-group/index.ts +1 -1
- package/src/blocks/gallery/gallery-item/index.ts +1 -1
- package/src/blocks/gallery/gallery-strip-group/constants.ts +22 -0
- package/src/blocks/gallery/gallery-strip-group/edit.tsx +112 -0
- package/src/blocks/gallery/gallery-strip-group/editor.scss +36 -0
- package/src/blocks/gallery/gallery-strip-group/factory.tsx +32 -0
- package/src/blocks/gallery/gallery-strip-group/index.ts +11 -0
- package/src/blocks/gallery/gallery-strip-group/types.ts +20 -0
- package/src/blocks/groups/text-and-media-group/index.ts +2 -0
- package/src/blocks/hero/hero-item/index.ts +1 -1
- package/src/blocks/review/review-summary-item/constants.ts +2 -0
- package/src/blocks/review/review-summary-item/edit.tsx +86 -0
- package/src/blocks/review/review-summary-item/editor.scss +44 -0
- package/src/blocks/review/review-summary-item/factory.tsx +27 -0
- package/src/blocks/review/review-summary-item/index.ts +9 -0
- package/src/blocks/review/review-summary-item/types.ts +11 -0
- package/src/blocks/urgency/urgency-item/constants.ts +39 -0
- package/src/blocks/urgency/urgency-item/edit.tsx +319 -0
- package/src/blocks/urgency/urgency-item/editor.scss +99 -0
- package/src/blocks/urgency/urgency-item/factory.tsx +36 -0
- package/src/blocks/urgency/urgency-item/index.ts +9 -0
- package/src/blocks/urgency/urgency-item/types.ts +23 -0
- package/src/components/EntitySelectModal/EntitySelectModal.tsx +19 -7
- package/src/components/GalleryImagesAppender/editor.scss +15 -0
- package/src/components/GalleryImagesAppender/index.tsx +29 -0
- package/src/constants.ts +9 -0
- package/src/editor.scss +5 -0
- package/src/index.ts +13 -0
- package/src/utils/plural.ts +13 -0
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
// Editor preview of the menu block: an admin card, not a copy of the page.
|
|
2
|
+
// wp-admin palette only — the canvas carries the theme's front-end styles,
|
|
3
|
+
// and none of its tokens belong here.
|
|
4
|
+
$fg: #1e1e1e;
|
|
5
|
+
$muted: #757575;
|
|
6
|
+
$line: #dcdcde;
|
|
7
|
+
$surface: #f6f7f7;
|
|
8
|
+
$accent: #3858e9;
|
|
9
|
+
$ok: #1d7c4d;
|
|
10
|
+
$ok-soft: #e5f3ec;
|
|
11
|
+
$warn: #9a6700;
|
|
12
|
+
|
|
13
|
+
@layer base {
|
|
14
|
+
.brilo-food-menu-preview {
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-direction: column;
|
|
17
|
+
gap: 14px;
|
|
18
|
+
color: $fg;
|
|
19
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
|
20
|
+
font-size: 14px;
|
|
21
|
+
line-height: 1.5;
|
|
22
|
+
text-align: left;
|
|
23
|
+
|
|
24
|
+
&--loading {
|
|
25
|
+
opacity: 0.6;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.brilo-food-menu-preview__pick {
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-wrap: wrap;
|
|
32
|
+
gap: 10px;
|
|
33
|
+
align-items: center;
|
|
34
|
+
padding: 10px 0 14px;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.brilo-food-menu-preview__head {
|
|
38
|
+
display: flex;
|
|
39
|
+
flex-wrap: wrap;
|
|
40
|
+
gap: 12px;
|
|
41
|
+
align-items: center;
|
|
42
|
+
justify-content: space-between;
|
|
43
|
+
padding: 10px 14px;
|
|
44
|
+
background: $surface;
|
|
45
|
+
border: 1px solid $line;
|
|
46
|
+
border-bottom: 0;
|
|
47
|
+
border-radius: 4px 4px 0 0;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.brilo-food-menu-preview__card--loading .brilo-food-menu-preview__head {
|
|
51
|
+
// Same height as a loaded head, so the block does not jump when it lands.
|
|
52
|
+
min-height: 43px;
|
|
53
|
+
justify-content: center;
|
|
54
|
+
border-bottom: 1px solid $line;
|
|
55
|
+
border-radius: 4px;
|
|
56
|
+
|
|
57
|
+
.components-spinner {
|
|
58
|
+
margin: 0;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.brilo-food-menu-preview__title {
|
|
63
|
+
display: flex;
|
|
64
|
+
gap: 10px;
|
|
65
|
+
align-items: center;
|
|
66
|
+
min-width: 0;
|
|
67
|
+
font-weight: 600;
|
|
68
|
+
|
|
69
|
+
svg {
|
|
70
|
+
flex: none;
|
|
71
|
+
width: 18px;
|
|
72
|
+
height: 18px;
|
|
73
|
+
color: $muted;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.brilo-food-menu-preview__meta {
|
|
78
|
+
display: flex;
|
|
79
|
+
flex-wrap: wrap;
|
|
80
|
+
gap: 6px;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.brilo-food-menu-preview__pill {
|
|
84
|
+
display: inline-flex;
|
|
85
|
+
gap: 6px;
|
|
86
|
+
align-items: center;
|
|
87
|
+
padding: 2px 9px;
|
|
88
|
+
color: $accent;
|
|
89
|
+
font-weight: 600;
|
|
90
|
+
font-size: 12px;
|
|
91
|
+
letter-spacing: 0.02em;
|
|
92
|
+
white-space: nowrap;
|
|
93
|
+
background: rgba($accent, 0.1);
|
|
94
|
+
border-radius: 999px;
|
|
95
|
+
|
|
96
|
+
&--ok {
|
|
97
|
+
color: $ok;
|
|
98
|
+
background: $ok-soft;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
&--muted {
|
|
102
|
+
color: $muted;
|
|
103
|
+
background: $surface;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.brilo-food-menu-preview__body {
|
|
108
|
+
border: 1px solid $line;
|
|
109
|
+
border-radius: 0 0 4px 4px;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.brilo-food-menu-preview__days {
|
|
113
|
+
display: flex;
|
|
114
|
+
overflow-x: auto;
|
|
115
|
+
// A shadow, not a border: the selected tab's underline paints over it
|
|
116
|
+
// without a negative margin, which would make the strip scroll vertically.
|
|
117
|
+
box-shadow: inset 0 -1px 0 $line;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.brilo-food-menu-preview__day {
|
|
121
|
+
display: flex;
|
|
122
|
+
gap: 6px;
|
|
123
|
+
align-items: center;
|
|
124
|
+
margin: 0;
|
|
125
|
+
padding: 8px 14px;
|
|
126
|
+
color: $muted;
|
|
127
|
+
font: inherit;
|
|
128
|
+
font-size: 13px;
|
|
129
|
+
white-space: nowrap;
|
|
130
|
+
background: none;
|
|
131
|
+
border: 0;
|
|
132
|
+
border-bottom: 2px solid transparent;
|
|
133
|
+
border-radius: 0;
|
|
134
|
+
cursor: pointer;
|
|
135
|
+
|
|
136
|
+
&[aria-selected="true"] {
|
|
137
|
+
color: $fg;
|
|
138
|
+
font-weight: 600;
|
|
139
|
+
border-bottom-color: $accent;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
&:focus-visible {
|
|
143
|
+
outline: 2px solid $accent;
|
|
144
|
+
outline-offset: -2px;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.brilo-food-menu-preview__dot {
|
|
149
|
+
width: 6px;
|
|
150
|
+
height: 6px;
|
|
151
|
+
background: $ok;
|
|
152
|
+
border-radius: 50%;
|
|
153
|
+
|
|
154
|
+
&--off {
|
|
155
|
+
background: $line;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.brilo-food-menu-preview__section {
|
|
160
|
+
padding: 10px 14px 4px;
|
|
161
|
+
|
|
162
|
+
& + & {
|
|
163
|
+
border-top: 1px solid $line;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.brilo-food-menu-preview__section-title {
|
|
168
|
+
margin: 0 0 4px;
|
|
169
|
+
color: $muted;
|
|
170
|
+
font-weight: 600;
|
|
171
|
+
font-size: 11px;
|
|
172
|
+
letter-spacing: 0.08em;
|
|
173
|
+
text-transform: uppercase;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.brilo-food-menu-preview__row {
|
|
177
|
+
display: grid;
|
|
178
|
+
grid-template-columns: 48px 1fr auto;
|
|
179
|
+
gap: 10px;
|
|
180
|
+
align-items: baseline;
|
|
181
|
+
padding: 6px 0;
|
|
182
|
+
font-size: 14px;
|
|
183
|
+
|
|
184
|
+
&--no-price {
|
|
185
|
+
grid-template-columns: 48px 1fr;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.brilo-food-menu-preview__unit {
|
|
190
|
+
color: $muted;
|
|
191
|
+
font-size: 12px;
|
|
192
|
+
font-variant-numeric: tabular-nums;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.brilo-food-menu-preview__name {
|
|
196
|
+
min-width: 0;
|
|
197
|
+
|
|
198
|
+
&--missing {
|
|
199
|
+
color: $muted;
|
|
200
|
+
font-style: italic;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.brilo-food-menu-preview__note {
|
|
205
|
+
display: block;
|
|
206
|
+
color: $muted;
|
|
207
|
+
font-size: 12px;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.brilo-food-menu-preview__chip {
|
|
211
|
+
display: inline-block;
|
|
212
|
+
margin-left: 4px;
|
|
213
|
+
padding: 0 5px;
|
|
214
|
+
color: $muted;
|
|
215
|
+
font-weight: 600;
|
|
216
|
+
font-size: 11px;
|
|
217
|
+
font-variant-numeric: tabular-nums;
|
|
218
|
+
line-height: 16px;
|
|
219
|
+
background: $surface;
|
|
220
|
+
border: 1px solid $line;
|
|
221
|
+
border-radius: 3px;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.brilo-food-menu-preview__price {
|
|
225
|
+
font-variant-numeric: tabular-nums;
|
|
226
|
+
white-space: nowrap;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.brilo-food-menu-preview__foot {
|
|
230
|
+
display: flex;
|
|
231
|
+
flex-wrap: wrap;
|
|
232
|
+
gap: 10px;
|
|
233
|
+
justify-content: space-between;
|
|
234
|
+
padding: 8px 14px;
|
|
235
|
+
color: $muted;
|
|
236
|
+
font-size: 12px;
|
|
237
|
+
background: $surface;
|
|
238
|
+
border-top: 1px solid $line;
|
|
239
|
+
border-radius: 0 0 4px 4px;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
.brilo-food-menu-preview__empty {
|
|
243
|
+
display: flex;
|
|
244
|
+
gap: 12px;
|
|
245
|
+
align-items: flex-start;
|
|
246
|
+
padding: 14px 16px;
|
|
247
|
+
color: $muted;
|
|
248
|
+
font-size: 14px;
|
|
249
|
+
border: 1px dashed $line;
|
|
250
|
+
border-radius: 4px;
|
|
251
|
+
|
|
252
|
+
b {
|
|
253
|
+
display: block;
|
|
254
|
+
color: $fg;
|
|
255
|
+
font-weight: 600;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.brilo-food-menu-preview__empty-icon {
|
|
260
|
+
flex: none;
|
|
261
|
+
width: 20px;
|
|
262
|
+
height: 20px;
|
|
263
|
+
color: $warn;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
.brilo-food-menu-preview__retry {
|
|
267
|
+
margin-top: 8px;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type {BlockConfiguration} from '@wordpress/blocks'
|
|
2
|
+
import {__} from '@wordpress/i18n'
|
|
3
|
+
import {
|
|
4
|
+
FOOD_MENU_GROUP_EMPTY_BEHAVIOUR,
|
|
5
|
+
FOOD_MENU_GROUP_EMPTY_BEHAVIOURS,
|
|
6
|
+
FOOD_MENU_GROUP_LAYOUT,
|
|
7
|
+
FOOD_MENU_GROUP_LAYOUTS,
|
|
8
|
+
FOOD_MENU_GROUP_MODE,
|
|
9
|
+
FOOD_MENU_GROUP_MODES,
|
|
10
|
+
} from './constants'
|
|
11
|
+
import {createFoodMenuGroupEdit} from './edit'
|
|
12
|
+
import {icon as defaultIcon} from './icon'
|
|
13
|
+
import type {FoodMenuGroupAttributes, FoodMenuGroupOptions} from './types'
|
|
14
|
+
|
|
15
|
+
export function createFoodMenuGroupBlock(options: FoodMenuGroupOptions): BlockConfiguration<FoodMenuGroupAttributes> {
|
|
16
|
+
return {
|
|
17
|
+
name: options.name,
|
|
18
|
+
title: options.title ?? __('Jídelní lístek', 'brilo-blocks'),
|
|
19
|
+
description: options.description ?? __('Zobrazí vybraný lístek, dnešní denní lístek nebo celý týden.', 'brilo-blocks'),
|
|
20
|
+
category: options.category ?? 'widgets',
|
|
21
|
+
...(options.parent && {parent: options.parent}),
|
|
22
|
+
icon: options.icon ?? {src: defaultIcon},
|
|
23
|
+
supports: {html: false, customClassName: false},
|
|
24
|
+
attributes: {
|
|
25
|
+
mode: {
|
|
26
|
+
type: 'string',
|
|
27
|
+
default: FOOD_MENU_GROUP_MODE,
|
|
28
|
+
enum: [...FOOD_MENU_GROUP_MODES],
|
|
29
|
+
},
|
|
30
|
+
layout: {
|
|
31
|
+
type: 'string',
|
|
32
|
+
default: FOOD_MENU_GROUP_LAYOUT,
|
|
33
|
+
enum: [...FOOD_MENU_GROUP_LAYOUTS],
|
|
34
|
+
},
|
|
35
|
+
menuIds: {
|
|
36
|
+
type: 'array',
|
|
37
|
+
default: [],
|
|
38
|
+
items: {type: 'number'},
|
|
39
|
+
},
|
|
40
|
+
showPrices: {
|
|
41
|
+
type: 'boolean',
|
|
42
|
+
default: true,
|
|
43
|
+
},
|
|
44
|
+
showAllergens: {
|
|
45
|
+
type: 'boolean',
|
|
46
|
+
default: true,
|
|
47
|
+
},
|
|
48
|
+
showReservation: {
|
|
49
|
+
type: 'boolean',
|
|
50
|
+
default: true,
|
|
51
|
+
},
|
|
52
|
+
emptyBehaviour: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
default: FOOD_MENU_GROUP_EMPTY_BEHAVIOUR,
|
|
55
|
+
enum: [...FOOD_MENU_GROUP_EMPTY_BEHAVIOURS],
|
|
56
|
+
},
|
|
57
|
+
// Empty means "use the wording the server picks for this mode".
|
|
58
|
+
emptyText: {
|
|
59
|
+
type: 'string',
|
|
60
|
+
default: '',
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
edit: createFoodMenuGroupEdit(options),
|
|
64
|
+
save: () => null,
|
|
65
|
+
} as unknown as BlockConfiguration<FoodMenuGroupAttributes>
|
|
66
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const icon = (
|
|
2
|
+
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Jídelní lístek">
|
|
3
|
+
<rect x="3" y="2" width="14" height="16" stroke="currentColor" fill="none" />
|
|
4
|
+
<line x1="6" y1="6" x2="14" y2="6" stroke="currentColor" />
|
|
5
|
+
<line x1="6" y1="10" x2="14" y2="10" stroke="currentColor" />
|
|
6
|
+
<line x1="6" y1="14" x2="11" y2="14" stroke="currentColor" />
|
|
7
|
+
</svg>
|
|
8
|
+
)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type {
|
|
2
|
+
FoodMenuGroupAttributes,
|
|
3
|
+
FoodMenuGroupEmptyBehaviour,
|
|
4
|
+
FoodMenuGroupLayout,
|
|
5
|
+
FoodMenuGroupMode,
|
|
6
|
+
FoodMenuGroupOptions,
|
|
7
|
+
} from './types'
|
|
8
|
+
export {createFoodMenuGroupBlock} from './factory'
|
|
9
|
+
export {FoodMenuSelectModal} from './FoodMenuSelectModal'
|
|
10
|
+
|
|
11
|
+
import type {FoodMenuGroupOptions} from './types'
|
|
12
|
+
|
|
13
|
+
export const foodMenuGroupDefaults: FoodMenuGroupOptions = {
|
|
14
|
+
name: 'brilo/food-menu-group',
|
|
15
|
+
// Also allowed inside a content column, so a menu can sit next to a gallery.
|
|
16
|
+
parent: ['brilo/base-section', 'brilo/column-item'],
|
|
17
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type {BriloBlockType, SelectControlProps} from '~/types'
|
|
2
|
+
import type {FOOD_MENU_GROUP_EMPTY_BEHAVIOURS, FOOD_MENU_GROUP_LAYOUTS, FOOD_MENU_GROUP_MODES} from './constants'
|
|
3
|
+
|
|
4
|
+
export type FoodMenuGroupMode = (typeof FOOD_MENU_GROUP_MODES)[number]
|
|
5
|
+
export type FoodMenuGroupLayout = (typeof FOOD_MENU_GROUP_LAYOUTS)[number]
|
|
6
|
+
export type FoodMenuGroupEmptyBehaviour = (typeof FOOD_MENU_GROUP_EMPTY_BEHAVIOURS)[number]
|
|
7
|
+
|
|
8
|
+
export interface FoodMenuGroupAttributes extends Record<string, unknown> {
|
|
9
|
+
mode: FoodMenuGroupMode
|
|
10
|
+
layout: FoodMenuGroupLayout
|
|
11
|
+
menuIds: number[]
|
|
12
|
+
showPrices: boolean
|
|
13
|
+
showAllergens: boolean
|
|
14
|
+
showReservation: boolean
|
|
15
|
+
emptyBehaviour: FoodMenuGroupEmptyBehaviour
|
|
16
|
+
emptyText: string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface FoodMenuGroupOptions extends BriloBlockType {
|
|
20
|
+
renderMenusControl?: (props: SelectControlProps) => JSX.Element
|
|
21
|
+
}
|
|
@@ -12,7 +12,7 @@ import type {FormGroupOptions} from './types'
|
|
|
12
12
|
|
|
13
13
|
export const formGroupDefaults: FormGroupOptions = {
|
|
14
14
|
name: 'brilo/form-group',
|
|
15
|
-
parent: ['brilo/base-section'],
|
|
15
|
+
parent: ['brilo/base-section', 'brilo/column-item', 'brilo/responsive-grid-item'],
|
|
16
16
|
allowedBlocks: ['brilo/form-field'],
|
|
17
17
|
template: [['brilo/form-field', {type: 'text'}]],
|
|
18
18
|
}
|
|
@@ -1,10 +1,3 @@
|
|
|
1
1
|
export const DEFAULT_COLUMNS = [2, 3, 4, 6] as const
|
|
2
2
|
|
|
3
|
-
export
|
|
4
|
-
{value: '4:3', label: '4:3'},
|
|
5
|
-
{value: '16:9', label: '16:9'},
|
|
6
|
-
{value: '3:2', label: '3:2'},
|
|
7
|
-
{value: '1:1', label: '1:1'},
|
|
8
|
-
{value: '2:1', label: '2:1'},
|
|
9
|
-
{value: '3:4', label: '3:4'},
|
|
10
|
-
] as const
|
|
3
|
+
export {GALLERY_RATIOS as DEFAULT_RATIOS} from '~/constants'
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {InspectorControls
|
|
1
|
+
import {InspectorControls} from '@wordpress/block-editor'
|
|
2
2
|
import {
|
|
3
3
|
PanelBody,
|
|
4
4
|
TextControl,
|
|
@@ -6,19 +6,13 @@ import {
|
|
|
6
6
|
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
|
7
7
|
} from '@wordpress/components'
|
|
8
8
|
import {__} from '@wordpress/i18n'
|
|
9
|
-
import {useDispatch} from '@wordpress/data'
|
|
10
|
-
import {createBlock} from '@wordpress/blocks'
|
|
11
9
|
import clsx from 'clsx'
|
|
10
|
+
import {GalleryImagesAppender} from '~/components/GalleryImagesAppender'
|
|
12
11
|
import {ItemSpacingPanel, itemSpacingStyle} from '~/components/ItemSpacingControl'
|
|
13
12
|
import {useGroupBlock} from '~/hooks/useGroupBlock'
|
|
14
13
|
import {DEFAULT_COLUMNS, DEFAULT_RATIOS} from './constants'
|
|
15
14
|
import type {GalleryGroupAttributes, GalleryGroupOptions, GalleryRatio} from './types'
|
|
16
15
|
|
|
17
|
-
type Media = {
|
|
18
|
-
id: number
|
|
19
|
-
url: string
|
|
20
|
-
}
|
|
21
|
-
|
|
22
16
|
export function createGalleryGroupEdit(options: GalleryGroupOptions) {
|
|
23
17
|
const COLUMNS = options.columns ?? DEFAULT_COLUMNS
|
|
24
18
|
const RATIOS = options.ratios ?? DEFAULT_RATIOS
|
|
@@ -33,36 +27,6 @@ export function createGalleryGroupEdit(options: GalleryGroupOptions) {
|
|
|
33
27
|
clientId: string
|
|
34
28
|
}) {
|
|
35
29
|
const {columns, ratio, galleryId, spacing} = attributes
|
|
36
|
-
const {insertBlock} = useDispatch('core/block-editor')
|
|
37
|
-
|
|
38
|
-
const addNewBlock = (imageId: number) => {
|
|
39
|
-
const newBlock = createBlock(options.allowedBlocks[0], {
|
|
40
|
-
img: {
|
|
41
|
-
id: imageId,
|
|
42
|
-
},
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
insertBlock(newBlock, undefined, clientId)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const onSelectImages = (media: Media[]) => {
|
|
49
|
-
media.forEach((item) => addNewBlock(item.id))
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const CustomAppender = () => {
|
|
53
|
-
return (
|
|
54
|
-
<MediaUpload
|
|
55
|
-
onSelect={onSelectImages}
|
|
56
|
-
multiple="add"
|
|
57
|
-
allowedTypes={['image']}
|
|
58
|
-
render={({open}) => (
|
|
59
|
-
<div onClick={open} className="g-gallery__appender">
|
|
60
|
-
{__('Přidat obrázky', 'brilo-blocks')}
|
|
61
|
-
</div>
|
|
62
|
-
)}
|
|
63
|
-
/>
|
|
64
|
-
)
|
|
65
|
-
}
|
|
66
30
|
|
|
67
31
|
const {blockProps, innerBlocksProps} = useGroupBlock({
|
|
68
32
|
blockClassName: clsx(options.blockClassName ?? 'g-gallery wp-block-section'),
|
|
@@ -73,7 +37,7 @@ export function createGalleryGroupEdit(options: GalleryGroupOptions) {
|
|
|
73
37
|
...itemSpacingStyle(spacing),
|
|
74
38
|
},
|
|
75
39
|
allowedBlocks: options.allowedBlocks,
|
|
76
|
-
renderAppender:
|
|
40
|
+
renderAppender: () => <GalleryImagesAppender clientId={clientId} itemBlock={options.allowedBlocks[0]} />,
|
|
77
41
|
template: options.template,
|
|
78
42
|
layout: {type: 'default'},
|
|
79
43
|
})
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
.g-gallery__appender {
|
|
2
|
-
padding: 16px;
|
|
3
|
-
display: flex;
|
|
4
|
-
align-items: center;
|
|
5
|
-
justify-content: center;
|
|
6
|
-
border: 2px dashed lightblue;
|
|
7
|
-
height: 100%;
|
|
8
|
-
cursor: pointer;
|
|
9
|
-
box-sizing: border-box;
|
|
10
|
-
min-height: 256px;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
1
|
.g-gallery {
|
|
14
2
|
.block-list-appender {
|
|
15
3
|
width: 100%;
|
|
@@ -5,7 +5,7 @@ import type {GalleryGroupOptions} from './types'
|
|
|
5
5
|
|
|
6
6
|
export const galleryGroupDefaults: GalleryGroupOptions = {
|
|
7
7
|
name: 'brilo/gallery-group',
|
|
8
|
-
parent: ['brilo/base-section'],
|
|
8
|
+
parent: ['brilo/base-section', 'brilo/column-item'],
|
|
9
9
|
allowedBlocks: ['brilo/gallery-item'],
|
|
10
10
|
template: [],
|
|
11
11
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {__} from '@wordpress/i18n'
|
|
2
|
+
|
|
3
|
+
export const HEIGHTS = [
|
|
4
|
+
{value: 'sm', label: __('Malá', 'brilo-blocks')},
|
|
5
|
+
{value: 'md', label: __('Střední', 'brilo-blocks')},
|
|
6
|
+
{value: 'lg', label: __('Velká', 'brilo-blocks')},
|
|
7
|
+
] as const
|
|
8
|
+
|
|
9
|
+
export const SPEEDS = [
|
|
10
|
+
{value: 'slow', label: __('Pomalu', 'brilo-blocks')},
|
|
11
|
+
{value: 'medium', label: __('Středně', 'brilo-blocks')},
|
|
12
|
+
{value: 'fast', label: __('Rychle', 'brilo-blocks')},
|
|
13
|
+
] as const
|
|
14
|
+
|
|
15
|
+
export const DIRECTIONS = [
|
|
16
|
+
{value: 'left', label: __('Doleva', 'brilo-blocks')},
|
|
17
|
+
{value: 'right', label: __('Doprava', 'brilo-blocks')},
|
|
18
|
+
] as const
|
|
19
|
+
|
|
20
|
+
export {GALLERY_RATIOS as DEFAULT_RATIOS} from '~/constants'
|
|
21
|
+
|
|
22
|
+
export const HEIGHT_PIXELS = {sm: 160, md: 240, lg: 320} as const
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import {InspectorControls} from '@wordpress/block-editor'
|
|
2
|
+
import {
|
|
3
|
+
PanelBody,
|
|
4
|
+
__experimentalToggleGroupControl as ToggleGroupControl,
|
|
5
|
+
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
|
6
|
+
} from '@wordpress/components'
|
|
7
|
+
import {__} from '@wordpress/i18n'
|
|
8
|
+
import clsx from 'clsx'
|
|
9
|
+
import {GalleryImagesAppender} from '~/components/GalleryImagesAppender'
|
|
10
|
+
import {ItemSpacingPanel, itemSpacingStyle} from '~/components/ItemSpacingControl'
|
|
11
|
+
import {useGroupBlock} from '~/hooks/useGroupBlock'
|
|
12
|
+
import {DEFAULT_RATIOS, DIRECTIONS, HEIGHTS, HEIGHT_PIXELS, SPEEDS} from './constants'
|
|
13
|
+
import type {
|
|
14
|
+
GalleryStripDirection,
|
|
15
|
+
GalleryStripGroupAttributes,
|
|
16
|
+
GalleryStripGroupOptions,
|
|
17
|
+
GalleryStripHeight,
|
|
18
|
+
GalleryStripRatio,
|
|
19
|
+
GalleryStripSpeed,
|
|
20
|
+
} from './types'
|
|
21
|
+
|
|
22
|
+
export function createGalleryStripGroupEdit(options: GalleryStripGroupOptions) {
|
|
23
|
+
const RATIOS = options.ratios ?? DEFAULT_RATIOS
|
|
24
|
+
|
|
25
|
+
return function Edit({
|
|
26
|
+
attributes,
|
|
27
|
+
setAttributes,
|
|
28
|
+
clientId,
|
|
29
|
+
}: {
|
|
30
|
+
attributes: GalleryStripGroupAttributes
|
|
31
|
+
setAttributes: (a: Partial<GalleryStripGroupAttributes>) => void
|
|
32
|
+
clientId: string
|
|
33
|
+
}) {
|
|
34
|
+
const {height, ratio, speed, direction, spacing} = attributes
|
|
35
|
+
const heightPx = HEIGHT_PIXELS[height] ?? HEIGHT_PIXELS.md
|
|
36
|
+
const [ratioWidth, ratioHeight] = ratio.split(':').map(Number)
|
|
37
|
+
|
|
38
|
+
const {blockProps, innerBlocksProps} = useGroupBlock({
|
|
39
|
+
blockClassName: clsx(
|
|
40
|
+
options.blockClassName ?? 'g-gallery g-gallery-strip wp-block-section',
|
|
41
|
+
`--speed-${speed}`,
|
|
42
|
+
`--direction-${direction}`,
|
|
43
|
+
),
|
|
44
|
+
containerClassName: options.containerClassName ?? 'g-gallery-strip__track',
|
|
45
|
+
containerStyle: {
|
|
46
|
+
'--gallery-strip-height': `${heightPx}px`,
|
|
47
|
+
'--gallery-strip-item-width': `${Math.round((heightPx * ratioWidth) / ratioHeight)}px`,
|
|
48
|
+
...itemSpacingStyle(spacing),
|
|
49
|
+
},
|
|
50
|
+
allowedBlocks: options.allowedBlocks,
|
|
51
|
+
orientation: 'horizontal',
|
|
52
|
+
renderAppender: () => <GalleryImagesAppender clientId={clientId} itemBlock={options.allowedBlocks[0]} />,
|
|
53
|
+
template: options.template,
|
|
54
|
+
layout: {type: 'default'},
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<>
|
|
59
|
+
<InspectorControls>
|
|
60
|
+
<PanelBody title={__('Rozložení', 'brilo-blocks')}>
|
|
61
|
+
<ToggleGroupControl
|
|
62
|
+
isBlock
|
|
63
|
+
label={__('Výška', 'brilo-blocks')}
|
|
64
|
+
value={height}
|
|
65
|
+
onChange={(v) => setAttributes({height: v as GalleryStripHeight})}
|
|
66
|
+
>
|
|
67
|
+
{HEIGHTS.map((h) => (
|
|
68
|
+
<ToggleGroupControlOption key={h.value} value={h.value} label={h.label} />
|
|
69
|
+
))}
|
|
70
|
+
</ToggleGroupControl>
|
|
71
|
+
<ToggleGroupControl
|
|
72
|
+
isBlock
|
|
73
|
+
label={__('Poměr stran', 'brilo-blocks')}
|
|
74
|
+
value={ratio}
|
|
75
|
+
onChange={(v) => setAttributes({ratio: v as GalleryStripRatio})}
|
|
76
|
+
>
|
|
77
|
+
{RATIOS.map((r) => (
|
|
78
|
+
<ToggleGroupControlOption key={r.value} value={r.value} label={r.label} />
|
|
79
|
+
))}
|
|
80
|
+
</ToggleGroupControl>
|
|
81
|
+
</PanelBody>
|
|
82
|
+
<PanelBody title={__('Animace', 'brilo-blocks')}>
|
|
83
|
+
<ToggleGroupControl
|
|
84
|
+
isBlock
|
|
85
|
+
label={__('Rychlost', 'brilo-blocks')}
|
|
86
|
+
value={speed}
|
|
87
|
+
onChange={(v) => setAttributes({speed: v as GalleryStripSpeed})}
|
|
88
|
+
>
|
|
89
|
+
{SPEEDS.map((s) => (
|
|
90
|
+
<ToggleGroupControlOption key={s.value} value={s.value} label={s.label} />
|
|
91
|
+
))}
|
|
92
|
+
</ToggleGroupControl>
|
|
93
|
+
<ToggleGroupControl
|
|
94
|
+
isBlock
|
|
95
|
+
label={__('Směr', 'brilo-blocks')}
|
|
96
|
+
value={direction}
|
|
97
|
+
onChange={(v) => setAttributes({direction: v as GalleryStripDirection})}
|
|
98
|
+
>
|
|
99
|
+
{DIRECTIONS.map((d) => (
|
|
100
|
+
<ToggleGroupControlOption key={d.value} value={d.value} label={d.label} />
|
|
101
|
+
))}
|
|
102
|
+
</ToggleGroupControl>
|
|
103
|
+
</PanelBody>
|
|
104
|
+
<ItemSpacingPanel spacing={spacing} onChange={(v) => setAttributes({spacing: v})} />
|
|
105
|
+
</InspectorControls>
|
|
106
|
+
<div {...blockProps}>
|
|
107
|
+
<div {...innerBlocksProps} />
|
|
108
|
+
</div>
|
|
109
|
+
</>
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
.g-gallery-strip {
|
|
2
|
+
// Horizontal scroll only: items get a fixed width (height × ratio) and grow
|
|
3
|
+
// vertically to fit the gallery-item controls instead of overflowing.
|
|
4
|
+
.g-gallery-strip__track {
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-wrap: nowrap;
|
|
7
|
+
align-items: stretch;
|
|
8
|
+
gap: 16px;
|
|
9
|
+
overflow-x: auto;
|
|
10
|
+
overflow-y: hidden;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.g-gallery-strip__track > .wp-block,
|
|
14
|
+
.g-gallery-strip__track > .block-list-appender {
|
|
15
|
+
flex: 0 0 var(--gallery-strip-item-width);
|
|
16
|
+
width: var(--gallery-strip-item-width);
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
min-height: var(--gallery-strip-height);
|
|
20
|
+
margin: 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.i-gallery {
|
|
24
|
+
display: flex;
|
|
25
|
+
flex: 1;
|
|
26
|
+
flex-direction: column;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.i-gallery__image-wrapper {
|
|
30
|
+
flex: 1;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.g-gallery__appender {
|
|
34
|
+
min-height: var(--gallery-strip-height);
|
|
35
|
+
}
|
|
36
|
+
}
|