Skip to content

Commit 45450d6

Browse files
committed
✨ Add examples for card components
1 parent df4eddf commit 45450d6

File tree

9 files changed

+109
-11
lines changed

9 files changed

+109
-11
lines changed

src/components/Card/Card.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const {
1212
element = 'section',
1313
title,
1414
titleTag = 'span',
15-
compact = true,
15+
compact,
1616
className,
1717
secondary,
1818
...rest
@@ -37,7 +37,7 @@ const Title = titleTag
3737
<Title class="card-title">{title}</Title>
3838
)}
3939
<div class="card-body" class:list={[compact && 'compact']}>
40-
{compact ? (
40+
{compact && !secondary ? (
4141
<div class="card-wrapper"><slot /></div>
4242
) : (
4343
<slot />

src/pages/button.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ import { Button as ReactButton } from '@components/Button/Button.tsx'
1616
</ComponentWrapper>
1717

1818
<ComponentWrapper type="Svelte">
19-
<SvelteButton theme="alert" onClick={() => console.log('👋')} client:load>
19+
<SvelteButton theme="alert">
2020
Button in Svelte
2121
</SvelteButton>
2222
</ComponentWrapper>
2323

2424
<ComponentWrapper type="React">
25-
<ReactButton theme="info" onClick={() => console.log('👋')} client:load>
25+
<ReactButton theme="info">
2626
Button in React
2727
</ReactButton>
2828
</ComponentWrapper>

src/pages/card.astro

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
import Layout from '@static/Layout.astro'
3+
4+
import AstroCard from '@components/Card/Card.astro'
5+
import SvelteButton from '@components/Button/Button.svelte'
6+
import { Button as ReactButton } from '@components/Button/Button.tsx'
7+
---
8+
9+
<Layout>
10+
<h1>Card</h1>
11+
12+
<div class="grid md-2 lg-3">
13+
<AstroCard compact={true}>
14+
Card component using <span class="a">Astro</span>
15+
</AstroCard>
16+
17+
<AstroCard compact={true}>
18+
Card component using <span class="s">Svelte</span>
19+
</AstroCard>
20+
21+
<AstroCard compact={true}>
22+
Card component using <span class="r">React</span>
23+
</AstroCard>
24+
25+
<AstroCard title="Titled card" compact={true}>
26+
Card with title
27+
</AstroCard>
28+
29+
<AstroCard title="Spacious">
30+
Spacious card with title
31+
</AstroCard>
32+
33+
<AstroCard>
34+
Spacious card without title
35+
</AstroCard>
36+
37+
<AstroCard title="Secondary" secondary={true}>
38+
Secondary card with title
39+
</AstroCard>
40+
41+
<AstroCard secondary={true}>
42+
Secondary card without title
43+
</AstroCard>
44+
45+
<AstroCard title="Bolded" titleTag="strong">
46+
Card with bold title using <code>strong</code> tag.
47+
</AstroCard>
48+
</div>
49+
</Layout>
50+
51+
<style lang="scss">
52+
.a {
53+
background: #B545ED;
54+
background: linear-gradient(to right, #505FFF, #B545ED);
55+
background-clip: text;
56+
-webkit-background-clip: text;
57+
-webkit-text-fill-color: transparent;
58+
}
59+
60+
.s {
61+
color: #FF3E00;
62+
}
63+
64+
.r {
65+
color: #61DAFB;
66+
}
67+
</style>

src/pages/index.astro

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
import Layout from '@static/Layout.astro'
3+
import CardWrapper from '@static/CardWrapper.astro'
34
45
import Button from '@components/Button/Button.astro'
5-
import Card from '@components/Card/Card.astro'
66
import Accordion from '@components/Accordion/Accordion.astro'
77
---
88

@@ -27,7 +27,7 @@ import Accordion from '@components/Accordion/Accordion.astro'
2727
</Button>
2828
</div>
2929
<div class="grid md-2 lg-3">
30-
<Card title="Accordion" element="a" href="/accordion">
30+
<CardWrapper title="Accordion" href="/accordion">
3131
<Accordion
3232
items={[{
3333
title: 'Do you offer support?',
@@ -40,11 +40,14 @@ import Accordion from '@components/Accordion/Accordion.astro'
4040
content: 'Hopefully.'
4141
}]}
4242
/>
43-
</Card>
44-
<Card title="Button" element="a" href="/button">
43+
</CardWrapper>
44+
<CardWrapper title="Button" href="/button">
4545
<Button>Primary</Button>
4646
<Button theme="secondary">Secondary</Button>
47-
</Card>
47+
</CardWrapper>
48+
<CardWrapper title="Card" href="/card">
49+
<p>Paragraph inside a card</p>
50+
</CardWrapper>
4851
</div>
4952
</Layout>
5053

src/scss/global.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
@import './global/elements.scss';
12
@import './global/utility.scss';

src/scss/global/elements.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@import '../config';
2+
3+
@mixin Elements() {
4+
code {
5+
display: inline-block;
6+
padding: 2px 10px;
7+
border-radius: 5px;
8+
border: 1px solid #252525;
9+
font-size: 14px;
10+
}
11+
}

src/scss/setup.scss

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
$config: (
44
includeResets: true,
5-
includeHelperClasses: true
5+
includeHelperClasses: true,
6+
includeElementStyles: true
67
);
78

89
@function config($key) {
@@ -19,4 +20,8 @@ $config: (
1920
@if (config('includeHelperClasses')) {
2021
@include Utility();
2122
}
23+
24+
@if (config('includeElementStyles')) {
25+
@include Elements();
26+
}
2227
}

src/static/CardWrapper.astro

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
import Card from '@components/Card/Card.astro'
3+
4+
const {
5+
title,
6+
href
7+
} = Astro.props
8+
---
9+
10+
<Card title={title} element="a" href={href} compact={true}>
11+
<slot />
12+
</Card>

src/static/ComponentWrapper.astro

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const {
1111
title={title || type}
1212
className={type && type.slice(0, 1).toLocaleLowerCase()}
1313
titleTag="strong"
14-
compact={false}
1514
>
1615
<slot />
1716
</Card>

0 commit comments

Comments
 (0)