From f44a3f9ca2e16daa5eeb2e0a9b5cbe9645ba5413 Mon Sep 17 00:00:00 2001 From: Sauli Anto Date: Mon, 8 Apr 2024 10:25:48 +0300 Subject: [PATCH] OPHJOD-287: Use Tailwind CSS rules and fix href --- lib/components/HeroCard/HeroCard.stories.tsx | 20 ++++++++++++++++---- lib/components/HeroCard/HeroCard.test.tsx | 10 ++++++++-- lib/components/HeroCard/HeroCard.tsx | 12 ++++++------ 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/lib/components/HeroCard/HeroCard.stories.tsx b/lib/components/HeroCard/HeroCard.stories.tsx index 3755199..90bef29 100644 --- a/lib/components/HeroCard/HeroCard.stories.tsx +++ b/lib/components/HeroCard/HeroCard.stories.tsx @@ -15,6 +15,7 @@ type Story = StoryObj; const secondaryCardArgs = { title: 'Tunnista osaamistasi ja tutki mahdollisuuksia', backgroundColor: '#00A8B3F2', + href: '/', }; export const Primary: Story = { @@ -38,6 +39,7 @@ export const Primary: Story = { 'Elämä on jatkuvaa muutosta ja uudistumista. Olipa kyse uran vaihdosta, uuden osaamisen oppimisesta tai henkilökohtaisen elämäntilanteen parantamisesta, me tarjoamme sinulle tiedon ja inspiraation joita tarvitset.', backgroundColor: '#006DB3F2', actionContent: 'Kokeile palvelua', + href: '/', }, decorators: [ (Story) => ( @@ -62,6 +64,7 @@ export const Secondary: Story = { }, args: { title: secondaryCardArgs.title, + href: secondaryCardArgs.href, }, decorators: [ (Story) => ( @@ -90,9 +93,13 @@ export const MultipleSecondary: Story = {
- +
), ], @@ -120,6 +127,7 @@ export const Hero: Story = { 'Elämä on jatkuvaa muutosta ja uudistumista. Olipa kyse uran vaihdosta, uuden osaamisen oppimisesta tai henkilökohtaisen elämäntilanteen parantamisesta, me tarjoamme sinulle tiedon ja inspiraation joita tarvitset.', backgroundColor: '#006DB3F2', actionContent: 'Kokeile palvelua', + href: '/', }, decorators: [ (Story) => ( @@ -130,9 +138,13 @@ export const Hero: Story = {
- +
), diff --git a/lib/components/HeroCard/HeroCard.test.tsx b/lib/components/HeroCard/HeroCard.test.tsx index 593c9de..f16e8d8 100644 --- a/lib/components/HeroCard/HeroCard.test.tsx +++ b/lib/components/HeroCard/HeroCard.test.tsx @@ -16,7 +16,13 @@ describe('HeroCard', () => { it('renders HeroCard with actionContent', () => { render( - , + , ); // Assert title, content, and actionContent are rendered @@ -42,7 +48,7 @@ describe('HeroCard', () => { }); it('renders HeroCard without actionContent', () => { - render(); + render(); // Assert title and content are rendered expect(screen.getByText(title)).toBeInTheDocument(); diff --git a/lib/components/HeroCard/HeroCard.tsx b/lib/components/HeroCard/HeroCard.tsx index c229a7e..1d4fcc4 100644 --- a/lib/components/HeroCard/HeroCard.tsx +++ b/lib/components/HeroCard/HeroCard.tsx @@ -8,7 +8,7 @@ export interface HeroCardProps { /** Background color of the card */ backgroundColor?: string; /** Link to page */ - href?: string; + href: string; } export const HeroCard = ({ title, content, actionContent, backgroundColor = '#444BACF2', href }: HeroCardProps) => ( @@ -23,7 +23,7 @@ export const HeroCard = ({ title, content, actionContent, backgroundColor = '#44 /> ) : ( - + )} @@ -33,7 +33,7 @@ const BaseCard = ({ title, content, actionContent, backgroundColor, href }: Hero const Heading = actionContent ? 'h1' : 'h2'; return (
{title} @@ -41,10 +41,10 @@ const BaseCard = ({ title, content, actionContent, backgroundColor, href }: Hero {actionContent ? (
{actionContent} @@ -52,7 +52,7 @@ const BaseCard = ({ title, content, actionContent, backgroundColor, href }: Hero
) : ( - + )}