Skip to content

Commit

Permalink
feat: add guidelines component to library
Browse files Browse the repository at this point in the history
  • Loading branch information
benfurber committed Jun 5, 2024
1 parent 592489a commit 38a50a2
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 10 deletions.
38 changes: 38 additions & 0 deletions packages/components/src/Guidelines/Guidelines.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { ExternalLink } from '../ExternalLink/ExternalLink'
import { Guidelines } from './Guidelines'

import type { Meta, StoryFn } from '@storybook/react'

export default {
title: 'Components/Guidelines',
component: Guidelines,
} as Meta<typeof Guidelines>

export const Default: StoryFn<typeof Guidelines> = () => (
<Guidelines
title="How does it work?"
steps={[
<>
Choose a topic you want to research{' '}
<span role="img" aria-label="raised-hand">
🙌
</span>
</>,
<>
Read{' '}
<ExternalLink sx={{ color: 'blue' }} href="/academy/guides/research">
our guidelines{' '}
<span role="img" aria-label="nerd-face">
🤓
</span>
</ExternalLink>
</>,
<>
Write your introduction{' '}
<span role="img" aria-label="archive-box">
🗄️
</span>
</>,
]}
/>
)
15 changes: 15 additions & 0 deletions packages/components/src/Guidelines/Guidelines.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { render } from '../tests/utils'
import { Default } from './Guidelines.stories'

import type { IProps } from './Guidelines'

describe('Guidelines', () => {
it('validates the component behaviour', () => {
const { getByText } = render(<Default {...(Default.args as IProps)} />)

expect(getByText('How does it work?')).toBeInTheDocument()
expect(
getByText('Choose a topic you want to research', { exact: false }),
).toBeInTheDocument()
})
})
28 changes: 28 additions & 0 deletions packages/components/src/Guidelines/Guidelines.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Card, Flex, Heading, Text } from 'theme-ui'

import type { ReactElement } from 'react'

export interface IProps {
title: string
steps: ReactElement[]
}

export const Guidelines = ({ title, steps }: IProps) => {
return (
<Card>
<Flex sx={{ flexDirection: 'column', padding: [2, 3, 4], gap: 1 }}>
<Heading as="h2" mb={2}>
{title}
</Heading>

{steps.map((step, index) => {
return (
<Text variant="auxiliary" key={index}>
{`${index + 1}. `} {step}
</Text>
)
})}
</Flex>
</Card>
)
}
21 changes: 11 additions & 10 deletions packages/components/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
export { ArticleCallToAction } from './ArticleCallToAction/ArticleCallToAction'
export { BlockedRoute } from './BlockedRoute/BlockedRoute'
export { Breadcrumbs } from './Breadcrumbs/Breadcrumbs'
export { Button } from './Button/Button'
export { ButtonShowReplies } from './ButtonShowReplies/ButtonShowReplies'
export { Category } from './Category/Category'
export { ContentStatistics } from './ContentStatistics/ContentStatistics'
export { CommentItem } from './CommentItem/CommentItem'
export { CommentList } from './CommentList/CommentList'
export { CreateReply } from './CreateReply/CreateReply'
export { ConfirmModal } from './ConfirmModal/ConfirmModal'
export { CreateComment } from './CreateComment/CreateComment'
export { DiscussionContainer } from './DiscussionContainer/DiscussionContainer'
export { DiscussionTitle } from './DiscussionTitle/DiscussionTitle'
export { DonationRequest } from './DonationRequest/DonationRequest'
export { DonationRequestModal } from './DonationRequestModal/DonationRequestModal'
export { DownloadButton } from './DownloadButton/DownloadButton'
export { DownloadCounter } from './DownloadCounter/DownloadCounter'
export { DownloadFileFromLink } from './DownloadFileFromLink/DownloadFileFromLink'
export { DownloadStaticFile } from './DownloadStaticFile/DownloadStaticFile'
export { EditComment } from './EditComment/EditComment'
export { ElWithBeforeIcon } from './ElWithBeforeIcon/ElWithBeforeIcon'
export { ExternalLink } from './ExternalLink/ExternalLink'
export { FieldDatepicker } from './FieldDatepicker/FieldDatepicker'
export { FieldInput } from './FieldInput/FieldInput'
export { FieldTextarea } from './FieldTextarea/FieldTextarea'
export { DownloadStaticFile } from './DownloadStaticFile/DownloadStaticFile'
export { Guidelines } from './Guidelines/Guidelines'
export { FlagIcon, FlagIconHowTos, FlagIconEvents } from './FlagIcon/FlagIcon'
export { FollowButton } from './FollowButton/FollowButton'
export { GlobalStyles } from './GlobalStyles/GlobalStyles'
export { Icon } from './Icon/Icon'
export { IconCountWithTooltip } from './IconCountWithTooltip/IconCountWithTooltip'
export { ImageCrop } from './ImageCrop/ImageCrop'
export { ImageGallery } from './ImageGallery/ImageGallery'
export { InternalLink } from './InternalLink/InternalLink'
Expand All @@ -40,21 +48,14 @@ export { ProfileLink } from './ProfileLink/ProfileLink'
export { ResearchEditorOverview } from './ResearchEditorOverview/ResearchEditorOverview'
export { Select } from './Select/Select'
export { SiteFooter } from './SiteFooter/SiteFooter'
export { Tab, TabsList, TabPanel, Tabs } from './TabbedContent/TabbedContent'
export { Tag } from './Tag/Tag'
export { TagList } from './TagList/TagList'
export { TextNotification } from './TextNotification/TextNotification'
export { Tooltip } from './Tooltip/Tooltip'
export { UsefulStatsButton } from './UsefulStatsButton/UsefulStatsButton'
export { UserEngagementWrapper } from './UserEngagementWrapper/UserEngagementWrapper'
export { Username } from './Username/Username'
export { UserStatistics } from './UserStatistics/UserStatistics'
export { VideoPlayer } from './VideoPlayer/VideoPlayer'
export { BlockedRoute } from './BlockedRoute/BlockedRoute'
export { ContentStatistics } from './ContentStatistics/ContentStatistics'
export { Tab, TabsList, TabPanel, Tabs } from './TabbedContent/TabbedContent'
export { DiscussionContainer } from './DiscussionContainer/DiscussionContainer'
export { DiscussionTitle } from './DiscussionTitle/DiscussionTitle'
export { UserEngagementWrapper } from './UserEngagementWrapper/UserEngagementWrapper'
export { IconCountWithTooltip } from './IconCountWithTooltip/IconCountWithTooltip'
export { DonationRequest } from './DonationRequest/DonationRequest'
export { DonationRequestModal } from './DonationRequestModal/DonationRequestModal'
export { UserNotificationItem } from './NotificationItem/NotificationItem'

0 comments on commit 38a50a2

Please sign in to comment.