rename chat message -> messages and cleanup
This commit is contained in:
parent
bf9e76d960
commit
0be4c340b4
|
@ -1,15 +0,0 @@
|
|||
import { Stack } from 'tamagui'
|
||||
|
||||
import { Paragraph } from '../../typography'
|
||||
|
||||
interface Props {
|
||||
onClick?: VoidFunction
|
||||
}
|
||||
|
||||
export const Actions = (_props: Props) => {
|
||||
return (
|
||||
<Stack position="absolute" top={0} right={0}>
|
||||
<Paragraph>actions</Paragraph>
|
||||
</Stack>
|
||||
)
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
import { Pressable } from 'react-native'
|
||||
import { Stack, XStack, YStack } from 'tamagui'
|
||||
|
||||
interface Props {}
|
||||
|
||||
const ReactionButton = ({ type }) => {
|
||||
return (
|
||||
<Stack
|
||||
padding={3}
|
||||
borderWidth={1}
|
||||
borderColor="$neutral-100"
|
||||
borderRadius={2}
|
||||
>
|
||||
{type}
|
||||
</Stack>
|
||||
)
|
||||
}
|
||||
|
||||
export const Reactions = (props: Props) => {
|
||||
const {} = props
|
||||
|
||||
return (
|
||||
<XStack>
|
||||
<ReactionButton type="like" />
|
||||
<ReactionButton type="+1" />
|
||||
<ReactionButton type="-1" />
|
||||
<ReactionButton type="sad" />
|
||||
<ReactionButton type="angry" />
|
||||
</XStack>
|
||||
)
|
||||
}
|
|
@ -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 && (
|
||||
<Unspaced>
|
||||
<Actions />
|
||||
<Actions onClick={() => {}} />
|
||||
</Unspaced>
|
||||
)}
|
||||
|
||||
|
@ -47,17 +47,12 @@ const ChatMessage = (props: Props) => {
|
|||
/>
|
||||
|
||||
<YStack flex={1}>
|
||||
<XStack space={8} alignItems="center">
|
||||
<Paragraph weight="semibold" color="$neutral-100">
|
||||
Alisher Yakupov
|
||||
</Paragraph>
|
||||
<Paragraph color="$neutral-50" fontSize={11}>
|
||||
zQ3...9d4Gs0
|
||||
</Paragraph>
|
||||
<Paragraph color="$neutral-50" variant={11}>
|
||||
09:30
|
||||
</Paragraph>
|
||||
</XStack>
|
||||
<Author
|
||||
name="Alisher Yakupov"
|
||||
address="zQ3...9d4Gs0"
|
||||
status="verified"
|
||||
time="09:30"
|
||||
/>
|
||||
|
||||
{text && (
|
||||
<Paragraph flexGrow={0} weight="regular" color="$neutral-100">
|
||||
|
@ -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) => {
|
|||
</Stack>
|
||||
))}
|
||||
|
||||
{reactions && <Reactions />}
|
||||
{reactions && (
|
||||
<Stack marginTop={8}>
|
||||
<Reactions />
|
||||
</Stack>
|
||||
)}
|
||||
</YStack>
|
||||
</XStack>
|
||||
)
|
|
@ -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<typeof Actions> = {
|
||||
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 (
|
||||
<div
|
||||
style={{
|
||||
position: 'relative',
|
||||
width: 110,
|
||||
height: 38,
|
||||
}}
|
||||
>
|
||||
<Story />
|
||||
</div>
|
||||
)
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
type Story = StoryObj<typeof Actions>
|
||||
|
||||
// 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
|
|
@ -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 (
|
||||
<Stack
|
||||
backgroundColor="$white-100"
|
||||
borderWidth={1}
|
||||
borderColor="$neutral-10"
|
||||
borderRadius={10}
|
||||
overflow="hidden"
|
||||
position="absolute"
|
||||
top={-16}
|
||||
right={0}
|
||||
flexDirection="row"
|
||||
shadowRadius={20}
|
||||
shadowOffset={{ width: 0, height: 4 }}
|
||||
shadowColor="rgba(9, 16, 28, 0.08)"
|
||||
zIndex={10}
|
||||
>
|
||||
<Button type="ghost" icon={<AddReaction />} borderRadius={0} />
|
||||
<Button type="ghost" icon={<Reply />} borderRadius={0} />
|
||||
<Button type="ghost" icon={<Options />} borderRadius={0} />
|
||||
</Stack>
|
||||
)
|
||||
}
|
|
@ -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<typeof Reactions> = {
|
||||
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<typeof Reactions>
|
||||
|
||||
// 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
|
|
@ -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 (
|
||||
<ReactButton selected={selected}>
|
||||
{cloneElement(icon, { color: '$neutral-100' })}
|
||||
<Paragraph weight="medium" variant="smaller" whiteSpace="nowrap">
|
||||
{count}
|
||||
</Paragraph>
|
||||
</ReactButton>
|
||||
)
|
||||
}
|
||||
|
||||
export const Reactions = (props: Props) => {
|
||||
const {} = props
|
||||
|
||||
return (
|
||||
<XStack space={8}>
|
||||
<ReactionButton count={1} icon={<Love />} selected />
|
||||
<ReactionButton count={10} icon={<ThumbsUp />} />
|
||||
<ReactionButton count={99} icon={<ThumbsDown />} />
|
||||
<ReactionButton count={100} icon={<Laugh />} />
|
||||
<ReactionButton count={100} icon={<Sad />} />
|
||||
{/* <ReactionButton count={100} icon={ang} /> */}
|
||||
<ReactionButton count={100} icon={<Angry />} />
|
||||
<ReactionButton icon={<AddReaction />} />
|
||||
</XStack>
|
||||
)
|
||||
}
|
|
@ -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<typeof Stack>
|
||||
|
||||
export const Messages = (props: BaseProps) => {
|
||||
export const Messages = () => {
|
||||
return (
|
||||
<Stack {...props}>
|
||||
<>
|
||||
<ChatMessage text="fsdjkf kasldjf ksdlfjksdlfj asdklfj sdkljf" />
|
||||
<ChatMessage text="fsdjkf kasldjf ksdlfjksdlfj asdklfj sdkljf" />
|
||||
<ChatMessage text="fsdjkf kasldjf ksdlfjksdlfj asdklfj sdkljf" />
|
||||
|
@ -21,12 +15,21 @@ export const Messages = (props: BaseProps) => {
|
|||
},
|
||||
]}
|
||||
/>
|
||||
<ChatMessage
|
||||
text="fsdjkf kasldjf ksdlfjksdlfj asdklfj sdkljf"
|
||||
reactions={['123']}
|
||||
/>
|
||||
<ChatMessage text="fsdjkf kasldjf ksdlfjksdlfj asdklfj sdkljf" />
|
||||
<ChatMessage text="fsdjkf kasldjf ksdlfjksdlfj asdklfj sdkljf" />
|
||||
<ChatMessage text="fsdjkf kasldjf ksdlfjksdlfj asdklfj sdkljf" />
|
||||
<ChatMessage text="fsdjkf kasldjf ksdlfjksdlfj asdklfj sdkljf" />
|
||||
<ChatMessage text="fsdjkf kasldjf ksdlfjksdlfj asdklfj sdkljf" />
|
||||
<ChatMessage text="fsdjkf kasldjf ksdlfjksdlfj asdklfj sdkljf" />
|
||||
</Stack>
|
||||
<ChatMessage
|
||||
text="fsdjkf kasldjf ksdlfjksdlfj asdklfj sdkljf"
|
||||
reactions={['123']}
|
||||
/>
|
||||
<ChatMessage
|
||||
text="fsdjkf kasldjf ksdlfjksdlfj asdklfj sdkljf"
|
||||
reactions={['123']}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
}
|
|
@ -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<typeof ChatMessage> = {
|
||||
// title: 'Messages',
|
||||
component: ChatMessage,
|
||||
argTypes: {},
|
||||
parameters: {
|
||||
|
@ -16,28 +17,40 @@ const meta: Meta<typeof ChatMessage> = {
|
|||
|
||||
type Story = StoryObj<typeof ChatMessage>
|
||||
|
||||
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
|
Loading…
Reference in New Issue