-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Cards component to style guide #35
Changes from all commits
04c3a82
fddcc82
90de0e9
a33448d
c8d8430
f79ccb4
2633289
cec63f0
1a07ec7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<script> | ||
import { Meta, Story } from '@storybook/addon-svelte-csf'; | ||
import { UserKey, Wallet } from '/src/lib/assets'; | ||
import Card from './Card.svelte'; | ||
</script> | ||
|
||
<Meta title="UI Components/Features/Card" component={Card} /> | ||
|
||
<!-- Primary --> | ||
<Story name="Default Card"> | ||
<Card></Card> | ||
</Story> | ||
|
||
<!-- 320px Width --> | ||
<Story name="Specific Width"> | ||
<Card | ||
title="320px width" | ||
class="w-f320 my-4" | ||
icon={UserKey} | ||
/> | ||
</Story> | ||
|
||
<!-- Half Width --> | ||
<Story name="Half Width" > | ||
<Card | ||
title="Half width" | ||
icon={Wallet} | ||
class="w-1/2 mb-4" | ||
> | ||
<p slot="content"> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididun | ||
</p> | ||
</Card> | ||
</Story> | ||
|
||
<!-- Another color --> | ||
<Story name="Alt Color" > | ||
<Card | ||
title="Alternate color card" | ||
titleColor="cream" | ||
bgColor="teal" | ||
> | ||
<div slot="content"> | ||
<h4 class="font-bold md text-navy">Slot content title</h4> | ||
<p class="text-error bg-white w-fit px-2 rounded">Slot content: Error text!</p> | ||
<p class="text-white">Slot content: error message!</p> | ||
</div> | ||
</Card> | ||
</Story> |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,19 @@ | ||||||
<script> | ||||||
import { UserFilled } from '/src/lib/assets/index'; | ||||||
|
||||||
export let title = 'Default Card Header'; | ||||||
export let bgColor = 'cream'; | ||||||
export let titleColor = 'navy' | ||||||
export let icon = UserFilled; | ||||||
</script> | ||||||
|
||||||
<div class="p-6 card-shadow rounded-xl bg-{bgColor} {$$restProps.class}"> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Thinking we degault to cream, then when a user wants to change the color, they can just set the class to the new color that they want and it can override the cream through the restProps.class. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did it this way because the background color as a prop was part of the Issue specification. It does already default to cream, however, I think it's not the best practice to have two background color classes end up in the class list. |
||||||
<div class="pb-6 flex justify-between"> | ||||||
<h5 class="font-bold text-{titleColor} inline">{title}</h5> | ||||||
<svelte:component this={icon} class="w-f48 h-f48"/> | ||||||
</div> | ||||||
<slot name="content" > | ||||||
This is default content | ||||||
</slot> | ||||||
</div> | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a width specified in the Figma design so I added it.