diff --git a/package-lock.json b/package-lock.json index 7677e91..ade361d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,6 +26,9 @@ "typescript": "^4.9.4", "web-vitals": "^2.1.4", "zustand": "^4.1.5" + }, + "devDependencies": { + "tailwindcss": "^3.2.4" } }, "node_modules/@adobe/css-tools": { diff --git a/package.json b/package.json index b812058..a5db5f5 100644 --- a/package.json +++ b/package.json @@ -45,5 +45,8 @@ "last 1 firefox version", "last 1 safari version" ] + }, + "devDependencies": { + "tailwindcss": "^3.2.4" } } diff --git a/src/App.tsx b/src/App.tsx index dbbb153..de334dd 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,4 +1,5 @@ import { ChatLayout } from './layout/ChatLayout'; +import './index.css'; function App() { return ; diff --git a/src/components/Timeline/ChatMessage/index.tsx b/src/components/Timeline/ChatMessage/index.tsx index 776d573..7d75e0c 100644 --- a/src/components/Timeline/ChatMessage/index.tsx +++ b/src/components/Timeline/ChatMessage/index.tsx @@ -1,30 +1,15 @@ -import { Box, Typography } from '@mui/material'; +import { Typography } from '@mui/material'; +import { Stack } from '../../../components/core/Stack'; +import { Box } from '../../../components/core/Box'; + import { Message } from '../../../api/types'; import moment from 'moment'; interface ChatMessageProps { message: Message; self: string; - isSmallScreen: boolean; } -const otherChartMessageSX = (isSmallScreen: boolean) => ({ - position: 'relative', - display: 'flex', - flexDirection: 'column', - borderRadius: '10px', - border: '1px solid #eaeaea', - minWidth: '200px', - maxWidth: isSmallScreen ? '240px' : '80%', - padding: '16px', - marginTop: '16px', - backgroundColor: '#fefefe', -}); - -const selfChartMessageSX = { - backgroundColor: '#fff59d', -}; - const labelSX = { color: '#aeaeae' }; const getStringOrNumberBack = (text: unknown) => { @@ -39,31 +24,24 @@ const getDateString = (timestamp: number) => { return moment(timestamp).format('DD MMM YYYY HH:mm'); }; -const ChatMessage = ({ message, self, isSmallScreen }: ChatMessageProps) => { +const ChatMessage = ({ message, self }: ChatMessageProps) => { const { author, message: _message, timestamp } = message; const isSelf = self === author; return ( - - + {!isSelf && ( {getStringOrNumberBack(author)} )} {getStringOrNumberBack(_message)} {getDateString(timestamp)} - + ); }; diff --git a/src/components/Timeline/index.tsx b/src/components/Timeline/index.tsx index c29bc52..11d74aa 100644 --- a/src/components/Timeline/index.tsx +++ b/src/components/Timeline/index.tsx @@ -6,20 +6,14 @@ import { useChatTimeline } from '../../hooks/useChatTimeline'; import { Error } from '../Error'; const Timeline = () => { - const { smallDevice, data, author, hasMore, next, hasError } = - useChatTimeline(); + const { data, author, hasMore, next, hasError } = useChatTimeline(); const renderChatMessages = useMemo( () => data.map((message: Message) => ( - + )), - [data, author, smallDevice] + [data, author] ); if (hasError) { diff --git a/src/components/core/Box/index.tsx b/src/components/core/Box/index.tsx new file mode 100644 index 0000000..1462a4c --- /dev/null +++ b/src/components/core/Box/index.tsx @@ -0,0 +1,9 @@ +const Box = ({ + children, + className, +}: { + children: any; + className?: string; +}) =>
{children}
; + +export { Box }; diff --git a/src/components/core/Stack/index.tsx b/src/components/core/Stack/index.tsx new file mode 100644 index 0000000..dbc801a --- /dev/null +++ b/src/components/core/Stack/index.tsx @@ -0,0 +1,12 @@ +const Stack = ({ + children, + className, +}: { + children: any; + className?: string; +}) => { + const style = `flex-col ${className || ''}`; + + return
{children}
; +}; +export { Stack }; diff --git a/src/index.css b/src/index.css index ec2585e..651ed53 100644 --- a/src/index.css +++ b/src/index.css @@ -1,3 +1,6 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', diff --git a/tailwind.config.js b/tailwind.config.js new file mode 100644 index 0000000..9b6645e --- /dev/null +++ b/tailwind.config.js @@ -0,0 +1,8 @@ +/** @type {import('tailwindcss').Config} */ +module.exports = { + content: ['./src/**/*.{js,jsx,ts,tsx}'], + theme: { + extend: {}, + }, + plugins: [], +};