diff --git a/client/src/components/ui/Comment/index.tsx b/client/src/components/ui/Comment/index.tsx index a95268e1eef56f33a3c97f7680403ec1c13641d5..372e7bfe53f6995b3da039a012dcaf169214b8a4 100644 --- a/client/src/components/ui/Comment/index.tsx +++ b/client/src/components/ui/Comment/index.tsx @@ -6,6 +6,7 @@ import { getUser, User } from 'adapters/user'; import { Comment as IComment } from 'adapters/comment'; import Avatar from 'components/ui/Avatar'; +import LongText from 'components/ui/LongText'; import './comment.scss'; @@ -39,7 +40,7 @@ export default function Comment({ comment }: CommentProps) { </div> </div> <div className="comment"> - {comment.text} + <LongText text={comment.text} /> </div> </div> ) diff --git a/client/src/components/ui/LongText/index.tsx b/client/src/components/ui/LongText/index.tsx new file mode 100644 index 0000000000000000000000000000000000000000..6c2892e36c605c3a29df5615e7dade60bc58efc2 --- /dev/null +++ b/client/src/components/ui/LongText/index.tsx @@ -0,0 +1,26 @@ + +import { useState } from 'react'; + +interface Props { + text: string; +} + +export default function LongText({ text }: Props) { + const [more, setMore] = useState(false); + + return ( + (text.length < 300) + ? <p>{text}</p> + : (more + ? <> + <p>{text}</p> + <button onClick={() => setMore(false)}>less</button> + </> + : <> + <p>{text.substr(0, 300) + '... '}</p> + <button onClick={() => setMore(true)}>more</button> + </> + ) + ); +} + diff --git a/client/src/index.scss b/client/src/index.scss index 1459a6f1cabbca1aaf24593ddac71cdcabddd663..a4d10203fa061701ec27899a95642315b04d07ec 100644 --- a/client/src/index.scss +++ b/client/src/index.scss @@ -33,6 +33,7 @@ button { } a, button { + font-size: 1em; font-weight: s.$weight-semi-bold; color: s.$primary; text-decoration: none; diff --git a/client/src/pages/Projects/ProjectDetail/index.tsx b/client/src/pages/Projects/ProjectDetail/index.tsx index 64faeee18dc09d1845d53bbcd66053e537ff00cf..8b7fe79e3fc930bebd1c7345dae1795df22a243d 100644 --- a/client/src/pages/Projects/ProjectDetail/index.tsx +++ b/client/src/pages/Projects/ProjectDetail/index.tsx @@ -6,6 +6,7 @@ import { StatusColors } from 'adapters/common'; import { getProject, Project } from 'adapters/project'; import Tag from 'components/ui/Tag'; +import LongText from 'components/ui/LongText'; import Tabs, { Tab } from 'components/navigation/Tabs'; import LoadingScreen from 'components/ui/LoadingScreen'; @@ -55,9 +56,7 @@ export default function ProjectDetail() { <Tag label={project.status} color={StatusColors.get(project.status)} /> <h1>{project.name}</h1> <div className="description-container"> - <p> - {project.text} - </p> + <LongText text={project.text} /> </div> { tabs diff --git a/client/src/pages/Tasks/TaskDetail/index.tsx b/client/src/pages/Tasks/TaskDetail/index.tsx index 3f157be5bd9e8ed7817b7b1bb5e54f6e8fbd7cca..02989a0d57c4d570dcb01630a183989abdbe35ba 100644 --- a/client/src/pages/Tasks/TaskDetail/index.tsx +++ b/client/src/pages/Tasks/TaskDetail/index.tsx @@ -9,6 +9,7 @@ import { getProject, Project } from 'adapters/project'; import { getTask, getTaskAssignees, Task, TaskAssignment } from 'adapters/task'; import Tag from 'components/ui/Tag'; +import LongText from 'components/ui/LongText'; import Tabs from 'components/navigation/Tabs'; import DetailGrid from 'components/layout/DetailGrid'; import LoadingScreen from 'components/ui/LoadingScreen'; @@ -25,7 +26,6 @@ export interface Params { } export default function TaskDetail() { - const [more, setMore] = useState(false); const [task, setTask] = useState<Task>(); const [project, setProject] = useState<Project>(); const [teamNames, setTeamNames] = useState<string[]>([]); @@ -49,7 +49,7 @@ export default function TaskDetail() { getTaskAssignees(taskId).then(setAssignees); setAssignment(task.assigned.find(a => a.user === userId)) }).catch(() => history.goBack()); - }, [taskId, history]); + }, [taskId, userId, history]); if (task) { return ( @@ -61,20 +61,7 @@ export default function TaskDetail() { <Tag label={task.status} color={StatusColors.get(task.status)} /> <h1>{task.name}</h1> <div className="description-container"> - { - (task.text.length < 300) - ? <p>{task.text}</p> - : (more - ? <> - <p>{task.text}</p> - <a onClick={() => setMore(false)}>less</a> - </> - : <> - <p>{task.text.substr(0, 300) + '... '}</p> - <a onClick={() => setMore(true)}>more</a> - </> - ) - } + <LongText text={task.text} /> </div> <h2> Details