Skip to content

Commit 1967068

Browse files
authored
feat/card: add the Card component (#115)
* refactor(component): refactoring Daisy Button props * feat(component): add Card Component * style: formatting Card JSX demo * style: remove unused imports * refactor: update property name
1 parent db7cf71 commit 1967068

File tree

19 files changed

+317
-0
lines changed

19 files changed

+317
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { component$, HTMLAttributes, Slot } from '@builder.io/qwik';
2+
import {
3+
CardActions as HeadlessCartActions,
4+
} from '@qwik-ui/headless';
5+
6+
export type CardActionsProps = HTMLAttributes<HTMLElement>;
7+
8+
9+
export const CardActions = component$(
10+
(props: CardActionsProps) => (
11+
<HeadlessCartActions {...props} class="card-actions justify-end">
12+
<Slot />
13+
</HeadlessCartActions>
14+
)
15+
)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { component$, HTMLAttributes, Slot } from '@builder.io/qwik';
2+
type CardBodyProps = HTMLAttributes<HTMLElement>;
3+
4+
5+
export const CardBody = component$(
6+
(props: CardBodyProps) => {
7+
return (
8+
<div class="card-body" {...props}>
9+
<Slot />
10+
</div>
11+
)
12+
}
13+
)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { component$, HTMLAttributes, QwikIntrinsicElements } from '@builder.io/qwik';
2+
import {
3+
CardImage as HeadlessCardImage,
4+
} from '@qwik-ui/headless';
5+
export type HTMLImgProps = QwikIntrinsicElements['img'];
6+
7+
type CardImageProps = HTMLAttributes<HTMLElement> & HTMLImgProps;
8+
9+
10+
export const CardImage = component$(
11+
(props: CardImageProps) => (
12+
<HeadlessCardImage {...props} />
13+
)
14+
)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { component$, HTMLAttributes, Slot } from '@builder.io/qwik';
2+
import {
3+
CardTitle as HeadlessCardTitle,
4+
} from '@qwik-ui/headless';
5+
6+
export type CardTitleProps = HTMLAttributes<HTMLElement>;
7+
8+
9+
export const CardTitle = component$(
10+
(props: CardTitleProps) => (
11+
<HeadlessCardTitle {...props} class="card-title">
12+
<Slot />
13+
</HeadlessCardTitle>
14+
)
15+
)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { component$, HTMLAttributes, Slot } from '@builder.io/qwik';
2+
import {
3+
Card as HeadlessCard,
4+
} from '@qwik-ui/headless';
5+
import { clsq } from '@qwik-ui/shared';
6+
7+
export type CardProps = HTMLAttributes<HTMLElement>;
8+
9+
export const Card = component$(
10+
(props: CardProps) => {
11+
const { class: className, ...rest } = props;
12+
return (
13+
<HeadlessCard class={clsq('card bg-base-100 ', className)} {...rest}>
14+
<Slot />
15+
</HeadlessCard>
16+
);
17+
}
18+
);
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export * from './card';
2+
export * from './card-body';
3+
export * from './card-title';
4+
export * from './card-actions';
5+
export * from './card-image';

packages/daisy/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export * from './components/button/button';
22
export * from './components/button-group/button-group';
3+
export * from './components/card';
34
export * from './components/collapse/collapse';
45
export * from './components/drawer/drawer';
56
export * from './components/tabs';
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { component$, HTMLAttributes, Slot } from '@builder.io/qwik';
2+
3+
type CardActionsProps = HTMLAttributes<HTMLElement>;
4+
5+
export const CardActions = component$(
6+
(props: CardActionsProps) => {
7+
return (
8+
<div {...props}>
9+
<Slot />
10+
</div>
11+
);
12+
}
13+
);
14+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { component$, HTMLAttributes, Slot } from '@builder.io/qwik';
2+
3+
type CardBodyProps = HTMLAttributes<HTMLElement>;
4+
5+
export const CardBody = component$(
6+
(props: CardBodyProps) => {
7+
return (
8+
<div {...props}>
9+
<Slot />
10+
</div>
11+
);
12+
}
13+
);
14+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { component$, HTMLAttributes, QwikIntrinsicElements } from '@builder.io/qwik';
2+
3+
export type HTMLImgProps = QwikIntrinsicElements['img'];
4+
5+
type CardImageProps = HTMLAttributes<HTMLElement> & HTMLImgProps;
6+
7+
export const CardImage = component$(
8+
(props: CardImageProps) => {
9+
return (
10+
<figure><img {...props} /></figure>
11+
);
12+
}
13+
);
14+

0 commit comments

Comments
 (0)