Skip to content

Conversation

@jellydeck
Copy link
Contributor

@jellydeck jellydeck commented Jan 16, 2026

Closes #132

Description

  • add "Alert" component with following variants:
    default | success | danger | info | warning | mono
  • add tests

Summary by CodeRabbit

  • New Features
    • Added an Alert component with multiple visual variants (default, primary, success, warning, danger, info, mono), required title, optional icon override, and flexible content slot.
  • Style
    • Added themable CSS for Alert layout and variant-specific accent, background, and text colors.
  • Tests
    • Added unit and end-to-end tests covering rendering, variants, icons, accessibility, and snapshots.
  • Documentation
    • Added usage docs and examples demonstrating variants and custom icons.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot
Copy link

changeset-bot bot commented Jan 16, 2026

🦋 Changeset detected

Latest commit: 8c6f410

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@studiocms/ui Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 16, 2026

📝 Walkthrough

Walkthrough

Adds a new Alert UI component to the studio CMS UI package with typed props (title, variant, icon), seven visual variants, CSS theming, exports, documentation, a test fixture, Vitest unit tests, and Playwright end-to-end tests.

Changes

Cohort / File(s) Summary
Changeset Documentation
\.changeset/calm-waves-kneel.md
Adds a changeset recording a minor version bump for @studiocms/ui and the new Alert component.
Component Implementation
packages/studiocms_ui/src/components/Alert/Alert.astro, packages/studiocms_ui/src/components/Alert/alert.css
New Alert.astro with Props (title, variant?, icon?), per-variant default icon mapping, forwarded div attributes, and markup; accompanying CSS introduces base styles and data-variant rules for seven variants using CSS variables.
Export Map
packages/studiocms_ui/src/index.ts
Adds virtual export entry 'studiocms:ui/components/alert' pointing to the new component.
Unit Tests
packages/studiocms_ui/test/components/Alert.test.ts
Vitest tests covering rendering, variants, custom title/icon, slot content, data-variant attribute, CSS classes, and snapshots.
End-to-End Tests
packages/studiocms_ui/test/components/Alert.e2e.ts
Playwright E2E suite validating rendering on /alert-test, all variants, icons, content, accessibility checks in dark/light modes, and screenshots.
Test Fixture Page
packages/studiocms_ui/test/fixtures/test-server/src/pages/alert-test.astro
Adds a test page that renders multiple Alert configurations for automated and manual testing.
Documentation
docs/src/content/docs/docs/components/alert.mdx
New MDX docs with previews and code samples demonstrating variants and custom icon usage.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A tidy alert hops into view,
Seven colors, a title or two,
Icons aligned, and CSS set right,
Tests and docs guard the new sight.
Hooray—messages now sparkle bright! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The PR title 'feat: Alert/Aside component' is overly broad and partially misleading—the changeset and all implementation focus on the Alert component, with no Aside component additions. Clarify the title to 'feat: Alert component' if no Aside component is included, or complete the Aside implementation to match the title.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The PR successfully implements the core requirements from #132: a static Alert component with multiple variants (default, success, danger, info, warning, mono) for displaying inline page alerts without scripted behavior.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the Alert component requested in #132; comprehensive tests and documentation are appropriately included scope additions.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Member

@Adammatthiesen Adammatthiesen left a comment

Choose a reason for hiding this comment

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

Biggest thing... make sure your linting with the repo's linter... and our linter only...

@Adammatthiesen
Copy link
Member

Oh i just noticed this was a draft.... 😅

- also updated `colors.css` to pass accessiblity tests.
coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 18, 2026
coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 18, 2026
coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 18, 2026
Copy link
Member

@Adammatthiesen Adammatthiesen left a comment

Choose a reason for hiding this comment

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

Okay, here is my current checklist...

Not sure if Lou has anything else to add

@jellydeck
Copy link
Contributor Author

@Adammatthiesen cleaned up, with changesets.

@jellydeck jellydeck marked this pull request as ready for review January 18, 2026 10:57
@jellydeck jellydeck requested review from a team and louisescher as code owners January 18, 2026 10:57
Copy link
Contributor Author

@jellydeck jellydeck left a comment

Choose a reason for hiding this comment

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

requested changes applied

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@packages/studiocms_ui/test/components/Alert.e2e.ts`:
- Around line 44-76: The tests "Renders alert content correctly" and "Renders
with correct variant icons" are missing assertions for the primary variant;
update both tests to include checks for the primary variant by using the same
variantSection locator and selectors: add an assertion that
variantSection.locator('[data-variant="primary"] .sui-alert-content') contains
the primary alert text (e.g., 'This is a primary alert message.') in the content
test, and add an assertion that variantSection.locator('[data-variant="primary"]
.sui-alert-icon') is visible in the icon visibility test so the primary variant
is covered like the other variants.

In `@packages/studiocms_ui/test/components/Alert.test.ts`:
- Around line 14-23: The variants array in the test "renders Alert component
with different variants" is missing the supported "primary" variant; update the
variants constant used in that test (the local variable named variants) to
include "primary" alongside 'default', 'success', 'danger', 'info', 'warning',
and 'mono' so the Alert component (Alert) test covers all StudioCMSColorway
options.
🧹 Nitpick comments (3)
packages/studiocms_ui/src/components/Alert/alert.css (1)

31-71: Consider scoping the variant selectors to .sui-alert.

The [data-variant="..."] selectors are not scoped to .sui-alert, which could unintentionally style other components that use the same data-variant attribute pattern.

♻️ Suggested refactor
-.sui-alert-title {
-	font-weight: 600;
-	font-size: 1.125em;
-}
-
-[data-variant="default"] {
+.sui-alert[data-variant="default"] {
 	--alert-accent: var(--text-normal);
 	color: var(--text-dimmed);
 	background-color: var(--default-base);
 }

-[data-variant="primary"] {
+.sui-alert[data-variant="primary"] {
 	--alert-accent: var(--primary-base);
 	color: var(--text-dimmed);
 	background-color: var(--primary-flat);
 }

-[data-variant="success"] {
+.sui-alert[data-variant="success"] {
 	--alert-accent: var(--success-base);
 	color: var(--text-dimmed);
 	background-color: var(--success-flat);
 }

-[data-variant="warning"] {
+.sui-alert[data-variant="warning"] {
 	--alert-accent: var(--warning-base);
 	color: var(--text-dimmed);
 	background-color: var(--warning-flat);
 }

-[data-variant="danger"] {
+.sui-alert[data-variant="danger"] {
 	--alert-accent: var(--danger-vibrant);
 	color: var(--text-dimmed);
 	background-color: var(--danger-flat);
 }

-[data-variant="info"] {
+.sui-alert[data-variant="info"] {
 	--alert-accent: var(--info-vibrant);
 	color: var(--text-dimmed);
 	background-color: var(--info-flat);
 }

-[data-variant="mono"] {
+.sui-alert[data-variant="mono"] {
 	--alert-accent: var(--mono-base);
 	color: var(--text-dimmed);
 	background-color: var(--mono-flat);
 }
packages/studiocms_ui/src/components/Alert/Alert.astro (1)

39-39: Simplify the class conditional.

The className && className pattern is redundant. Astro's class:list already handles falsy values gracefully.

♻️ Suggested fix
-<div class:list={["sui-alert", className && className]} data-variant={variant} {...props}>
+<div class:list={["sui-alert", className]} data-variant={variant} {...props}>
packages/studiocms_ui/test/components/Alert.test.ts (1)

57-66: Consider extracting the variants array to reduce duplication.

The variants array is defined identically on lines 15 and 58. Extracting it to a module-level constant would improve maintainability—if a new variant is added, you'd only need to update one place.

♻️ Suggested refactor
 import { describe, expect } from 'vitest';
 import Alert from '../../src/components/Alert/Alert.astro';
 import { test } from '../fixtures/vitest/AstroContainer';
 
+const ALERT_VARIANTS = ['default', 'success', 'danger', 'info', 'warning', 'mono'] as const;
+
 describe('Alert Component', () => {
 	test('renders Alert component with different variants', async ({ renderComponent }) => {
-		const variants = ['default', 'success', 'danger', 'info', 'warning', 'mono'];
-		for (const variant of variants) {
+		for (const variant of ALERT_VARIANTS) {
 			// ...
 		}
 	});
 
 	// ... later in the file ...
 
 	test('renders Alert with correct data-variant attribute', async ({ renderComponent }) => {
-		const variants = ['default', 'success', 'danger', 'info', 'warning', 'mono'];
-		for (const variant of variants) {
+		for (const variant of ALERT_VARIANTS) {
 			// ...
 		}
 	});
 });

coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 18, 2026
@codecov
Copy link

codecov bot commented Jan 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

Adammatthiesen
Adammatthiesen previously approved these changes Jan 18, 2026
Copy link
Member

@Adammatthiesen Adammatthiesen left a comment

Choose a reason for hiding this comment

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

That clears up the things I saw. Will leave it to the UI team now

Copy link
Member

@RATIU5 RATIU5 left a comment

Choose a reason for hiding this comment

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

@jellydeck If you're able to, create a docs page that goes over the usage and features of this component. Feel free to use another page as a reference found in docs/src/content/docs/docs/components.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 18, 2026
@jellydeck
Copy link
Contributor Author

@jellydeck If you're able to, create a docs page that goes over the usage and features of this component. Feel free to use another page as a reference found in docs/src/content/docs/docs/components.

@RATIU5 took other pages as reference and added docs.

dreyfus92
dreyfus92 previously approved these changes Jan 18, 2026
Copy link
Member

@dreyfus92 dreyfus92 left a comment

Choose a reason for hiding this comment

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

Awesome job @jellydeck, this looks good to me. 😄

Copy link
Member

@Adammatthiesen Adammatthiesen left a comment

Choose a reason for hiding this comment

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

Snapshots are outdated again due to change.

Image

Copy link
Member

@Adammatthiesen Adammatthiesen left a comment

Choose a reason for hiding this comment

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

Hey this is looking like the next new StudioCMS UI Component! 🎉 Great work and thanks for bearing with our nitpicks!

@jellydeck jellydeck requested review from RATIU5 and dreyfus92 January 19, 2026 10:20
@jellydeck
Copy link
Contributor Author

Hey this is looking like the next new StudioCMS UI Component! 🎉 Great work and thanks for bearing with our nitpicks!

@Adammatthiesen appreciate it :)

@louisescher louisescher merged commit 9b89906 into withstudiocms:main Jan 19, 2026
12 checks passed
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.

[Feature Request]: Alert/Aside component

5 participants