Skip to content

Commit

Permalink
feat(ui): add option prop on Date component
Browse files Browse the repository at this point in the history
Add `dateFormat` prop to customize date output format
  • Loading branch information
mateusfg7 committed May 10, 2023
1 parent c1cd49a commit 015b232
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/components/Date.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ import { parseISO, format } from 'date-fns'

interface Props {
dateString: string
dateFormat?: string
}

export const Date: React.FC<Props> = ({ dateString }) => {
export const Date: React.FC<Props> = ({
dateString,
dateFormat = 'LLL d, yyyy'
}) => {
const date = parseISO(dateString)

return <time dateTime={dateString}>{format(date, 'LLL d, yyyy')}</time>
return <time dateTime={dateString}>{format(date, dateFormat)}</time>
}

0 comments on commit 015b232

Please sign in to comment.