Skip to content

feat(components): shared Alert Twig component varying by type#99

Merged
martinyde merged 1 commit into
developfrom
feature/issue-93-alert-component
Jun 22, 2026
Merged

feat(components): shared Alert Twig component varying by type#99
martinyde merged 1 commit into
developfrom
feature/issue-93-alert-component

Conversation

@martinydeAI

Copy link
Copy Markdown
Collaborator

Links to issues

Closes #93.

Description

The notification box on templates/security/login.html.twig was
hand-rolled with <div class="...rounded-lg border border-line bg-surface-2..." role="alert">. Extract a shared Alert Twig
component so the same markup powers flash messages and inline
errors across the app.

  • New templates/components/Alert.html.twigtype (success |
    error | warning | info, default info), class slot for
    layout extras (margins).
  • type drives the ARIA role: error / warning are assertive
    (role="alert"), success / info are polite (role="status").
  • Visual treatment is a single neutral surface today, matching the
    existing login error block. Per-type colour treatments will land
    once success / warning / error / info colour tokens are
    added to assets/styles/app.css — this PR ships the stable
    call-site API so adoption can start now.

Refactored the one site on develop:

  • templates/security/login.html.twig (form-login error)

Screenshot of the result

n/a — the refactored login error preserves the exact class string
that was there before (only the wrapper element name changes from
<div> to the rendered Twig component, which emits the same
<div>). Visual output is unchanged.

Checklist

  • My code is covered by test cases.
  • My code passes our test (all our tests).
  • My code passes our static analysis suite.
  • My code passes our continuous integration process.

Verified locally:

  • task coding-standards-twig-check — green.
  • task test-coverage — 70 tests, 267 assertions, 100% coverage.

Additional comments or questions

The four type values are all accepted today but only the ARIA
role differs between them. That intentional under-engineering keeps
the design system honest: visual differentiation should follow a
colour-token decision, not be invented inside one component.


Details - AI specificities

Adds `templates/components/Alert.html.twig` accepting a `type` prop
(success | error | warning | info, default info) and a `class` slot
for layout extras like margins.

`type` drives the ARIA role: error / warning are assertive
(role="alert"), success / info are polite (role="status"). The
visual treatment is a single neutral surface today, matching the
existing login error block; per-type colour treatments will land
once success / warning / error / info colour tokens are added to
`app.css` - this PR just gives the call-sites a stable API.

Refactors the one duplicated call site on develop:

- templates/security/login.html.twig (form-login error)

Refs #93.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@martinyde martinyde requested a review from yepzdk June 22, 2026 06:54

@yepzdk yepzdk left a comment

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.

LGTM.

@martinyde martinyde merged commit 254d91a into develop Jun 22, 2026
5 checks passed
martinydeAI added a commit that referenced this pull request Jun 22, 2026
The admin user-list page hand-rolled the same flash-message box
markup that the new `<twig:Alert>` component (from PR #99, now on
develop) handles. Swap to the component so the markup and ARIA
role live in one place.

`type="success"` resolves to `role="status"` inside the component,
matching the previous explicit `role="status"`. Visual output
unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

feat(components): shared Alert Twig component varying by type

3 participants