Skip to content

Commit 5eb8b0d

Browse files
committed
fix(card)!: refactor card component, remove CardHead
1 parent df34619 commit 5eb8b0d

File tree

7 files changed

+101
-51
lines changed

7 files changed

+101
-51
lines changed

.vitepress/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export default defineConfig({
6363
{ text: 'Badge', link: '/components/badge' },
6464
{ text: 'Button', link: '/components/button' },
6565
{ text: 'Icon Button', link: '/components/icon-button' },
66+
{ text: 'Card', link: '/components/card' },
6667
{ text: 'Separator', link: '/components/separator' },
6768
],
6869
},

docs/content/components/card.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
title: Card
3+
description: Container that groups related content and actions.
4+
status: stable
5+
source: https://github.com/typlog/ui/tree/main/src/components/card
6+
reka: https://reka-ui.com/docs/components/card
7+
radix: https://www.radix-ui.com/themes/docs/components/card
8+
---
9+
10+
<Example name="card/Overview.vue" />
11+
12+
## API Reference
13+
14+
<PropsTable name="Card" />
15+
16+
## Examples
17+
18+
### Size
19+
20+
<Example name="card/Size.vue" />

docs/examples/card/Overview.vue

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<script setup lang="ts">
2+
import { Card, Avatar } from '#components'
3+
</script>
4+
5+
<template>
6+
<div class="max-w-60">
7+
<Card>
8+
<div class="flex items-center gap-3">
9+
<Avatar
10+
src="https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?&w=256&h=256&q=70&crop=focalpoint&fp-x=0.5&fp-y=0.3&fp-z=1&fit=crop"
11+
alt="Alex"
12+
size="3"
13+
radius="full"
14+
/>
15+
<div class="text-sm">
16+
<div class="font-bold">Alex Wang</div>
17+
<div class="text-gray-10">Engineering</div>
18+
</div>
19+
</div>
20+
</Card>
21+
</div>
22+
</template>

docs/examples/card/Size.vue

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<script setup lang="ts">
2+
import { Card, Avatar } from '#components'
3+
4+
const picture = "https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?&w=256&h=256&q=70&crop=focalpoint&fp-x=0.5&fp-y=0.3&fp-z=1&fit=crop"
5+
</script>
6+
7+
<template>
8+
<div class="flex flex-col gap-4 max-w-68">
9+
<Card size="1">
10+
<div class="flex items-center gap-3">
11+
<Avatar
12+
:src="picture"
13+
alt="Alex"
14+
size="3"
15+
radius="full"
16+
/>
17+
<div class="text-sm">
18+
<div class="font-bold">Alex Wang</div>
19+
<div class="text-gray-10">Engineering</div>
20+
</div>
21+
</div>
22+
</Card>
23+
<Card size="2">
24+
<div class="flex items-center gap-3">
25+
<Avatar
26+
:src="picture"
27+
alt="Alex"
28+
size="3"
29+
radius="full"
30+
/>
31+
<div class="text-sm">
32+
<div class="font-bold">Alex Wang</div>
33+
<div class="text-gray-10">Engineering</div>
34+
</div>
35+
</div>
36+
</Card>
37+
<Card size="3">
38+
<div class="flex items-center gap-3">
39+
<Avatar
40+
:src="picture"
41+
alt="Alex"
42+
size="3"
43+
radius="full"
44+
/>
45+
<div class="text-sm">
46+
<div class="font-bold">Alex Wang</div>
47+
<div class="text-gray-10">Engineering</div>
48+
</div>
49+
</div>
50+
</Card>
51+
</div>
52+
</template>

src/components/card/Card.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,7 @@ const resetClass = buildPropsClass(props, ['size', 'variant'])
4646
border-color: var(--card-border-color, var(--gray-a5));
4747
border-width: var(--card-border-width, 1px);
4848
border-style: solid;
49-
--inset-padding-top: var(--card-padding);
50-
--inset-padding-right: var(--card-padding);
51-
--inset-padding-bottom: var(--card-padding);
52-
--inset-padding-left: var(--card-padding);
49+
width: 100%;
5350
}
5451
.ui-Card:where(:any-link, button, label):where(:hover) {
5552
--card-border-color: var(--gray-a7);
@@ -85,4 +82,9 @@ const resetClass = buildPropsClass(props, ['size', 'variant'])
8582
.ui-Card:where(.r-variant-soft):where(:any-link, button, label):where(:hover) {
8683
border-color: var(--gray-a5);
8784
}
85+
86+
/** special enhancement for tailwindcss */
87+
.ui-Card:where(.p-0) {
88+
--card0-padding: 0;
89+
}
8890
</style>

src/components/card/CardHead.vue

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

src/components/card/index.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,3 @@ export {
22
default as Card,
33
type CardProps,
44
} from './Card.vue'
5-
6-
export {
7-
default as CardHead,
8-
type CardHeadProps,
9-
} from './CardHead.vue'

0 commit comments

Comments
 (0)