From 6651a4d1a88397c647f69099f9fb79539c953386 Mon Sep 17 00:00:00 2001 From: Anton Date: Fri, 4 Aug 2023 13:10:50 +0300 Subject: [PATCH] chore(ProjectListItemCollapsable): remove Goals button --- src/components/CollapsableItem.tsx | 45 ++++-- src/components/CommonHeader.tsx | 3 +- src/components/ProjectListItem.tsx | 1 + .../ProjectListItemCollapsable.i18n/en.json | 4 - .../ProjectListItemCollapsable.i18n/index.ts | 17 -- .../ProjectListItemCollapsable.i18n/ru.json | 4 - .../ProjectListItemCollapsable.tsx | 147 +++++++----------- src/components/ProjectListItemConnected.tsx | 16 +- .../ProjectPageLayout/ProjectPageLayout.tsx | 8 +- .../ProjectsPage/ProjectsPage.i18n/en.json | 3 +- .../ProjectsPage/ProjectsPage.i18n/ru.json | 3 +- src/components/ProjectsPage/ProjectsPage.tsx | 18 ++- 12 files changed, 118 insertions(+), 151 deletions(-) delete mode 100644 src/components/ProjectListItemCollapsable/ProjectListItemCollapsable.i18n/en.json delete mode 100644 src/components/ProjectListItemCollapsable/ProjectListItemCollapsable.i18n/index.ts delete mode 100644 src/components/ProjectListItemCollapsable/ProjectListItemCollapsable.i18n/ru.json diff --git a/src/components/CollapsableItem.tsx b/src/components/CollapsableItem.tsx index 356ac91d8..00a62f583 100644 --- a/src/components/CollapsableItem.tsx +++ b/src/components/CollapsableItem.tsx @@ -38,6 +38,7 @@ const StyledCollapsableHeader = styled.div` const StyledCollapsableItem = styled.div` position: relative; + padding-bottom: 1px; &:before { content: ''; @@ -56,7 +57,7 @@ const StyledHeaderContent = styled.div<{ highlighted?: boolean }>` `} `; -const StyledCollapsableContainer = styled.div<{ collapsed: boolean; deep: number }>` +const StyledCollapsableContainer = styled.div<{ collapsed: boolean; deep: number; hasChild: boolean }>` position: relative; border-radius: ${radiusM}; @@ -85,8 +86,9 @@ const StyledCollapsableContainer = styled.div<{ collapsed: boolean; deep: number padding-left: ${collapseOffset}px; `} - ${({ collapsed, deep }) => + ${({ collapsed, deep, hasChild }) => !collapsed && + hasChild && css` padding-left: ${collapseOffset}px; margin-left: ${deep === 0 ? -collapseOffset : 0}px; @@ -143,12 +145,20 @@ const StyledCollapsableContainer = styled.div<{ collapsed: boolean; deep: number margin-left: -${collapseOffset}px; } - > ${StyledCollapsableItem}:before { + /** show grey line for additional content section (for example goals list) if it's not last item. See design :) */ + // TODO: Remove this here https://github.com/taskany-inc/issues/issues/1448 + + > ${StyledCollapsableItem}:not(:last-child):before { display: block; } `} `; +export const CollapsableContentItem: FC<{ + children?: ReactNode; + className?: string; +}> = ({ children, className }) => {children}; + export const CollapsableItem: FC<{ children?: ReactNode; onClick?: () => void; @@ -156,16 +166,19 @@ export const CollapsableItem: FC<{ content: ReactNode; deep?: number; collapsed: boolean; -}> = ({ onClick, children, header, collapsed, deep = 0, content }) => ( - - - - - {header} - - {nullable(children, (ch) => ( - {ch} - ))} - {!collapsed ? content : null} - -); + hasChild: boolean; +}> = ({ onClick, children, header, collapsed, deep = 0, hasChild, content }) => { + return ( + + + + + {header} + + {nullable(children, (ch) => ( + {ch} + ))} + {!collapsed ? content : null} + + ); +}; diff --git a/src/components/CommonHeader.tsx b/src/components/CommonHeader.tsx index b351b750f..ff32e0a75 100644 --- a/src/components/CommonHeader.tsx +++ b/src/components/CommonHeader.tsx @@ -12,8 +12,7 @@ interface CommonHeaderProps { } const StyledCommonHeader = styled(PageContent)` - display: grid; - grid-template-columns: 8fr 4fr; + width: calc(2 / 3 * 100%); `; const StyledCommonHeaderInfo = styled.div<{ align: 'left' | 'right' }>` diff --git a/src/components/ProjectListItem.tsx b/src/components/ProjectListItem.tsx index 79dbbb8eb..1e1111033 100644 --- a/src/components/ProjectListItem.tsx +++ b/src/components/ProjectListItem.tsx @@ -19,6 +19,7 @@ interface ProjectListItemProps { className?: string; disabled?: boolean; averageScore: number | null; + onClick?: (e: React.MouseEvent) => void; } const StyledTitleCell = styled(TableCell)` diff --git a/src/components/ProjectListItemCollapsable/ProjectListItemCollapsable.i18n/en.json b/src/components/ProjectListItemCollapsable/ProjectListItemCollapsable.i18n/en.json deleted file mode 100644 index c44c8f6e9..000000000 --- a/src/components/ProjectListItemCollapsable/ProjectListItemCollapsable.i18n/en.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "Goals": "Goals", - "No goals": "No goals" -} diff --git a/src/components/ProjectListItemCollapsable/ProjectListItemCollapsable.i18n/index.ts b/src/components/ProjectListItemCollapsable/ProjectListItemCollapsable.i18n/index.ts deleted file mode 100644 index 5c148475b..000000000 --- a/src/components/ProjectListItemCollapsable/ProjectListItemCollapsable.i18n/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* eslint-disable */ -// Do not edit, use generator to update -import { i18n, fmt, I18nLangSet } from 'easy-typed-intl'; -import getLang from '../../../utils/getLang'; - -import ru from './ru.json'; -import en from './en.json'; - -export type I18nKey = keyof typeof ru & keyof typeof en; -type I18nLang = 'ru' | 'en'; - -const keyset: I18nLangSet = {}; - -keyset['ru'] = ru; -keyset['en'] = en; - -export const tr = i18n(keyset, fmt, getLang); diff --git a/src/components/ProjectListItemCollapsable/ProjectListItemCollapsable.i18n/ru.json b/src/components/ProjectListItemCollapsable/ProjectListItemCollapsable.i18n/ru.json deleted file mode 100644 index d68d41206..000000000 --- a/src/components/ProjectListItemCollapsable/ProjectListItemCollapsable.i18n/ru.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "Goals": "Цели", - "No goals": "Нет целей" -} diff --git a/src/components/ProjectListItemCollapsable/ProjectListItemCollapsable.tsx b/src/components/ProjectListItemCollapsable/ProjectListItemCollapsable.tsx index 4145cc54b..d90ec3881 100644 --- a/src/components/ProjectListItemCollapsable/ProjectListItemCollapsable.tsx +++ b/src/components/ProjectListItemCollapsable/ProjectListItemCollapsable.tsx @@ -1,68 +1,51 @@ -import React, { MouseEvent, ReactNode, useCallback, useMemo } from 'react'; -import NextLink from 'next/link'; +import React, { MouseEvent, ReactNode, useMemo } from 'react'; import styled from 'styled-components'; -import { Badge, Button, ExternalLinkIcon, Link, Text, nullable } from '@taskany/bricks'; -import { gapS, gray7, gray4, radiusM } from '@taskany/colors'; +import NextLink from 'next/link'; +import { gapXs, gray4, radiusM } from '@taskany/colors'; +import { Text, nullable } from '@taskany/bricks'; +import { IconServersOutline } from '@taskany/icons'; import { ProjectByIdReturnType } from '../../../trpc/inferredTypes'; import { GoalsListContainer } from '../GoalListItem'; -import { CollapsableItem, collapseOffset } from '../CollapsableItem'; +import { CollapsableItem, CollapsableContentItem, collapseOffset } from '../CollapsableItem'; import { ProjectListContainer, ProjectListItem } from '../ProjectListItem'; -import { tr } from './ProjectListItemCollapsable.i18n'; - -const StyledNoGoals = styled(Text)` - white-space: nowrap; -`; - -const StyledProjectListItemActionsContainer = styled.div` - display: flex; - align-items: center; -`; - -const StyledProjectListItemAction = styled.div<{ forceVisibility?: boolean }>` - visibility: ${({ forceVisibility }) => (forceVisibility ? 'visible' : 'hidden')}; - - margin-left: ${gapS}; - - &:first-child { - margin-left: 0; - } -`; - -const StyledProjectListItem = styled(ProjectListItem)` - &:hover { - ${StyledProjectListItemAction} { - visibility: visible; - } - } -`; - const StyledGoalsListContainer = styled(GoalsListContainer)` background-color: ${gray4}; border-radius: ${radiusM}; margin: 0px; padding: 0px; `; + +const StyledProjectIcons = styled.div` + display: flex; + align-items: center; + gap: ${gapXs}; +`; + interface ProjectListItemCollapsableProps { href?: string; project: NonNullable; goals?: ReactNode; children?: ReactNode; collapsed: boolean; - collapsedGoals: boolean; onClick?: () => void; - onGoalsClick?: () => void; loading?: boolean; deep?: number; } +const onProjectClickHandler = (e: MouseEvent) => { + if (!e.metaKey && !e.ctrlKey) { + e.preventDefault(); + } else { + e.stopPropagation(); + } +}; + export const ProjectListItemCollapsable: React.FC = ({ project, collapsed = true, - collapsedGoals = true, onClick, - onGoalsClick, children, goals, loading = false, @@ -71,69 +54,55 @@ export const ProjectListItemCollapsable: React.FC { const childs = useMemo(() => project.children.map(({ id }) => id), [project]); - const onClickEnabled = childs.length; - const contentHidden = !childs.length || collapsed || loading; + const contentHidden = collapsed || loading; const offset = collapseOffset * (deep > 0 && contentHidden ? deep - 1 : deep); - const onGoalsButtonClick = useCallback( - (e: MouseEvent) => { - e.stopPropagation(); - - onGoalsClick?.(); - }, - [onGoalsClick], + const projectComponent = ( + + {nullable(childs.length, (c) => ( + + + {c} + + ))} + ); - const onExternalLinkClick = useCallback((e: MouseEvent) => { - e.stopPropagation(); - }, []); - return ( - - - - {project._count.goals ? ( -