2
2
import { ref , computed } from ' vue'
3
3
import componentHelpers from ' ../../utils/html-elements/componentHelpers'
4
4
import components from ' ../../utils/html-elements/component'
5
+ import themes from ' ../../utils/html-elements/themes'
5
6
import { usePageBuilderModal } from ' ../../composables/usePageBuilderModal'
6
7
import type { ComponentObject } from ' ../../types'
7
8
import { getPageBuilder } from ' ../../composables/builderInstance'
@@ -20,6 +21,9 @@ defineProps({
20
21
21
22
const isLoading = ref (false )
22
23
24
+ const selectedThemeSelection = ref (' Components' )
25
+
26
+ const componentOrThemes = [' Components' , ' Themes' ]
23
27
const selectedCategory = ref (' All' )
24
28
25
29
const categories = computed (() => {
@@ -34,9 +38,32 @@ const filteredComponents = computed(() => {
34
38
return components [0 ].components .data .filter ((comp ) => comp .category === selectedCategory .value )
35
39
})
36
40
41
+ const selectedThemeCategory = ref (' All' )
42
+
43
+ const themeCategories = computed (() => {
44
+ const allCategories = themes [0 ].themes .data .map ((comp ) => comp .category )
45
+ return [' All' , ... new Set (allCategories )]
46
+ })
47
+
48
+ const filteredThemes = computed (() => {
49
+ if (selectedThemeCategory .value === ' All' ) {
50
+ return themes [0 ].themes .data
51
+ }
52
+ return themes [0 ].themes .data .filter ((comp ) => comp .category === selectedThemeCategory .value )
53
+ })
54
+
37
55
// Get modal close function
38
56
const { closeAddComponentModal } = usePageBuilderModal ()
39
57
58
+ // Super simple component addition with professional modal closing!
59
+ const handleDropTheme = async function (components : string ) {
60
+ isLoading .value = true
61
+
62
+ await pageBuilderService .addTheme (components )
63
+ closeAddComponentModal ()
64
+ isLoading .value = false
65
+ }
66
+
40
67
// Super simple component addition with professional modal closing!
41
68
const handleDropComponent = async function (componentObject : ComponentObject ) {
42
69
isLoading .value = true
@@ -104,81 +131,151 @@ const convertToComponentObject = function (comp: any): ComponentObject {
104
131
</div >
105
132
</template >
106
133
<div v-if =" !isLoading" >
107
- <!-- Helper Components Section -->
108
- <div class =" pbx-mb-8" >
109
- <h3 class =" pbx-myQuaternaryHeader pbx-mb-4" >{{ translate('Helper Components') }}</h3 >
110
- <div
111
- class =" pbx-px-2 pbx-grid pbx-grid-cols-1 sm:pbx-grid-cols-2 md:pbx-grid-cols-3 lg:pbx-grid-cols-4 pbx-gap-4"
134
+ <div class =" pbx-mb-4 pbx-flex pbx-jusitify-left pbx-items-center pbx-gap-2" >
135
+ <button
136
+ v-for =" category in componentOrThemes"
137
+ :key =" category"
138
+ @click =" selectedThemeSelection = category"
139
+ class =" pbx-mySecondaryButton pbx-text-xs pbx-px-4"
140
+ :class =" [
141
+ selectedThemeSelection === category
142
+ ? 'pbx-bg-myPrimaryLinkColor pbx-text-white hover:pbx-bg-myPrimaryLinkColor hover:pbx-text-white'
143
+ : 'hover:pbx-bg-myPrimaryLinkColor hover:pbx-text-white',
144
+ ]"
112
145
>
146
+ {{ translate(category) }}
147
+ </button >
148
+ </div >
149
+
150
+ <!-- theme is selected start -->
151
+ <template v-if =" selectedThemeSelection === ' Themes' " >
152
+ <div class =" pbx-mb-8" >
153
+ <h3 class =" pbx-myQuaternaryHeader pbx-mb-4" >{{ translate('Themes') }}</h3 >
154
+ <div class =" pbx-mb-4 pbx-flex pbx-jusitify-left pbx-items-center pbx-gap-2" >
155
+ <button
156
+ v-for =" category in themeCategories"
157
+ :key =" category"
158
+ @click =" selectedThemeCategory = category"
159
+ class =" pbx-mySecondaryButton pbx-text-xs pbx-px-4"
160
+ :class =" [
161
+ selectedThemeCategory === category
162
+ ? 'pbx-bg-myPrimaryLinkColor pbx-text-white hover:pbx-bg-myPrimaryLinkColor hover:pbx-text-white'
163
+ : 'hover:pbx-bg-myPrimaryLinkColor hover:pbx-text-white',
164
+ ]"
165
+ >
166
+ {{ translate(category) }}
167
+ </button >
168
+ </div >
169
+
113
170
<div
114
- v-for =" helper in componentHelpers"
115
- :key =" helper.title"
116
- class =" pbx-border-solid pbx-border pbx-border-gray-400 pbx-overflow-hidden hover:pbx-border-myPrimaryLinkColor pbx-duration-100 pbx-cursor-pointer pbx-p-4"
117
- @click =" handleDropComponent(helper)"
171
+ class =" pbx-px-2 pbx-grid pbx-grid-cols-1 sm:pbx-grid-cols-2 md:pbx-grid-cols-3 lg:pbx-grid-cols-4 pbx-gap-4"
118
172
>
119
173
<div
120
- class =" pbx-max-h-72 pbx-cursor-pointer pbx-object-contain pbx-bg-white pbx-mx-auto"
174
+ v-for =" theme in filteredThemes"
175
+ :key =" theme.title"
176
+ class =" pbx-border-solid pbx-border pbx-border-gray-400 pbx-overflow-hidden hover:pbx-border-myPrimaryLinkColor pbx-duration-100 pbx-cursor-pointer"
177
+ @click =" handleDropTheme(theme.html_code)"
121
178
>
122
- <div v-if =" false" class =" pbx-mr-2" v-html =" helper.icon" ></div >
123
- <h4 class =" pbx-myPrimaryParagraph pbx-text-base pbx-font-medium" >
124
- {{ translate(helper.title) }}
125
- </h4 >
126
- </div >
127
- <div class =" pbx-myPrimaryParagraph pbx-text-xs pbx-font-normal pbx-pt-2" >
128
- {{ translate('Click to add') }} {{ helper.title.toLowerCase() }}
129
- {{ translate('component') }}
179
+ <div
180
+ class =" pbx-overflow-hidden pbx-whitespace-pre-line pbx-flex-1 pbx-h-auto pbx-border-0 pbx-border-solid pbx-border-b pbx-border-gray-200 lg:pbx-py-10 pbx-py-8 pbx-px-2"
181
+ >
182
+ <!-- Use SVG preview instead of external images -->
183
+ <div
184
+ class =" pbx-max-h-72 pbx-cursor-pointer pbx-bg-white pbx-mx-auto pbx-flex pbx-items-center pbx-justify-center"
185
+ v-html =" theme.cover_image"
186
+ ></div >
187
+ </div >
188
+ <div class =" pbx-p-3" >
189
+ <h4 class =" pbx-myPrimaryParagraph pbx-text-sm pbx-font-normal" >
190
+ {{ translate(theme.title) }}
191
+ </h4 >
192
+ <div class =" pbx-myPrimaryParagraph pbx-text-xs pbx-font-normal pbx-pt-2" >
193
+ {{ translate('Click to add theme') }}
194
+ </div >
195
+ </div >
130
196
</div >
131
197
</div >
132
198
</div >
133
- </div >
199
+ </template >
200
+ <!-- theme is selected end -->
134
201
135
- <!-- Regular Components Section -->
136
- <div class =" pbx-px-2" v-if =" customMediaComponent" >
137
- <h3 class =" pbx-myQuaternaryHeader pbx-mb-4" >{{ translate('Layout Components') }}</h3 >
138
- <div class =" pbx-mb-4 pbx-flex pbx-jusitify-left pbx-items-center pbx-gap-2" >
139
- <button
140
- v-for =" category in categories"
141
- :key =" category"
142
- @click =" selectedCategory = category"
143
- class =" pbx-mySecondaryButton pbx-text-xs pbx-px-4"
144
- :class =" [
145
- selectedCategory === category
146
- ? 'pbx-bg-myPrimaryLinkColor pbx-text-white hover:pbx-bg-myPrimaryLinkColor hover:pbx-text-white'
147
- : 'hover:pbx-bg-myPrimaryLinkColor hover:pbx-text-white',
148
- ]"
202
+ <template v-if =" selectedThemeSelection === ' Components' " >
203
+ <!-- Helper Components Section -->
204
+ <div class =" pbx-mb-8" >
205
+ <h3 class =" pbx-myQuaternaryHeader pbx-mb-4" >{{ translate('Helper Components') }}</h3 >
206
+ <div
207
+ class =" pbx-px-2 pbx-grid pbx-grid-cols-1 sm:pbx-grid-cols-2 md:pbx-grid-cols-3 lg:pbx-grid-cols-4 pbx-gap-4"
149
208
>
150
- {{ translate(category) }}
151
- </button >
209
+ <div
210
+ v-for =" helper in componentHelpers"
211
+ :key =" helper.title"
212
+ class =" pbx-border-solid pbx-border pbx-border-gray-400 pbx-overflow-hidden hover:pbx-border-myPrimaryLinkColor pbx-duration-100 pbx-cursor-pointer pbx-p-4"
213
+ @click =" handleDropComponent(helper)"
214
+ >
215
+ <div
216
+ class =" pbx-max-h-72 pbx-cursor-pointer pbx-object-contain pbx-bg-white pbx-mx-auto"
217
+ >
218
+ <div v-if =" false" class =" pbx-mr-2" v-html =" helper.icon" ></div >
219
+ <h4 class =" pbx-myPrimaryParagraph pbx-text-base pbx-font-medium" >
220
+ {{ translate(helper.title) }}
221
+ </h4 >
222
+ </div >
223
+ <div class =" pbx-myPrimaryParagraph pbx-text-xs pbx-font-normal pbx-pt-2" >
224
+ {{ translate('Click to add') }} {{ helper.title.toLowerCase() }}
225
+ {{ translate('component') }}
226
+ </div >
227
+ </div >
228
+ </div >
152
229
</div >
153
- <div
154
- class =" pbx-grid pbx-grid-cols-1 sm:pbx-grid-cols-2 md:pbx-grid-cols-3 pbx-gap-4 pbx-pb-4"
155
- >
230
+
231
+ <!-- Regular Components Section -->
232
+ <div class =" pbx-px-2" v-if =" customMediaComponent" >
233
+ <h3 class =" pbx-myQuaternaryHeader pbx-mb-4" >{{ translate('Layout Components') }}</h3 >
234
+ <div class =" pbx-mb-4 pbx-flex pbx-jusitify-left pbx-items-center pbx-gap-2" >
235
+ <button
236
+ v-for =" category in categories"
237
+ :key =" category"
238
+ @click =" selectedCategory = category"
239
+ class =" pbx-mySecondaryButton pbx-text-xs pbx-px-4"
240
+ :class =" [
241
+ selectedCategory === category
242
+ ? 'pbx-bg-myPrimaryLinkColor pbx-text-white hover:pbx-bg-myPrimaryLinkColor hover:pbx-text-white'
243
+ : 'hover:pbx-bg-myPrimaryLinkColor hover:pbx-text-white',
244
+ ]"
245
+ >
246
+ {{ translate(category) }}
247
+ </button >
248
+ </div >
156
249
<div
157
- v-for =" comp in filteredComponents"
158
- :key =" comp.title"
159
- class =" pbx-border-solid pbx-border pbx-border-gray-400 pbx-overflow-hidden hover:pbx-border-myPrimaryLinkColor pbx-duration-100 pbx-cursor-pointer"
160
- @click =" handleDropComponent(convertToComponentObject(comp))"
250
+ class =" pbx-grid pbx-grid-cols-1 sm:pbx-grid-cols-2 md:pbx-grid-cols-3 pbx-gap-4 pbx-pb-4"
161
251
>
162
252
<div
163
- class =" pbx-overflow-hidden pbx-whitespace-pre-line pbx-flex-1 pbx-h-auto pbx-border-0 pbx-border-solid pbx-border-b pbx-border-gray-200 lg:pbx-py-10 pbx-py-8 pbx-px-2"
253
+ v-for =" comp in filteredComponents"
254
+ :key =" comp.title"
255
+ class =" pbx-border-solid pbx-border pbx-border-gray-400 pbx-overflow-hidden hover:pbx-border-myPrimaryLinkColor pbx-duration-100 pbx-cursor-pointer"
256
+ @click =" handleDropComponent(convertToComponentObject(comp))"
164
257
>
165
- <!-- Use SVG preview instead of external images -->
166
258
<div
167
- class =" pbx-max-h-72 pbx-cursor-pointer pbx-bg-white pbx-mx-auto pbx-flex pbx-items-center pbx-justify-center"
168
- v-html =" comp.cover_image"
169
- ></div >
170
- </div >
171
- <div class =" pbx-p-3" >
172
- <h4 class =" pbx-myPrimaryParagraph pbx-text-sm pbx-font-normal" >
173
- {{ translate(comp.title) }}
174
- </h4 >
175
- <div class =" pbx-myPrimaryParagraph pbx-text-xs pbx-font-normal pbx-pt-2" >
176
- {{ translate('Click to add component') }}
259
+ class =" pbx-overflow-hidden pbx-whitespace-pre-line pbx-flex-1 pbx-h-auto pbx-border-0 pbx-border-solid pbx-border-b pbx-border-gray-200 lg:pbx-py-10 pbx-py-8 pbx-px-2"
260
+ >
261
+ <!-- Use SVG preview instead of external images -->
262
+ <div
263
+ class =" pbx-max-h-72 pbx-cursor-pointer pbx-bg-white pbx-mx-auto pbx-flex pbx-items-center pbx-justify-center"
264
+ v-html =" comp.cover_image"
265
+ ></div >
266
+ </div >
267
+ <div class =" pbx-p-3" >
268
+ <h4 class =" pbx-myPrimaryParagraph pbx-text-sm pbx-font-normal" >
269
+ {{ translate(comp.title) }}
270
+ </h4 >
271
+ <div class =" pbx-myPrimaryParagraph pbx-text-xs pbx-font-normal pbx-pt-2" >
272
+ {{ translate('Click to add component') }}
273
+ </div >
177
274
</div >
178
275
</div >
179
276
</div >
180
277
</div >
181
- </div >
278
+ </template >
182
279
<div >
183
280
<button class =" pbx-sr-only" >Focusable fallback</button >
184
281
</div >
0 commit comments