generated from theodorusclarence/ts-nextjs-tailwind-starter
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b025bfe
commit 259c8de
Showing
3 changed files
with
74 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'use client'; | ||
|
||
import * as React from 'react'; | ||
|
||
import { shuffleArray } from '@/lib/helper'; | ||
|
||
import Button from '@/components/buttons/Button'; | ||
|
||
import { RandomFact } from '@/types/RandomFact'; | ||
|
||
export interface QuizAnswer { | ||
headline: string; | ||
key?: string; | ||
} | ||
|
||
export interface GeneralViewProps { | ||
facts: RandomFact[]; | ||
} | ||
|
||
const GeneralView = ({ facts }: GeneralViewProps) => { | ||
const randomFact = shuffleArray(facts)[0]; | ||
|
||
return ( | ||
<div className='p4 rounded dark:bg-slate-900'> | ||
<div className='mb-5'>{randomFact.description}</div> | ||
|
||
<div className='flex justify-center'> | ||
<Button>Load another random fact</Button> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default GeneralView; |
34 changes: 34 additions & 0 deletions
34
src/components/molecules/RandomFacts/__stories__/GeneralView.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Meta } from '@storybook/react'; | ||
|
||
import GeneralView, { | ||
GeneralViewProps, | ||
} from '@/components/molecules/RandomFacts/GeneralView'; | ||
|
||
import { RandomFact } from '@/types/RandomFact'; | ||
|
||
const meta: Meta<typeof GeneralView> = { | ||
title: 'Components/Random Facts/General View', | ||
component: GeneralView, | ||
tags: ['autodocs'], | ||
}; | ||
|
||
export default meta; | ||
|
||
const facts: RandomFact[] = [ | ||
{ | ||
_id: 'a', | ||
name: 'name', | ||
headline: '', | ||
description: | ||
'I have been officially excommunicated by the Roman Catholic Church ⛪', | ||
trueFact: true, | ||
explanation: '', | ||
}, | ||
]; | ||
|
||
export const SampleStory = (args: GeneralViewProps) => ( | ||
<GeneralView {...args} /> | ||
); | ||
SampleStory.args = { | ||
facts, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters