|
1 | 1 | from django import forms |
2 | 2 | from django.conf import settings |
| 3 | +from django.core.validators import MinValueValidator |
3 | 4 | from django.utils.translation import gettext_lazy as _ |
4 | 5 | from djangocms_frontend.component_base import CMSFrontendComponent |
5 | 6 | from djangocms_frontend.component_pool import components |
6 | | -from djangocms_frontend.fields import HTMLFormField |
7 | | - |
8 | | -from djangocms_frontend.fields import ColoredButtonGroup |
| 7 | +from djangocms_frontend.fields import ColoredButtonGroup, HTMLFormField |
9 | 8 |
|
10 | 9 |
|
11 | 10 | @components.register |
@@ -75,7 +74,7 @@ class Meta: |
75 | 74 | required=False, |
76 | 75 | initial="default", |
77 | 76 | ) |
78 | | - |
| 77 | + |
79 | 78 |
|
80 | 79 | @components.register |
81 | 80 | class TimelineContainer(CMSFrontendComponent): |
@@ -173,8 +172,8 @@ class Meta: |
173 | 172 | required=False, |
174 | 173 | initial="flex-column", |
175 | 174 | ) |
176 | | - |
177 | | - |
| 175 | + |
| 176 | + |
178 | 177 | @components.register |
179 | 178 | class CTAPanel(CMSFrontendComponent): |
180 | 179 | """CTAPanel component with background grid option""" |
@@ -209,9 +208,68 @@ class Meta: |
209 | 208 | choices=[ |
210 | 209 | ("start", _("Start")), |
211 | 210 | ("center", _("Center (Default)")), |
212 | | - ("end", _("End")) |
| 211 | + ("end", _("End")), |
213 | 212 | ], |
214 | 213 | initial="center", |
215 | | - help_text=_("Controls horizontal alignment of all content") |
| 214 | + help_text=_("Controls horizontal alignment of all content"), |
| 215 | + ) |
| 216 | + |
| 217 | + |
| 218 | +@components.register |
| 219 | +class LogoCarousel(CMSFrontendComponent): |
| 220 | + """LogoCarousel component""" |
| 221 | + |
| 222 | + class Meta: |
| 223 | + name = _("Logo Carousel") |
| 224 | + render_template = "carousel/logo_carousel.html" |
| 225 | + allow_children = True |
| 226 | + child_classes = [ |
| 227 | + "HeadingPlugin", |
| 228 | + "CarouselItemPlugin", |
| 229 | + ] |
| 230 | + mixins = ["Background", "Spacing", "Attributes"] |
| 231 | + |
| 232 | + loop = forms.BooleanField( |
| 233 | + label=_("Loop Carousel"), |
| 234 | + required=False, |
| 235 | + initial=False, |
| 236 | + help_text=_( |
| 237 | + "Turn on to make the slides loop continuously from the last slide back to the first." |
| 238 | + ), |
| 239 | + ) |
| 240 | + |
| 241 | + space_between_slides = forms.IntegerField( |
| 242 | + label=_("Space Between Slides"), |
| 243 | + required=False, |
| 244 | + initial=20, |
| 245 | + validators=[MinValueValidator(0)], |
| 246 | + help_text=_("Set the space (in pixels) between each slide in the carousel."), |
| 247 | + ) |
| 248 | + |
| 249 | + autoplay = forms.BooleanField( |
| 250 | + label=_("AutoPlay"), |
| 251 | + required=False, |
| 252 | + initial=True, |
| 253 | + help_text=_( |
| 254 | + "Turn on to make the slides move automatically without manual navigation." |
| 255 | + ), |
216 | 256 | ) |
217 | 257 |
|
| 258 | + delay = forms.IntegerField( |
| 259 | + label=_("Autoplay delay"), |
| 260 | + required=False, |
| 261 | + initial=3000, |
| 262 | + validators=[MinValueValidator(500)], |
| 263 | + help_text=_( |
| 264 | + "Set the time (in milliseconds) each slide stays visible before moving to the next one." |
| 265 | + ), |
| 266 | + ) |
| 267 | + |
| 268 | + btn_color = forms.ChoiceField( |
| 269 | + label=_("Button Color"), |
| 270 | + choices=settings.DJANGOCMS_FRONTEND_COLOR_STYLE_CHOICES, |
| 271 | + required=False, |
| 272 | + initial="primary", |
| 273 | + widget=ColoredButtonGroup(attrs={"class": "flex-wrap"}), |
| 274 | + help_text=_("Color for the carousel button."), |
| 275 | + ) |
0 commit comments