Skip to content

Commit dca6a0c

Browse files
committed
fix Alert component
1 parent 800ef7a commit dca6a0c

File tree

5 files changed

+55
-32
lines changed

5 files changed

+55
-32
lines changed

src/components/Details.astro

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
---
2-
export interface Props {
2+
import { cn } from '@/utils/styles';
3+
4+
import type { HTMLAttributes } from 'astro/types';
5+
6+
export interface Props extends HTMLAttributes<'details'> {
37
title: string;
48
}
59
6-
const { title } = Astro.props as Props;
10+
const { title, class: className, ...props } = Astro.props as Props;
711
---
812

9-
<details class="group mx-2 rounded-lg bg-slate-200 p-8 px-4 py-1 dark:bg-slate-800 sm:mx-4">
10-
<summary
11-
class="cursor-pointer text-purple-600 no-underline outline-none hover:underline hover:decoration-4 hover:underline-offset-2 focus:underline focus:decoration-4 focus:underline-offset-4 dark:text-purple-400"
12-
>
13-
<span
14-
class="bg-gradient-to-br from-blue-700 to-purple-600 bg-clip-text font-bold text-transparent dark:from-blue-400 dark:to-purple-400"
15-
>{title}</span
16-
>
13+
<details {...props} class={cn('rounded-button bg-base-200 px-4 py-1', className)}>
14+
<summary class="cursor-pointer">
15+
<span class="font-semibold">{title}</span>
1716
</summary>
1817
<slot />
1918
</details>

src/components/Prose.astro

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/pages/design/components.mdx

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
layout: '../../layouts/Page.astro'
3+
title: Other components
4+
---
5+
6+
7+
import Details from '../../components/Details.astro';
8+
import Alert from '../../components/Alert.astro';
9+
10+
back to [Index](/design)
11+
12+
## Details
13+
14+
<Details title="This is the title">
15+
These are the details.
16+
</Details>
17+
18+
export const alerts = {
19+
variant: [
20+
{ variant: 'note' },
21+
{ variant: 'info' },
22+
{ variant: 'tip' },
23+
{ variant: 'warning' },
24+
{ variant: 'danger' },
25+
],
26+
};
27+
28+
## Alerts
29+
30+
{Object.entries(alerts).map(([key, values]) => (
31+
<>
32+
<h4>{key}</h4>
33+
<div>
34+
{values.map((props) => {
35+
const item = `${Object.values(props)[0]}`;
36+
const text = `This is some ${item} text.`;
37+
38+
return <Alert {...props}>{text}</Alert>;
39+
})}
40+
</div>
41+
</>
42+
))}

src/pages/design/index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ title: Design system
1010
- [Colors](/design/colors)
1111
- [Images](/design/images)
1212
- [Embeds](/design/embeds)
13+
- [Components](/design/components)
1314
- [Typography](/design/typography)

src/styles/components/alert.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
@layer components {
22
.alert {
3-
@apply mb-4 mx-8 md:mx-auto px-4 py-1 rounded-button;
3+
@apply px-4 py-1 rounded-button;
44

55
& p {
66
@apply my-0;
77
}
88
}
9+
10+
/* extract into semantic colors maybe in future */
911
.alert--note {
1012
/* use base-200-300 here */
1113
@apply bg-slate-100 border border-slate-200 dark:border-slate-800 dark:bg-slate-900;

0 commit comments

Comments
 (0)