From 771d598c049a22727e77e4c4e7a3ccd43b0d910a Mon Sep 17 00:00:00 2001 From: Jordan Knott Date: Wed, 2 Sep 2020 20:25:28 -0500 Subject: [PATCH] feat: add task details --- frontend/package.json | 3 +- .../src/Projects/Project/Details/index.tsx | 3 +- frontend/src/Projects/Project/index.tsx | 12 +- .../src/shared/components/AddList/index.tsx | 2 +- .../src/shared/components/Button/index.tsx | 45 +- .../src/shared/components/Checklist/index.tsx | 2 +- frontend/src/shared/components/List/index.tsx | 2 +- .../src/shared/components/Lists/Styles.ts | 5 +- .../src/shared/components/Member/index.tsx | 4 +- .../src/shared/components/Modal/Styles.ts | 18 +- .../src/shared/components/Modal/index.tsx | 44 +- .../components/ProjectGridItem/index.tsx | 2 +- .../shared/components/TaskDetails/Styles.ts | 769 +++++++++++------- .../shared/components/TaskDetails/index.tsx | 613 +++++++------- .../components/TaskDetails/onDragEnd.ts | 90 ++ frontend/src/shared/generated/graphql.tsx | 21 + frontend/src/shared/graphql/findTask.graphqls | 11 + frontend/src/shared/hooks/useWindowSize.ts | 14 + frontend/src/shared/icons/At.tsx | 12 + frontend/src/shared/icons/Clone.tsx | 12 + frontend/src/shared/icons/Paperclip.tsx | 12 + frontend/src/shared/icons/Plus.tsx | 19 +- frontend/src/shared/icons/Share.tsx | 12 + frontend/src/shared/icons/Smile.tsx | 12 + frontend/src/shared/icons/Task.tsx | 12 + frontend/src/shared/icons/index.ts | 11 + frontend/src/shared/utils/editorTheme.ts | 86 ++ frontend/yarn.lock | 305 ++++++- 28 files changed, 1470 insertions(+), 683 deletions(-) create mode 100644 frontend/src/shared/components/TaskDetails/onDragEnd.ts create mode 100644 frontend/src/shared/hooks/useWindowSize.ts create mode 100644 frontend/src/shared/icons/At.tsx create mode 100644 frontend/src/shared/icons/Clone.tsx create mode 100644 frontend/src/shared/icons/Paperclip.tsx create mode 100644 frontend/src/shared/icons/Share.tsx create mode 100644 frontend/src/shared/icons/Smile.tsx create mode 100644 frontend/src/shared/icons/Task.tsx create mode 100644 frontend/src/shared/utils/editorTheme.ts diff --git a/frontend/package.json b/frontend/package.json index 3aa1f1d..6e05ebd 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -59,6 +59,7 @@ "react-router-dom": "^5.1.2", "react-scripts": "3.4.0", "react-select": "^3.1.0", + "rich-markdown-editor": "^10.6.5", "styled-components": "^5.0.1", "typescript": "~3.7.2" }, @@ -95,10 +96,10 @@ "@graphql-codegen/typescript-operations": "^1.13.2", "@graphql-codegen/typescript-react-apollo": "^1.13.2", "@storybook/addon-actions": "^5.3.13", - "@storybook/addon-links": "^5.3.13", "@storybook/addon-backgrounds": "^5.3.17", "@storybook/addon-docs": "^5.3.17", "@storybook/addon-knobs": "^5.3.17", + "@storybook/addon-links": "^5.3.13", "@storybook/addon-storysource": "^5.3.17", "@storybook/addon-viewport": "^5.3.17", "@storybook/addons": "^5.3.13", diff --git a/frontend/src/Projects/Project/Details/index.tsx b/frontend/src/Projects/Project/Details/index.tsx index b5669ac..2da521b 100644 --- a/frontend/src/Projects/Project/Details/index.tsx +++ b/frontend/src/Projects/Project/Details/index.tsx @@ -298,13 +298,14 @@ const Details: React.FC = ({ return ( <> { history.push(projectURL); }} renderContent={() => { return ( { updateTaskChecklistLocation({ diff --git a/frontend/src/Projects/Project/index.tsx b/frontend/src/Projects/Project/index.tsx index b79cddf..5ca804f 100644 --- a/frontend/src/Projects/Project/index.tsx +++ b/frontend/src/Projects/Project/index.tsx @@ -270,7 +270,17 @@ const Project = () => { updateTaskName({ variables: { taskID: updatedTask.id, name: newName } }); }} onTaskDescriptionChange={(updatedTask, newDescription) => { - updateTaskDescription({ variables: { taskID: updatedTask.id, description: newDescription } }); + updateTaskDescription({ + variables: { taskID: updatedTask.id, description: newDescription }, + optimisticResponse: { + __typename: 'Mutation', + updateTaskDescription: { + __typename: 'Task', + id: updatedTask.id, + description: newDescription, + }, + }, + }); }} onDeleteTask={deletedTask => { deleteTask({ variables: { taskID: deletedTask.id } }); diff --git a/frontend/src/shared/components/AddList/index.tsx b/frontend/src/shared/components/AddList/index.tsx index 0c822b2..7d1a4a0 100644 --- a/frontend/src/shared/components/AddList/index.tsx +++ b/frontend/src/shared/components/AddList/index.tsx @@ -98,7 +98,7 @@ const AddList: React.FC = ({ onSave }) => { ) : ( - + Add another list diff --git a/frontend/src/shared/components/Button/index.tsx b/frontend/src/shared/components/Button/index.tsx index 27b96a8..b977123 100644 --- a/frontend/src/shared/components/Button/index.tsx +++ b/frontend/src/shared/components/Button/index.tsx @@ -1,7 +1,7 @@ import React, { useRef } from 'react'; import styled, { css } from 'styled-components/macro'; -const Text = styled.span<{ fontSize: string; justifyTextContent: string }>` +const Text = styled.span<{ fontSize: string; justifyTextContent: string; hasIcon?: boolean }>` position: relative; display: flex; align-items: center; @@ -9,6 +9,11 @@ const Text = styled.span<{ fontSize: string; justifyTextContent: string }>` transition: all 0.2s ease; font-size: ${props => props.fontSize}; color: rgba(${props => props.theme.colors.text.secondary}); + ${props => + props.hasIcon && + css` + padding-left: 4px; + `} `; const Base = styled.button<{ color: string; disabled: boolean }>` @@ -18,6 +23,8 @@ const Base = styled.button<{ color: string; disabled: boolean }>` cursor: pointer; padding: 0.75rem 2rem; border-radius: ${props => props.theme.borderRadius.alternate}; + display: flex; + align-items: center; ${props => props.disabled && @@ -34,16 +41,28 @@ const Filled = styled(Base)` box-shadow: 0 8px 25px -8px rgba(${props => props.theme.colors[props.color]}); } `; -const Outline = styled(Base)` +const Outline = styled(Base)<{ invert: boolean }>` border: 1px solid rgba(${props => props.theme.colors[props.color]}); background: transparent; - & ${Text} { - color: rgba(${props => props.theme.colors[props.color]}); - } - - &:hover { - background: rgba(${props => props.theme.colors[props.color]}, 0.08); - } + ${props => + props.invert + ? css` + background: rgba(${props.theme.colors[props.color]}); + & ${Text} { + color: rgba(${props.theme.colors.text.secondary}); + } + &:hover { + background: rgba(${props.theme.colors[props.color]}, 0.8); + } + ` + : css` + & ${Text} { + color: rgba(${props.theme.colors[props.color]}); + } + &:hover { + background: rgba(${props.theme.colors[props.color]}, 0.08); + } + `} `; const Flat = styled(Base)` @@ -110,6 +129,8 @@ type ButtonProps = { color?: 'primary' | 'danger' | 'success' | 'warning' | 'dark'; disabled?: boolean; type?: 'button' | 'submit'; + icon?: JSX.Element; + invert?: boolean; className?: string; onClick?: ($target: React.RefObject) => void; justifyTextContent?: string; @@ -118,10 +139,12 @@ type ButtonProps = { const Button: React.FC = ({ disabled = false, fontSize = '14px', + invert = false, color = 'primary', variant = 'filled', type = 'button', justifyTextContent = 'center', + icon, onClick, className, children, @@ -136,7 +159,8 @@ const Button: React.FC = ({ case 'filled': return ( - + {icon && icon} + {children} @@ -145,6 +169,7 @@ const Button: React.FC = ({ return (