Skip to content

Add site banner#2111

Open
StenOskar wants to merge 8 commits intomasterfrom
stenhalse/web-50-banner-over-navbar
Open

Add site banner#2111
StenOskar wants to merge 8 commits intomasterfrom
stenhalse/web-50-banner-over-navbar

Conversation

@StenOskar
Copy link
Copy Markdown
Contributor

Adds support for site-wide banners managed through Django admin.

  • Add SiteBanner model, serializer, view, route, and admin registration
  • Add Migration for site banner
  • Add frontend SiteBanner component

Notes

  • active banners are fetched from /api/site-banners/active/
  • current frontend renders the first active banner
  • to test make a banner on the Django admin panel

@StenOskar StenOskar self-assigned this Mar 12, 2026
@0xSpecter
Copy link
Copy Markdown
Contributor

Sliter med å reviewe siden den er så langt bak master, prøv å merge / rebase på master først.

@aTrueYety
Copy link
Copy Markdown
Contributor

image Text not centered image Large text blocks overflow image Large part of the title image is covered by the information box

@aTrueYety
Copy link
Copy Markdown
Contributor

Would be nice with some docs on how this works (untill the frontend is setup). Would also be nice if the selection of what banner is shown was explained somewhere

@aTrueYety
Copy link
Copy Markdown
Contributor

image

Copy link
Copy Markdown
Contributor

@aTrueYety aTrueYety left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Main thing looks good but some bugs

@StenOskar
Copy link
Copy Markdown
Contributor Author

StenOskar commented Mar 17, 2026

For testing, this is an example of using link:

url: /events

@StenOskar
Copy link
Copy Markdown
Contributor Author

To make a banner, go to Django admin site on /admin/samfundet/sitebanner/

Simplify SiteBanner to use a single url (and new_tab flag) instead of multiple links and severity. Migration updated. Frontend: styles improved for centering, truncation and responsive layout.
@StenOskar StenOskar requested a review from aTrueYety March 17, 2026 20:59
@aTrueYety
Copy link
Copy Markdown
Contributor

image http://localhost:8000/admin/samfundet/sitebanner/

@StenOskar
Copy link
Copy Markdown
Contributor Author

Meg når jeg ikke tar å migrate ^^

Comment thread backend/samfundet/models/site_banner.py Outdated
Copy link
Copy Markdown
Contributor

@aTrueYety aTrueYety left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The animation when hiding the banner on scroll is very jumpy

This: Image

Comment thread backend/samfundet/models/site_banner.py Outdated
Comment thread backend/samfundet/models/site_banner.py Outdated
Comment thread frontend/src/Components/SiteBanner/SiteBanner.tsx Outdated
Comment thread frontend/src/Components/SiteBanner/SiteBanner.tsx Outdated
Comment thread frontend/src/Components/SiteBanner/SiteBanner.tsx Outdated
Comment thread frontend/src/Components/SiteBanner/SiteBanner.module.scss Outdated
Copy link
Copy Markdown
Contributor

@0xSpecter 0xSpecter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Når banneret går opp når du skroller kan man se under/ mellom den og navbaren, ser litt goofy ut.

  • kan også være ide å legge til en ease sånn at animasjonen ikke er så voldsom.

  • En litt lengere max tekst kunne ikke skade heller, noe som 150 ellerno.

ellers clean :DDD

Comment thread frontend/src/Components/SiteBanner/SiteBanner.tsx Outdated
Comment thread frontend/src/Components/SiteBanner/SiteBanner.tsx Outdated
Comment thread backend/samfundet/models/site_banner.py Outdated
Comment thread backend/samfundet/models/site_banner.py Outdated
Comment thread backend/samfundet/models/site_banner.py Outdated
Comment thread frontend/src/Components/SiteBanner/SiteBanner.tsx Outdated
Comment thread frontend/src/Components/SiteBanner/SiteBanner.tsx Outdated
Comment thread frontend/src/Components/SiteBanner/SiteBanner.tsx Outdated
Comment thread backend/samfundet/migrations/0006_sitebanner.py Outdated
Convert site banners to a single active banner flow and update frontend integration. Backend: remove is_active/UUID id, make start_at required, increase text length, remove is_active from serializer and admin list_display, and update migration accordingly; SiteBannerView.active now returns a single banner (first) or null. Frontend: add SiteBanner DTO, query key, and getActiveSiteBanner API; use react-query to fetch the active banner, render localized text via dbT
@0xSpecter
Copy link
Copy Markdown
Contributor

Når man endrer språk blir ikke språket på bannere endret

@0xSpecter
Copy link
Copy Markdown
Contributor

0xSpecter commented Apr 23, 2026

litt random men med brukt av en tab eller usynlig karakter så vil det bare vises en tynn rød bar, sikkert ikke viktig men ennå noe å tenke på.
image

Comment thread frontend/src/api.ts
return response.data;
}

export async function getActiveSiteBanner(): Promise<SiteBannerDto | null> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hadde vært fint med en funksjon som returnerer alle bannere i databasen for senere bruk, ikke hast.

Copy link
Copy Markdown
Contributor

@0xSpecter 0xSpecter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ser bra ut, par små ting som ikke er noe big deal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants