Skip to content

Commit

Permalink
OPHJOD-849: Create content card component
Browse files Browse the repository at this point in the history
  • Loading branch information
juhaniko committed Nov 21, 2024
1 parent 39eb769 commit 1bc2db9
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
34 changes: 34 additions & 0 deletions lib/components/ContentCard/ContentCard.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import type { Meta, StoryObj } from '@storybook/react';

import { ContentCard } from './ContentCard';

const meta = {
title: 'Cards/ContentCard',
component: ContentCard,
tags: ['autodocs'],
} satisfies Meta<typeof ContentCard>;

export default meta;

type Story = StoryObj<typeof meta>;

export const Default: Story = {
parameters: {
design: {
type: 'figma',
url: 'https://www.figma.com/design/6M2LrpSCcB0thlFDaQAI2J/cx_jod_client?node-id=2217-8588',
},
docs: {
description: {
story: 'This is a simple content card component for "ohjaaja" UI.',
},
},
},
args: {
title: 'Tulevaisuusmatka',
description:
'Mauris sed libero. Suspendisse facilisis nulla in lacinia laoreet, lorem velit osana ei osaa sanoa mitä accumsan dolor nonummy.',
tags: ['Taglorem', 'Loremtag', 'Nonutag'],
className: 'ds-bg-white',
},
};
28 changes: 28 additions & 0 deletions lib/components/ContentCard/ContentCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { tidyClasses as tc } from '../../main';

export interface ContentCardProps {
title: string;
description: string;
tags: string[];
className?: string;
}

const Tag = ({ label }: { label: string }) => {
return <li className="ds-px-2 first:ds-pl-0 last:ds-pr-0">{label}</li>;
};

export const ContentCard = ({ title, description, tags, className = '' }: ContentCardProps) => {
return (
<div className={tc(`ds-py-4 ds-flex ds-flex-col ds-gap-3 ${className}`)}>
<div className="ds-text-heading-3">{title}</div>
<div className="ds-text-body-sm">{description}</div>
<div className="ds-flex ds-flex-row ds-gap-3 ds-items-center">
<ul className="ds-text-attrib-value ds-flex ds-flex-row ds-divide-x ds-flex-wrap ds-text-accent">
{tags.map((tag) => (
<Tag key={tag} label={tag} />
))}
</ul>
</div>
</div>
);
};
1 change: 1 addition & 0 deletions lib/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export { Button } from './components/Button/Button';
export { Checkbox } from './components/Checkbox/Checkbox';
export { Combobox } from './components/Combobox/Combobox';
export { ConfirmDialog } from './components/ConfirmDialog/ConfirmDialog';
export { ContentCard } from './components/ContentCard/ContentCard';
export { Datepicker } from './components/Datepicker/Datepicker';
export { DiscussionCard } from './components/DiscussionCard/DiscussionCard';
export { Footer } from './components/Footer/Footer';
Expand Down

0 comments on commit 1bc2db9

Please sign in to comment.