11from django import forms
22from django .conf import settings
3+ from django .core .validators import MinValueValidator
34from django .utils .translation import gettext_lazy as _
45from djangocms_frontend .component_base import CMSFrontendComponent
56from djangocms_frontend .component_pool import components
6- from djangocms_frontend .fields import HTMLFormField
7+ from djangocms_frontend .fields import ColoredButtonGroup , HTMLFormField
78from djangocms_frontend .contrib .icon .fields import IconPickerField
89
9- from djangocms_frontend .fields import ColoredButtonGroup
10-
1110
1211@components .register
1312class Hero (CMSFrontendComponent ):
@@ -76,7 +75,7 @@ class Meta:
7675 required = False ,
7776 initial = "default" ,
7877 )
79-
78+
8079
8180@components .register
8281class TimelineContainer (CMSFrontendComponent ):
@@ -174,8 +173,8 @@ class Meta:
174173 required = False ,
175174 initial = "flex-column" ,
176175 )
177-
178-
176+
177+
179178@components .register
180179class CTAPanel (CMSFrontendComponent ):
181180 """CTAPanel component with background grid option"""
@@ -210,13 +209,73 @@ class Meta:
210209 choices = [
211210 ("start" , _ ("Start" )),
212211 ("center" , _ ("Center (Default)" )),
213- ("end" , _ ("End" ))
212+ ("end" , _ ("End" )),
214213 ],
215214 initial = "center" ,
216- help_text = _ ("Controls horizontal alignment of all content" )
215+ help_text = _ ("Controls horizontal alignment of all content" ),
217216 )
218217
219218
219+ @components .register
220+ class LogoCarousel (CMSFrontendComponent ):
221+ """LogoCarousel component"""
222+
223+ class Meta :
224+ name = _ ("Logo Carousel" )
225+ render_template = "carousel/logo_carousel.html"
226+ allow_children = True
227+ child_classes = [
228+ "HeadingPlugin" ,
229+ "CarouselItemPlugin" ,
230+ ]
231+ mixins = ["Background" , "Spacing" , "Attributes" ]
232+
233+ loop = forms .BooleanField (
234+ label = _ ("Loop Carousel" ),
235+ required = False ,
236+ initial = False ,
237+ help_text = _ (
238+ "Turn on to make the slides loop continuously from the last slide back to the first."
239+ ),
240+ )
241+
242+ space_between_slides = forms .IntegerField (
243+ label = _ ("Space Between Slides" ),
244+ required = False ,
245+ initial = 20 ,
246+ validators = [MinValueValidator (0 )],
247+ help_text = _ ("Set the space (in pixels) between each slide in the carousel." ),
248+ )
249+
250+ autoplay = forms .BooleanField (
251+ label = _ ("AutoPlay" ),
252+ required = False ,
253+ initial = True ,
254+ help_text = _ (
255+ "Turn on to make the slides move automatically without manual navigation."
256+ ),
257+ )
258+
259+ delay = forms .IntegerField (
260+ label = _ ("Autoplay delay" ),
261+ required = False ,
262+ initial = 3000 ,
263+ validators = [MinValueValidator (500 )],
264+ help_text = _ (
265+ "Set the time (in milliseconds) each slide stays visible before moving to the next one."
266+ ),
267+ )
268+
269+ btn_color = forms .ChoiceField (
270+ label = _ ("Button Color" ),
271+ choices = settings .DJANGOCMS_FRONTEND_COLOR_STYLE_CHOICES ,
272+ required = False ,
273+ initial = "primary" ,
274+ widget = ColoredButtonGroup (attrs = {"class" : "flex-wrap" }),
275+ help_text = _ ("Color for the carousel button." ),
276+ )
277+
278+
220279@components .register
221280class BenefitsPanel (CMSFrontendComponent ):
222281 """Benefits panel component"""
@@ -270,6 +329,4 @@ class Meta:
270329 label = _ ("Icon" ),
271330 required = False ,
272331 )
273-
274-
275-
332+
0 commit comments