diff --git a/web/src/components/Comment/Comment.stories.tsx b/web/src/components/Comment/Comment.stories.tsx new file mode 100644 index 000000000..83dea125e --- /dev/null +++ b/web/src/components/Comment/Comment.stories.tsx @@ -0,0 +1,15 @@ +import Comment from './Comment' + +export const generated = () => { + return ( + + ) +} + +export default { title: 'Components/Comment' } diff --git a/web/src/components/Comment/Comment.test.tsx b/web/src/components/Comment/Comment.test.tsx new file mode 100644 index 000000000..a1bc6f833 --- /dev/null +++ b/web/src/components/Comment/Comment.test.tsx @@ -0,0 +1,14 @@ +import { render } from '@redwoodjs/testing/web' + +import Comment from './Comment' + +// Improve this test with help from the Redwood Testing Doc: +// https://redwoodjs.com/docs/testing#testing-components + +describe('Comment', () => { + it('renders successfully', () => { + expect(() => { + render() + }).not.toThrow() + }) +}) diff --git a/web/src/components/Comment/Comment.tsx b/web/src/components/Comment/Comment.tsx new file mode 100644 index 000000000..f146714bb --- /dev/null +++ b/web/src/components/Comment/Comment.tsx @@ -0,0 +1,30 @@ +const formattedDate = (datetime: ConstructorParameters[0]) => { + const parsedDate = new Date(datetime) + const month = parsedDate.toLocaleString('default', { month: 'long' }) + return `${parsedDate.getDate()} ${month} ${parsedDate.getFullYear()}` +} + +// Just a temporary type. We'll replace this later +interface Props { + comment: { + name: string + createdAt: string + body: string + } +} + +const Comment = ({ comment }: Props) => { + return ( +
+
+

{comment.name}

+ +
+

{comment.body}

+
+ ) +} + +export default Comment