Skip to content

Commit e0d3954

Browse files
committed
feat: add modal size control to announcements
1 parent 7dde203 commit e0d3954

File tree

5 files changed

+49
-3
lines changed

5 files changed

+49
-3
lines changed

app/announcements/admin.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55

66
@admin.register(Announcement)
77
class AnnouncementAdmin(admin.ModelAdmin):
8-
list_display = ("title", "is_published", "created_at", "updated_at")
9-
list_filter = ("is_published", "created_at")
8+
list_display = ("title", "modal_size", "is_published", "created_at", "updated_at")
9+
list_filter = ("is_published", "modal_size", "created_at")
1010
search_fields = ("title", "content")
1111
readonly_fields = ("created_at", "updated_at")
1212
fieldsets = (
1313
("Content", {"fields": ("title", "content")}),
14+
("Display", {"fields": ("modal_size",)}),
1415
("Status", {"fields": ("is_published",)}),
1516
("Metadata", {"fields": ("created_at", "updated_at")}),
1617
)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 5.2.7 on 2026-03-12 13:57
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('announcements', '0001_initial'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='announcement',
15+
name='modal_size',
16+
field=models.CharField(choices=[('md', 'Medium (default)'), ('lg', 'Large'), ('xl', 'Extra Large')], default='md', help_text='Width of the announcement modal', max_length=10),
17+
),
18+
]

app/announcements/models.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,20 @@
33

44

55
class Announcement(models.Model):
6+
MODAL_SIZES = [
7+
("md", "Medium (default)"),
8+
("lg", "Large"),
9+
("xl", "Extra Large"),
10+
]
11+
612
title = models.CharField(max_length=255)
713
content = HTMLField()
14+
modal_size = models.CharField(
15+
max_length=10,
16+
choices=MODAL_SIZES,
17+
default="md",
18+
help_text="Width of the announcement modal",
19+
)
820
is_published = models.BooleanField(default=False)
921
created_at = models.DateTimeField(auto_now_add=True)
1022
updated_at = models.DateTimeField(auto_now=True)

static/css/app.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3696,6 +3696,16 @@
36963696
width: 100%;
36973697
}
36983698
}
3699+
.lg\:max-w-2xl {
3700+
@media (width >= 64rem) {
3701+
max-width: var(--container-2xl);
3702+
}
3703+
}
3704+
.lg\:max-w-4xl {
3705+
@media (width >= 64rem) {
3706+
max-width: var(--container-4xl);
3707+
}
3708+
}
36993709
.lg\:max-w-\[100\%\] {
37003710
@media (width >= 64rem) {
37013711
max-width: 100%;
@@ -3711,6 +3721,11 @@
37113721
max-width: 452px;
37123722
}
37133723
}
3724+
.lg\:max-w-lg {
3725+
@media (width >= 64rem) {
3726+
max-width: var(--container-lg);
3727+
}
3728+
}
37143729
.lg\:grid-cols-2 {
37153730
@media (width >= 64rem) {
37163731
grid-template-columns: repeat(2, minmax(0, 1fr));

templates/includes/announcement_modal.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
{% if latest_announcement %}
77
<dialog id="announcement-modal" class="modal" open>
8-
<div class="modal-box bg-cream-1">
8+
<div class="modal-box {% if latest_announcement.modal_size == 'lg' %}lg:max-w-2xl{% elif latest_announcement.modal_size == 'xl' %}lg:max-w-4xl{% else %}lg:max-w-lg{% endif %}">
99
<h3 class="font-bold text-lg">📢 {{ latest_announcement.title }}</h3>
1010
<div class="py-4">
1111
{{ latest_announcement.content|safe }}

0 commit comments

Comments
 (0)