Skip to content

Commit

Permalink
feat(nossas): add column size to mobile grid
Browse files Browse the repository at this point in the history
  • Loading branch information
igr-santos committed Apr 8, 2024
1 parent 46016ee commit d0861c8
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.2 on 2024-04-04 13:12

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('plugins', '0034_fullpageslider_background_size'),
]

operations = [
migrations.AddField(
model_name='grid',
name='grid_layout_mobile',
field=models.CharField(choices=[(' ', 'Auto'), ('g-col-12', '1 Coluna'), ('g-col-12 g-col-md-6', '2 Colunas'), ('g-col-12 g-col-md-4', '3 Colunas'), ('g-col-12 g-col-md-3', '4 Colunas'), ('g-col-12 g-col-md-2', '6 Colunas'), ('g-col-12 g-col-md-1', '12 Colunas')], default='g-col-12', max_length=80, verbose_name='Layout do Grid Mobile'),
),
migrations.AlterField(
model_name='fullpageslider',
name='background_size',
field=models.CharField(choices=[('contain', 'Contain'), ('cover', 'Cover'), ('initial', 'Initial')], default='contain', max_length=8),
),
]
17 changes: 17 additions & 0 deletions app/nossas/plugins/models/gridmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ class Grid(CMSPlugin):
choices=GridLayoutChoices.choices,
help_text="Escolha 'Auto' para um layout responsivo automático ou para selecionar o número de colunas manualmente.",
)
grid_layout_mobile = models.CharField(
"Layout do Grid Mobile",
max_length=80,
default=GridLayoutChoices.grid_1,
choices=GridLayoutChoices.choices,
# help_text="Escolha 'Auto' para um layout responsivo automático ou para selecionar o número de colunas manualmente.",
)
grid_gap = models.CharField(
"Espaçamento do Grid",
default=GridSpacingChoices.gap_0,
Expand All @@ -43,6 +50,16 @@ class Grid(CMSPlugin):
help_text="Selecione o espaço entre colunas do Grid.",
)

@property
def responsive_sizes(self):
if self.grid_layout_mobile == 'g-col-12':
classes = self.grid_layout_mobile
else:
classes = self.grid_layout_mobile.replace("g-col-12", "").replace("-md", "")
classes += self.grid_layout.replace("g-col-12", "")

return classes


class ColumnChoices(models.TextChoices):
auto = " ", "Auto"
Expand Down
2 changes: 1 addition & 1 deletion app/nossas/plugins/templates/nossas/plugins/column.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% load cms_tags %}

<div class="d-flex flex-column {{ instance.col }} {{ parent_instance.grid_layout }} {{ instance.col_start_at }}" style="{{ instance.spacing }} {{ instance.alignment_x }} {{ instance.alignment_y }} {{ instance.rows }}">
<div class="d-flex flex-column {{ instance.col }} {{ parent_instance.responsive_sizes }} {{ instance.col_start_at }}" style="{{ instance.spacing }} {{ instance.alignment_x }} {{ instance.alignment_y }} {{ instance.rows }}">
{% for plugin in instance.child_plugin_instances %}
{% render_plugin plugin %}
{% endfor %}
Expand Down

0 comments on commit d0861c8

Please sign in to comment.