Skip to content

Commit ccaac06

Browse files
committed
aside 支持卡片布局
1 parent ddeaed1 commit ccaac06

File tree

3 files changed

+257
-34
lines changed

3 files changed

+257
-34
lines changed

packages/pure/components/user/Aside.astro

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import Icon from './Icon.astro'
55
import { Icons } from '../../libs/icons'
66
77
const asideVariants = ['important', 'info', 'note', 'tip', 'warning', 'caution'] as const
8+
const asideStyles = ['solid', 'card'] as const;
9+
810
911
type IconName = keyof typeof Icons;
1012
@@ -22,9 +24,10 @@ interface Props {
2224
title?: string
2325
icon?: string
2426
open?: string;
27+
style?: (typeof asideStyles)[number];
2528
}
2629
27-
const { type = 'note', icon, open: openProp } = Astro.props;
30+
const { type = 'note', icon, open: openProp, style = 'solid' } = Astro.props;
2831
let { title } = Astro.props;
2932
3033
const isCollapsible = openProp !== undefined;
@@ -40,6 +43,14 @@ if (!asideVariants.includes(type)) {
4043
)
4144
}
4245
46+
if (style && !asideStyles.includes(style)) {
47+
throw new AstroError(
48+
'Invalid `style` prop passed to the `<Aside>` component.\n',
49+
`Received: ${JSON.stringify(style)}
50+
` + `Expected one of ${asideStyles.map((i) => JSON.stringify(i)).join(', ')}`
51+
);
52+
}
53+
4354
if (!title) {
4455
title = type.toUpperCase();
4556
}
@@ -70,6 +81,7 @@ if (icon) {
7081
aria-label={title}
7182
class:list={[
7283
`aside aside-${type}`,
84+
`aside-style-${style}`,
7385
{ 'is-collapsible': isCollapsible, 'is-collapsed': isCollapsible && !open },
7486
]}
7587
>

0 commit comments

Comments
 (0)