From 510615c74b323917e18244e07d57c3acc1f5f5bf Mon Sep 17 00:00:00 2001
From: Pavel Prichodko <14926950+prichodko@users.noreply.github.com>
Date: Fri, 20 Jan 2023 15:21:21 +0100
Subject: [PATCH] rename chat message -> messages and cleanup
---
.../src/chat-message/components/actions.tsx | 15 ----
.../src/chat-message/components/reactions.tsx | 31 -------
.../chat-message.tsx | 29 +++---
.../messages/components/actions.stories.tsx | 41 +++++++++
.../src/messages/components/actions.tsx | 31 +++++++
.../messages/components/reactions.stories.tsx | 25 ++++++
.../src/messages/components/reactions.tsx | 88 +++++++++++++++++++
.../src/{chat-message => messages}/index.tsx | 27 +++---
.../messages.stories.tsx} | 38 ++++++--
9 files changed, 246 insertions(+), 79 deletions(-)
delete mode 100644 packages/components/src/chat-message/components/actions.tsx
delete mode 100644 packages/components/src/chat-message/components/reactions.tsx
rename packages/components/src/{chat-message => messages}/chat-message.tsx (78%)
create mode 100644 packages/components/src/messages/components/actions.stories.tsx
create mode 100644 packages/components/src/messages/components/actions.tsx
create mode 100644 packages/components/src/messages/components/reactions.stories.tsx
create mode 100644 packages/components/src/messages/components/reactions.tsx
rename packages/components/src/{chat-message => messages}/index.tsx (64%)
rename packages/components/src/{chat-message/chat-message.stories.tsx => messages/messages.stories.tsx} (57%)
diff --git a/packages/components/src/chat-message/components/actions.tsx b/packages/components/src/chat-message/components/actions.tsx
deleted file mode 100644
index 73b44291..00000000
--- a/packages/components/src/chat-message/components/actions.tsx
+++ /dev/null
@@ -1,15 +0,0 @@
-import { Stack } from 'tamagui'
-
-import { Paragraph } from '../../typography'
-
-interface Props {
- onClick?: VoidFunction
-}
-
-export const Actions = (_props: Props) => {
- return (
-
- actions
-
- )
-}
diff --git a/packages/components/src/chat-message/components/reactions.tsx b/packages/components/src/chat-message/components/reactions.tsx
deleted file mode 100644
index 66af3659..00000000
--- a/packages/components/src/chat-message/components/reactions.tsx
+++ /dev/null
@@ -1,31 +0,0 @@
-import { Pressable } from 'react-native'
-import { Stack, XStack, YStack } from 'tamagui'
-
-interface Props {}
-
-const ReactionButton = ({ type }) => {
- return (
-
- {type}
-
- )
-}
-
-export const Reactions = (props: Props) => {
- const {} = props
-
- return (
-
-
-
-
-
-
-
- )
-}
diff --git a/packages/components/src/chat-message/chat-message.tsx b/packages/components/src/messages/chat-message.tsx
similarity index 78%
rename from packages/components/src/chat-message/chat-message.tsx
rename to packages/components/src/messages/chat-message.tsx
index 044d602a..6a63b7f5 100644
--- a/packages/components/src/chat-message/chat-message.tsx
+++ b/packages/components/src/messages/chat-message.tsx
@@ -2,6 +2,7 @@ import React from 'react'
import { Stack, Unspaced, XStack, YStack } from 'tamagui'
+import { Author } from '../author/author'
import { Avatar } from '../avatar'
import { Image } from '../image'
import { Paragraph } from '../typography'
@@ -24,7 +25,6 @@ const ChatMessage = (props: Props) => {
space={10}
position="relative"
alignItems="flex-start"
- justifyContent="center"
paddingHorizontal={8}
paddingVertical={12}
borderRadius={16}
@@ -36,7 +36,7 @@ const ChatMessage = (props: Props) => {
>
{hovered && (
-
+ {}} />
)}
@@ -47,17 +47,12 @@ const ChatMessage = (props: Props) => {
/>
-
-
- Alisher Yakupov
-
-
- zQ3...9d4Gs0
-
-
- 09:30
-
-
+
{text && (
@@ -70,7 +65,7 @@ const ChatMessage = (props: Props) => {
key={image.url}
borderRadius={12}
overflow="hidden"
- marginTop={6}
+ marginTop={8}
$gtMd={{
maxWidth: 320,
}}
@@ -79,7 +74,11 @@ const ChatMessage = (props: Props) => {
))}
- {reactions && }
+ {reactions && (
+
+
+
+ )}
)
diff --git a/packages/components/src/messages/components/actions.stories.tsx b/packages/components/src/messages/components/actions.stories.tsx
new file mode 100644
index 00000000..712f6c93
--- /dev/null
+++ b/packages/components/src/messages/components/actions.stories.tsx
@@ -0,0 +1,41 @@
+import { Actions } from './actions'
+
+import type { Meta, StoryObj } from '@storybook/react'
+
+// More on how to set up stories at: https://storybook.js.org/docs/7.0/react/writing-stories/introduction
+const meta: Meta = {
+ title: 'Messages/actions',
+ component: Actions,
+ argTypes: {},
+ parameters: {
+ layout: 'centered',
+ design: {
+ type: 'figma',
+ url: 'https://www.figma.com/file/IBmFKgGL1B4GzqD8LQTw6n/Design-System-for-Web?node-id=14560%3A157866&t=87Ziud3PyYYSvsRg-4',
+ },
+ },
+ decorators: [
+ Story => {
+ return (
+
+
+
+ )
+ },
+ ],
+}
+
+type Story = StoryObj
+
+// More on writing stories with args: https://storybook.js.org/docs/7.0/react/writing-stories/args
+export const Default: Story = {
+ args: {},
+}
+
+export default meta
diff --git a/packages/components/src/messages/components/actions.tsx b/packages/components/src/messages/components/actions.tsx
new file mode 100644
index 00000000..30c73bd0
--- /dev/null
+++ b/packages/components/src/messages/components/actions.tsx
@@ -0,0 +1,31 @@
+import { AddReaction, Options, Reply } from '@status-im/icons/20'
+import { Stack } from 'tamagui'
+
+import { Button } from '../../button'
+
+interface Props {
+ onClick: VoidFunction
+}
+export const Actions = (_props: Props) => {
+ return (
+
+ } borderRadius={0} />
+ } borderRadius={0} />
+ } borderRadius={0} />
+
+ )
+}
diff --git a/packages/components/src/messages/components/reactions.stories.tsx b/packages/components/src/messages/components/reactions.stories.tsx
new file mode 100644
index 00000000..5761436e
--- /dev/null
+++ b/packages/components/src/messages/components/reactions.stories.tsx
@@ -0,0 +1,25 @@
+import { Reactions } from './reactions'
+
+import type { Meta, StoryObj } from '@storybook/react'
+
+// More on how to set up stories at: https://storybook.js.org/docs/7.0/react/writing-stories/introduction
+const meta: Meta = {
+ title: 'messages/reactions',
+ component: Reactions,
+ argTypes: {},
+ parameters: {
+ design: {
+ type: 'figma',
+ url: 'https://www.figma.com/file/IBmFKgGL1B4GzqD8LQTw6n/Design-System-for-Web?node-id=12375%3A140482&t=87Ziud3PyYYSvsRg-4',
+ },
+ },
+}
+
+type Story = StoryObj
+
+// More on writing stories with args: https://storybook.js.org/docs/7.0/react/writing-stories/args
+export const Default: Story = {
+ args: {},
+}
+
+export default meta
diff --git a/packages/components/src/messages/components/reactions.tsx b/packages/components/src/messages/components/reactions.tsx
new file mode 100644
index 00000000..a28ba3c3
--- /dev/null
+++ b/packages/components/src/messages/components/reactions.tsx
@@ -0,0 +1,88 @@
+import { cloneElement } from 'react'
+
+import { AddReaction } from '@status-im/icons/20'
+import {
+ Angry,
+ Laugh,
+ Love,
+ Sad,
+ ThumbsDown,
+ ThumbsUp,
+} from '@status-im/icons/reactions'
+import { Stack, styled } from '@tamagui/core'
+import { XStack } from 'tamagui'
+
+import { Paragraph } from '../../typography'
+
+import type React from 'react'
+
+// import { Pressable } from 'react-native'
+
+const ReactButton = styled(Stack, {
+ name: 'ReactButton',
+ accessibilityRole: 'button',
+
+ cursor: 'pointer',
+ userSelect: 'none',
+ borderRadius: 8,
+ display: 'inline-flex',
+ flexDirection: 'row',
+ space: 4,
+ alignItems: 'center',
+ justifyContent: 'center',
+ flexShrink: 0,
+ minWidth: 36,
+ height: 24,
+ paddingHorizontal: 8,
+ borderWidth: 1,
+ borderColor: '$neutral-20',
+
+ hoverStyle: {
+ borderColor: '$neutral-30',
+ },
+
+ variants: {
+ selected: {
+ true: {
+ backgroundColor: '$neutral-30',
+ borderColor: '$neutral-30',
+ },
+ },
+ } as const,
+})
+
+interface Props {
+ icon: React.ReactElement
+ count: number
+ selected?: boolean
+}
+
+const ReactionButton = (props: Props) => {
+ const { count, selected, icon } = props
+
+ return (
+
+ {cloneElement(icon, { color: '$neutral-100' })}
+
+ {count}
+
+
+ )
+}
+
+export const Reactions = (props: Props) => {
+ const {} = props
+
+ return (
+
+ } selected />
+ } />
+ } />
+ } />
+ } />
+ {/* */}
+ } />
+ } />
+
+ )
+}
diff --git a/packages/components/src/chat-message/index.tsx b/packages/components/src/messages/index.tsx
similarity index 64%
rename from packages/components/src/chat-message/index.tsx
rename to packages/components/src/messages/index.tsx
index 50ad8290..9db88ef4 100644
--- a/packages/components/src/chat-message/index.tsx
+++ b/packages/components/src/messages/index.tsx
@@ -1,16 +1,10 @@
-import { Stack } from '@tamagui/core'
-
import { ChatMessage } from './chat-message'
-import type { GetProps } from '@tamagui/core'
-
export * from './chat-message'
-type BaseProps = GetProps
-
-export const Messages = (props: BaseProps) => {
+export const Messages = () => {
return (
-
+ <>
@@ -21,12 +15,21 @@ export const Messages = (props: BaseProps) => {
},
]}
/>
+
-
-
-
-
+
+
+ >
)
}
diff --git a/packages/components/src/chat-message/chat-message.stories.tsx b/packages/components/src/messages/messages.stories.tsx
similarity index 57%
rename from packages/components/src/chat-message/chat-message.stories.tsx
rename to packages/components/src/messages/messages.stories.tsx
index d815f0ca..7d4ddadf 100644
--- a/packages/components/src/chat-message/chat-message.stories.tsx
+++ b/packages/components/src/messages/messages.stories.tsx
@@ -4,6 +4,7 @@ import type { Meta, StoryObj } from '@storybook/react'
// More on how to set up stories at: https://storybook.js.org/docs/7.0/react/writing-stories/introduction
const meta: Meta = {
+ // title: 'Messages',
component: ChatMessage,
argTypes: {},
parameters: {
@@ -16,28 +17,40 @@ const meta: Meta = {
type Story = StoryObj
+const reactions = ['123']
+
// More on writing stories with args: https://storybook.js.org/docs/7.0/react/writing-stories/args
-export const Simple: Story = {
+export const Text: Story = {
args: {
text: 'This is a simple message.',
},
}
-export const SimpleLongText: Story = {
+export const TextWithReactions: Story = {
+ name: 'Text + Reactions',
+ args: {
+ text: 'This is a simple message.',
+ reactions,
+ },
+}
+
+export const LongText: Story = {
+ name: 'Long text',
args: {
text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
},
}
-export const SimpleWithReactions: Story = {
- name: 'Simple with reactions',
+export const LongTextReactions: Story = {
+ name: 'Long text + Reactions',
args: {
- text: 'This is a simple message.',
- reactions: ['thumb'],
+ text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
+ reactions,
},
}
export const Image: Story = {
+ name: 'Image',
args: {
images: [
{
@@ -47,4 +60,17 @@ export const Image: Story = {
},
}
+export const ImageWithReactions: Story = {
+ name: 'Image + Reactions',
+ args: {
+ reactions,
+
+ images: [
+ {
+ url: 'https://images.unsplash.com/photo-1673831792265-68b44126c999?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=866&q=80',
+ },
+ ],
+ },
+}
+
export default meta