-
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.
feat(MessageThread): add message thread component
- Loading branch information
Showing
18 changed files
with
262 additions
and
89 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
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
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
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
5 changes: 5 additions & 0 deletions
5
packages/components/src/components/MessageThread/MessageThread.module.scss
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,5 @@ | ||
.messageThread { | ||
display: flex; | ||
flex-direction: column; | ||
row-gap: var(--message-thread--spacing); | ||
} |
15 changes: 15 additions & 0 deletions
15
packages/components/src/components/MessageThread/MessageThread.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,15 @@ | ||
import type { FC, PropsWithChildren } from "react"; | ||
import React from "react"; | ||
import type { PropsWithClassName } from "@/lib/types/props"; | ||
import clsx from "clsx"; | ||
import styles from "./MessageThread.module.scss"; | ||
|
||
export type MessageThreadProps = PropsWithChildren & PropsWithClassName; | ||
|
||
export const MessageThread: FC<MessageThreadProps> = (props) => { | ||
const { children, className } = props; | ||
|
||
const rootClassName = clsx(styles.messageThread, className); | ||
|
||
return <div className={rootClassName}>{children}</div>; | ||
}; |
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,4 @@ | ||
import { MessageThread } from "./MessageThread"; | ||
|
||
export { type MessageThreadProps, MessageThread } from "./MessageThread"; | ||
export default MessageThread; |
68 changes: 68 additions & 0 deletions
68
packages/components/src/components/MessageThread/stories/Default.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,68 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import type { FC } from "react"; | ||
import React from "react"; | ||
import type { MessageProps } from "@/components/Message"; | ||
import { Message } from "@/components/Message"; | ||
import { MessageThread } from "@/components/MessageThread"; | ||
import { Header } from "@/components/Header"; | ||
import { Align } from "@/components/Align"; | ||
import { Avatar } from "@/components/Avatar"; | ||
import { Initials } from "@/components/Initials"; | ||
import { Text } from "@/components/Text"; | ||
import { Content } from "@/components/Content"; | ||
import { dummyText } from "@/lib/dev/dummyText"; | ||
|
||
interface ExampleMessageProps extends Pick<MessageProps, "type"> { | ||
name: string; | ||
content: string; | ||
} | ||
const ExampleMessage: FC<ExampleMessageProps> = (props) => { | ||
const { name, content, ...rest } = props; | ||
return ( | ||
<Message {...rest}> | ||
<Header> | ||
<Align> | ||
<Avatar> | ||
<Initials>{name}</Initials> | ||
</Avatar> | ||
<Text> | ||
<b>{name}</b> | ||
</Text> | ||
</Align> | ||
</Header> | ||
|
||
<Content> | ||
<Text>{content}</Text> | ||
</Content> | ||
</Message> | ||
); | ||
}; | ||
|
||
const meta: Meta<typeof MessageThread> = { | ||
title: "Content/MessageThread", | ||
component: MessageThread, | ||
render: (props) => ( | ||
<MessageThread {...props}> | ||
<ExampleMessage | ||
name="Max Mustermann" | ||
content={dummyText.medium} | ||
type="sender" | ||
/> | ||
<ExampleMessage | ||
name="John Doe" | ||
content={dummyText.long} | ||
type="responder" | ||
/> | ||
<ExampleMessage | ||
name="Max Mustermann" | ||
content={dummyText.short} | ||
type="sender" | ||
/> | ||
</MessageThread> | ||
), | ||
}; | ||
export default meta; | ||
|
||
type Story = StoryObj<typeof MessageThread>; | ||
|
||
export const Default: Story = {}; |
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
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,3 @@ | ||
message-thread: | ||
spacing: | ||
value: "{size-rem.l}" |
46 changes: 0 additions & 46 deletions
46
packages/docs/src/content/03-components/content/message/examples/right.tsx
This file was deleted.
Oops, something went wrong.
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
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
3 changes: 3 additions & 0 deletions
3
packages/docs/src/content/03-components/content/messageThread/develop.mdx
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,3 @@ | ||
# Properties | ||
|
||
<PropertiesTables /> |
73 changes: 73 additions & 0 deletions
73
packages/docs/src/content/03-components/content/messageThread/examples/default.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,73 @@ | ||
import { Message } from "@mittwald/flow-react-components/Message"; | ||
import { Header } from "@mittwald/flow-react-components/Header"; | ||
import { Align } from "@mittwald/flow-react-components/Align"; | ||
import { Avatar } from "@mittwald/flow-react-components/Avatar"; | ||
import { Initials } from "@mittwald/flow-react-components/Initials"; | ||
import { Text } from "@mittwald/flow-react-components/Text"; | ||
import { Content } from "@mittwald/flow-react-components/Content"; | ||
import { MessageThread } from "@mittwald/flow-react-components/MessageThread"; | ||
|
||
<MessageThread> | ||
<Message type="sender"> | ||
<Header> | ||
<Align> | ||
<Avatar> | ||
<Initials>Max Mustermann</Initials> | ||
</Avatar> | ||
<Text> | ||
<b>Max Mustermann</b> | ||
</Text> | ||
</Align> | ||
</Header> | ||
<Content> | ||
<Text> | ||
Lorem ipsum dolor sit amet consectetur adipisicing | ||
elit. Cumque eius quam quas vel voluptas, ullam | ||
aliquid fugit. Voluptate harum accusantium rerum | ||
ullam modi blanditiis vitae. | ||
</Text> | ||
</Content> | ||
</Message> | ||
|
||
<Message type="responder"> | ||
<Header> | ||
<Align> | ||
<Avatar> | ||
<Initials>John Doe</Initials> | ||
</Avatar> | ||
<Text> | ||
<b>John Doe</b> | ||
</Text> | ||
</Align> | ||
</Header> | ||
<Content> | ||
<Text> | ||
Lorem ipsum dolor sit amet consectetur adipisicing | ||
elit. Cumque eius quam quas vel voluptas, ullam | ||
aliquid fugit. Voluptate harum accusantium rerum | ||
ullam modi blanditiis vitae, laborum ea tempore, | ||
dolore voluptas. Earum pariatur, similique corrupti | ||
id officia perferendis. Labore, similique. Earum, | ||
quas in. At dolorem corrupti blanditiis nulla | ||
deserunt laborum! Corrupti delectus aspernatur nihil | ||
nulla obcaecati ipsam porro sequi rem? Quam. | ||
</Text> | ||
</Content> | ||
</Message> | ||
|
||
<Message type="sender"> | ||
<Header> | ||
<Align> | ||
<Avatar> | ||
<Initials>Max Mustermann</Initials> | ||
</Avatar> | ||
<Text> | ||
<b>Max Mustermann</b> | ||
</Text> | ||
</Align> | ||
</Header> | ||
<Content> | ||
<Text>Lorem ipsum dolor sit amet.</Text> | ||
</Content> | ||
</Message> | ||
</MessageThread>; |
Oops, something went wrong.