Skip to content

Commit a443456

Browse files
committed
feat(styled kit): add Alert component
1 parent 75341f7 commit a443456

File tree

9 files changed

+138
-2
lines changed

9 files changed

+138
-2
lines changed

.changeset/sixty-camels-flash.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@qwik-ui/styled': patch
3+
---
4+
5+
feat(styled kit): add Alert component

apps/website/src/_state/component-statuses.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export type ComponentKitsStatuses = {
1212
export const statusByComponent: ComponentKitsStatuses = {
1313
styled: {
1414
Accordion: ComponentStatus.Beta,
15+
Alert: ComponentStatus.Beta,
1516
Badge: ComponentStatus.Beta,
1617
Button: ComponentStatus.Beta,
1718
Card: ComponentStatus.Beta,
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { component$ } from '@builder.io/qwik';
2+
import { Alert, AlertDescription, AlertTitle } from '@qwik-ui/styled';
3+
import { LuAlertTriangle } from '@qwikest/icons/lucide';
4+
5+
export default component$(() => {
6+
return (
7+
<Alert look="alert">
8+
<LuAlertTriangle class="h-4 w-4" />
9+
<AlertTitle>Error</AlertTitle>
10+
<AlertDescription>Your session has expired. Please log in again.</AlertDescription>
11+
</Alert>
12+
);
13+
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { component$ } from '@builder.io/qwik';
2+
import { LuRocket } from '@qwikest/icons/lucide';
3+
4+
import { Alert, AlertDescription, AlertTitle } from '@qwik-ui/styled';
5+
6+
export default component$(() => {
7+
return (
8+
<Alert>
9+
<LuRocket class="h-4 w-4" />
10+
<AlertTitle>Heads up!</AlertTitle>
11+
<AlertDescription>
12+
You can add components to your app using the cli.
13+
</AlertDescription>
14+
</Alert>
15+
);
16+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { component$ } from '@builder.io/qwik';
2+
import { Alert, AlertDescription, AlertTitle } from '@qwik-ui/styled';
3+
import { LuAlertTriangle } from '@qwikest/icons/lucide';
4+
5+
export default component$(() => {
6+
return (
7+
<Alert look="primary">
8+
<LuAlertTriangle class="h-4 w-4" />
9+
<AlertTitle>Error</AlertTitle>
10+
<AlertDescription>Your session has expired. Please log in again.</AlertDescription>
11+
</Alert>
12+
);
13+
});

apps/website/src/routes/docs/styled/alert/index.mdx

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,42 @@ title: Qwik UI | Styled Alert Component
44

55
import { statusByComponent } from '~/_state/component-statuses';
66

7+
<StatusBanner status={statusByComponent.styled.Alert} />
8+
79
# Alert
810

9-
In a digital landscape of gentle nudges, the Qwik UI Styled alert pops with a playful flair, ensuring every crucial whisper finds its audience effortlessly.
11+
Displays a callout for user attention.
1012

11-
<StatusBanner status={statusByComponent.styled.Alert} />
13+
<Showcase name="hero" />
14+
15+
## Installation
16+
17+
```sh
18+
qwik-ui add alert
19+
```
20+
21+
## Usage
22+
23+
```tsx
24+
import { Alert, AlertDescription, AlertTitle } from '@qwik-ui/styled';
25+
```
26+
27+
```tsx
28+
<Alert>
29+
<Terminal className="h-4 w-4" />
30+
<AlertTitle>Heads up!</AlertTitle>
31+
<AlertDescription>
32+
You can add components and dependencies to your app using the cli.
33+
</AlertDescription>
34+
</Alert>
35+
```
36+
37+
## Examples
38+
39+
### Alert
40+
41+
<Showcase name="alert" vertical />
42+
43+
### Primary
44+
45+
<Showcase name="primary" vertical />

apps/website/src/routes/docs/styled/menu.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
## Components
1010

1111
- [Accordion](/docs/styled/accordion)
12+
- [Alert](/docs/styled/alert)
1213
- [Badge](/docs/styled/badge)
1314
- [Button](/docs/styled/button)
1415
- [Card](/docs/styled/card)
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { component$, Slot, PropsOf } from '@builder.io/qwik';
2+
import { cn } from '@qwik-ui/utils';
3+
4+
import { cva, type VariantProps } from 'class-variance-authority';
5+
6+
const alertVariants = cva(
7+
'relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground',
8+
{
9+
variants: {
10+
look: {
11+
neutral: 'bg-background text-foreground',
12+
alert: 'border-alert/60 text-alert [&>svg]:text-alert',
13+
primary: 'border-primary',
14+
secondary: 'border-secondary',
15+
},
16+
},
17+
defaultVariants: {
18+
look: 'neutral',
19+
},
20+
},
21+
);
22+
23+
type AlertProps = PropsOf<'div'> & VariantProps<typeof alertVariants>;
24+
25+
const Alert = component$<AlertProps>(({ look, ...props }) => {
26+
return (
27+
<div {...props} role="alert" class={cn(alertVariants({ look }), props.class)}>
28+
<Slot />
29+
</div>
30+
);
31+
});
32+
33+
const AlertTitle = component$<PropsOf<'h5'>>(({ ...props }) => {
34+
return (
35+
<h5
36+
{...props}
37+
class={cn('mb-1 font-medium leading-none tracking-tight', props.class)}
38+
>
39+
<Slot />
40+
</h5>
41+
);
42+
});
43+
44+
const AlertDescription = component$<PropsOf<'div'>>(({ ...props }) => {
45+
return (
46+
<div {...props} class={cn('text-sm [&_p]:leading-relaxed', props.class)}>
47+
<Slot />
48+
</div>
49+
);
50+
});
51+
52+
export { Alert, AlertTitle, AlertDescription };

packages/kit-styled/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export * from './components/accordion/accordion';
2+
export * from './components/alert/alert';
23
export * from './components/badge/badge';
34
export * from './components/button/button';
45
export * from './components/card/card';

0 commit comments

Comments
 (0)