Skip to content

Commit

Permalink
tag chips
Browse files Browse the repository at this point in the history
  • Loading branch information
ann-kilzer committed Apr 18, 2024
1 parent daab65d commit 48333ee
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/components/Article/Article.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
import { FC } from 'react';
import Box from '@mui/material/Box'
import Chip from '@mui/material/Chip'
import Divider from '@mui/material/Divider'
import Stack from '@mui/material/Stack'
import Typography from '@mui/material/Typography'
import TagChips from '../TagChips/TagChips';


interface Article {
interface ArticleProps {
title: string
subtitle: string
body: string
date: Date
tags: string[]
}

const Article: FC<Article> = ({
const Article: FC<ArticleProps> = ({
title,
subtitle,
body,
date,
tags,
}) => {
console.log(date.toLocaleString())
return <Box sx={{ my: 2 }}>
<Typography variant="h3">{title}</Typography>
<Typography variant="subtitle1">{subtitle}</Typography>
Expand All @@ -31,13 +30,7 @@ const Article: FC<Article> = ({
<Divider sx={{ my: 1 }} />
<Stack direction="row" spacing={2}>
<Typography variant="overline">Posted: {date.toLocaleDateString()}</Typography>
{tags.map((tag: string) => {
return <Chip
label={tag}
key={tag}
sx={{ mr: 1 }}
/>
})}
<TagChips tags={tags} />
</Stack>
<Divider sx={{ my: 1 }} />
</Box>
Expand Down
19 changes: 19 additions & 0 deletions src/components/TagChips/TagChips.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { FC } from 'react';

import Chip from '@mui/material/Chip'

interface TagChipsProps {
tags: string[]
}

const TagChips: FC<TagChipsProps> = ({ tags }) => {
return tags.map((tag: string) => {
return <Chip
label={tag}
key={tag}
sx={{ mr: 1 }}
/>
})
}

export default TagChips

0 comments on commit 48333ee

Please sign in to comment.