From 99ac5f8846eb15ec282a76a5c45ede7f8148e8ab Mon Sep 17 00:00:00 2001 From: Tony Vi Date: Thu, 12 Jan 2023 20:51:06 +0300 Subject: [PATCH] feat: global create button --- i18n/en.json | 8 ++- i18n/ru.json | 11 +-- src/components/Dropdown.tsx | 2 +- src/components/Header.tsx | 69 ++++++++++++++++++- src/components/HeaderMenu.tsx | 104 +---------------------------- src/pages/goals/[id].tsx | 10 --- src/pages/goals/index.tsx | 11 +-- src/pages/projects/[key]/index.tsx | 10 +-- src/pages/teams/[slug]/goals.tsx | 11 +-- src/pages/users/settings.tsx | 13 ++++ 10 files changed, 101 insertions(+), 148 deletions(-) diff --git a/i18n/en.json b/i18n/en.json index 033dbf8dc..5543d5cc0 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -116,6 +116,8 @@ "Name": "Name", "Nickname": "Nickname", "Appearance": "Appearance", + "Danger zone": "Danger zone", + "Sign out": "Sign out", "User name is required": "User name is required", "User name must be a string": "User name must be a string", "User name must be longer than 3 symbols": "User name must be longer than 3 symbol", @@ -252,7 +254,11 @@ "Goals": "Goals", "Issues": "Issues", "Explore": "Explore", - "Boards": "Boards" + "Boards": "Boards", + "Create": "Create", + "Create goal": "Goal", + "Create project": "Project", + "Create team": "Team" }, "HeaderMenu": { "New goal": "New goal", diff --git a/i18n/ru.json b/i18n/ru.json index 0ff7017a5..f8da63206 100644 --- a/i18n/ru.json +++ b/i18n/ru.json @@ -116,6 +116,8 @@ "Name": "Имя", "Nickname": "Логин", "Appearance": "Интерфейс", + "Danger zone": "Опасная зона", + "Sign out": "Выйти", "User name is required": "Указание имени обязательно", "User name must be a string": "Имя должно быть строкой", "User name must be longer than 3 symbols": "Имя не может быть короче 3х символов", @@ -252,12 +254,13 @@ "Goals": "Цели", "Issues": "Задачи", "Explore": "Обзор", - "Boards": "Доски" + "Boards": "Доски", + "Create": "Создать", + "Create goal": "Цель", + "Create project": "Проект", + "Create team": "Команду" }, "HeaderMenu": { - "New goal": "Новая цель", - "New project": "Новый проект", - "Invite users": "Пригласить", "Sign out": "Выйти" }, "TagCompletion": { diff --git a/src/components/Dropdown.tsx b/src/components/Dropdown.tsx index 6ed0a1e4b..4ed346aa0 100644 --- a/src/components/Dropdown.tsx +++ b/src/components/Dropdown.tsx @@ -151,7 +151,7 @@ const Dropdown = React.forwardRef( reference={popupRef} interactive arrow={false} - minWidth={150} + minWidth={100} maxWidth={250} offset={[-4, 8]} > diff --git a/src/components/Header.tsx b/src/components/Header.tsx index 44c55f333..7bf037ac9 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -1,17 +1,24 @@ +import { useCallback } from 'react'; import NextLink from 'next/link'; import styled from 'styled-components'; import { useTranslations } from 'next-intl'; +import dynamic from 'next/dynamic'; import { routes } from '../hooks/router'; import { textColor, gray7, colorPrimary, gray3 } from '../design/@generated/themes'; +import { dispatchModalEvent, ModalEvent } from '../utils/dispatchModal'; import { HeaderLogo } from './HeaderLogo'; import { HeaderMenu } from './HeaderMenu'; import { Icon } from './Icon'; +import { Button } from './Button'; +import { MenuItem } from './MenuItem'; + +const Dropdown = dynamic(() => import('./Dropdown')); const StyledHeader = styled.header` display: grid; - grid-template-columns: 20px 11fr 100px; + grid-template-columns: 20px 10fr 150px 55px; align-items: center; padding: 20px 40px; @@ -59,9 +66,18 @@ const StyledHeaderNavLink = styled.a<{ disabled?: boolean }>` } `; +const StyledCreateButton = styled.div` + display: flex; + align-items: center; +`; + export const Header: React.FC = () => { const t = useTranslations('Header'); + const onMenuItemClick = useCallback(({ event }: { event: ModalEvent }) => { + dispatchModalEvent(event)(); + }, []); + return ( @@ -81,7 +97,56 @@ export const Header: React.FC = () => { - + +