From e05d92466374a0869731d5b495d6a3075f421997 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nuno=20G=C3=B3is?= Date: Tue, 13 Dec 2022 13:19:21 +0000 Subject: [PATCH] fix: misc UI/UX fixes, mostly related with favorites (#2683) https://linear.app/unleash/issue/2-504/misc-frontend-related-fixes-mostly-related-with-favorites --- .../component/admin/groups/Group/Group.tsx | 20 +-- .../FavoriteIconButton/FavoriteIconButton.tsx | 40 +++--- .../common/MainHeader/MainHeader.tsx | 2 +- .../VirtualizedTable.styles.ts | 5 + .../FavoriteIconCell/FavoriteIconCell.tsx | 11 +- .../feature/FeatureView/FeatureView.tsx | 3 +- .../project/Project/Project.styles.ts | 1 - .../src/component/project/Project/Project.tsx | 116 +++++++++--------- .../project/ProjectCard/ProjectCard.tsx | 2 +- 9 files changed, 91 insertions(+), 109 deletions(-) diff --git a/frontend/src/component/admin/groups/Group/Group.tsx b/frontend/src/component/admin/groups/Group/Group.tsx index 907990755ae..7fe13965f60 100644 --- a/frontend/src/component/admin/groups/Group/Group.tsx +++ b/frontend/src/component/admin/groups/Group/Group.tsx @@ -1,11 +1,5 @@ import { useEffect, useMemo, useState, VFC } from 'react'; -import { - IconButton, - styled, - Tooltip, - useMediaQuery, - useTheme, -} from '@mui/material'; +import { IconButton, Tooltip, useMediaQuery, useTheme } from '@mui/material'; import { useSearchParams, Link } from 'react-router-dom'; import { SortingRule, useFlexLayout, useSortBy, useTable } from 'react-table'; import { TablePlaceholder, VirtualizedTable } from 'component/common/Table'; @@ -41,14 +35,6 @@ import { UG_REMOVE_USER_BTN_ID, } from 'utils/testIds'; -const StyledEdit = styled(Edit)(({ theme }) => ({ - fontSize: theme.fontSizes.mainHeader, -})); - -const StyledDelete = styled(Delete)(({ theme }) => ({ - fontSize: theme.fontSizes.mainHeader, -})); - export const groupUsersPlaceholder: IGroupUser[] = Array(15).fill({ name: 'Name of the user', username: 'Username of the user', @@ -248,7 +234,7 @@ export const Group: VFC = () => { title: 'Edit group', }} > - + { title: 'Delete group', }} > - + } diff --git a/frontend/src/component/common/FavoriteIconButton/FavoriteIconButton.tsx b/frontend/src/component/common/FavoriteIconButton/FavoriteIconButton.tsx index 7697789a359..ba007312bbb 100644 --- a/frontend/src/component/common/FavoriteIconButton/FavoriteIconButton.tsx +++ b/frontend/src/component/common/FavoriteIconButton/FavoriteIconButton.tsx @@ -1,5 +1,5 @@ -import React, { VFC } from 'react'; -import { IconButton, SxProps, Theme } from '@mui/material'; +import { VFC } from 'react'; +import { IconButton, IconButtonProps } from '@mui/material'; import { ConditionallyRender } from '../ConditionallyRender/ConditionallyRender'; import { Star as StarIcon, @@ -7,30 +7,24 @@ import { } from '@mui/icons-material'; import { TooltipResolver } from '../TooltipResolver/TooltipResolver'; -interface IFavoriteIconButtonProps { - onClick: (event?: any) => void; +interface IFavoriteIconButtonProps extends IconButtonProps { isFavorite: boolean; size?: 'medium' | 'large'; - sx?: SxProps; } export const FavoriteIconButton: VFC = ({ - onClick, isFavorite, size = 'large', - sx, + ...props }) => { return ( - - + + = ({ : theme.spacing(3), }} /> - - } - elseShow={ - + } + elseShow={ @@ -52,9 +44,9 @@ export const FavoriteIconButton: VFC = ({ : theme.spacing(3), }} /> - - } - /> - + } + /> + + ); }; diff --git a/frontend/src/component/common/MainHeader/MainHeader.tsx b/frontend/src/component/common/MainHeader/MainHeader.tsx index 9c5464bfdb4..2b46d0237b9 100644 --- a/frontend/src/component/common/MainHeader/MainHeader.tsx +++ b/frontend/src/component/common/MainHeader/MainHeader.tsx @@ -13,7 +13,7 @@ const StyledMainHeader = styled(Paper)(({ theme }) => ({ const StyledTitleHeader = styled('div')(({ theme }) => ({ display: 'flex', - alignItems: 'flex-start', + alignItems: 'center', justifyContent: 'space-between', })); diff --git a/frontend/src/component/common/Table/VirtualizedTable/VirtualizedTable.styles.ts b/frontend/src/component/common/Table/VirtualizedTable/VirtualizedTable.styles.ts index d368e0efaad..c31f53a9103 100644 --- a/frontend/src/component/common/Table/VirtualizedTable/VirtualizedTable.styles.ts +++ b/frontend/src/component/common/Table/VirtualizedTable/VirtualizedTable.styles.ts @@ -4,6 +4,11 @@ export const useStyles = makeStyles()(() => ({ row: { position: 'absolute', width: '100%', + '&:hover': { + '.show-row-hover': { + display: 'inherit', + }, + }, }, cell: { alignItems: 'center', diff --git a/frontend/src/component/common/Table/cells/FavoriteIconCell/FavoriteIconCell.tsx b/frontend/src/component/common/Table/cells/FavoriteIconCell/FavoriteIconCell.tsx index 53653ad4550..5b8281f6348 100644 --- a/frontend/src/component/common/Table/cells/FavoriteIconCell/FavoriteIconCell.tsx +++ b/frontend/src/component/common/Table/cells/FavoriteIconCell/FavoriteIconCell.tsx @@ -5,7 +5,7 @@ import { StarBorder as StarBorderIcon, } from '@mui/icons-material'; import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; -import { TooltipResolver } from '../../../TooltipResolver/TooltipResolver'; +import { TooltipResolver } from 'component/common/TooltipResolver/TooltipResolver'; interface IFavoriteIconCellProps { value?: boolean; @@ -13,17 +13,15 @@ interface IFavoriteIconCellProps { } const InactiveIconButton = styled(IconButton)(({ theme }) => ({ - color: 'transparent', - '&:hover, &:focus': { - color: theme.palette.primary.main, - }, + color: theme.palette.primary.main, + display: 'none', })); export const FavoriteIconCell: VFC = ({ value = false, onClick, }) => ( - + = ({ elseShow={ { )} /> diff --git a/frontend/src/component/project/Project/Project.styles.ts b/frontend/src/component/project/Project/Project.styles.ts index ab223f91b4d..5132164be8e 100644 --- a/frontend/src/component/project/Project/Project.styles.ts +++ b/frontend/src/component/project/Project/Project.styles.ts @@ -48,7 +48,6 @@ export const useStyles = makeStyles()(theme => ({ width: '100%', fontSize: theme.fontSizes.mainHeader, fontWeight: 'bold', - marginBottom: '0.5rem', display: 'flex', justifyContent: 'space-between', alignItems: 'center', diff --git a/frontend/src/component/project/Project/Project.tsx b/frontend/src/component/project/Project/Project.tsx index 33f5e32f88c..58c6fd8e4f8 100644 --- a/frontend/src/component/project/Project/Project.tsx +++ b/frontend/src/component/project/Project/Project.tsx @@ -7,7 +7,7 @@ import { styled, Tab, Tabs } from '@mui/material'; import { Delete, Edit } from '@mui/icons-material'; import useToast from 'hooks/useToast'; import useQueryParams from 'hooks/useQueryParams'; -import React, { useEffect, useMemo, useState } from 'react'; +import { useEffect, useMemo, useState } from 'react'; import ProjectEnvironment from '../ProjectEnvironment/ProjectEnvironment'; import { ProjectFeaturesArchive } from './ProjectFeaturesArchive/ProjectFeaturesArchive'; import ProjectOverview from './ProjectOverview'; @@ -28,18 +28,18 @@ import { MainLayout } from 'component/layout/MainLayout/MainLayout'; import { ProjectChangeRequests } from '../../changeRequest/ProjectChangeRequests/ProjectChangeRequests'; import { ProjectSettings } from './ProjectSettings/ProjectSettings'; import { useChangeRequestsEnabled } from 'hooks/useChangeRequestsEnabled'; -import { FavoriteIconButton } from '../../common/FavoriteIconButton/FavoriteIconButton'; -import { useFavoriteProjectsApi } from '../../../hooks/api/actions/useFavoriteProjectsApi/useFavoriteProjectsApi'; +import { FavoriteIconButton } from 'component/common/FavoriteIconButton/FavoriteIconButton'; +import { useFavoriteProjectsApi } from 'hooks/api/actions/useFavoriteProjectsApi/useFavoriteProjectsApi'; const StyledDiv = styled('div')(() => ({ display: 'flex', })); -const Row = styled('div')(({ theme }) => ({ +const StyledTopRow = styled('div')(() => ({ display: 'flex', flexDirection: 'row', - justifyContent: 'center', - paddingBottom: theme.spacing(0.25), + justifyContent: 'space-between', + width: '100%', })); const Column = styled('div')(() => ({ @@ -47,11 +47,10 @@ const Column = styled('div')(() => ({ flexDirection: 'column', })); -const StyledName = styled('div')(({ theme }) => ({ +const StyledName = styled('div')(() => ({ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', - paddingTop: theme.spacing(1), })); const StyledTitle = styled('span')(({ theme }) => ({ @@ -62,6 +61,10 @@ const StyledText = styled(StyledTitle)(({ theme }) => ({ color: theme.palette.grey[800], })); +const StyledFavoriteIconButton = styled(FavoriteIconButton)(({ theme }) => ({ + marginLeft: theme.spacing(-1.5), +})); + const Project = () => { const projectId = useRequiredPathParam('projectId'); const params = useQueryParams(); @@ -158,21 +161,54 @@ const Project = () => { >
- - ( - - )} - /> -

- {projectName} -

-
+ + + ( + + )} + /> +

+ + {projectName} + +

+
+ + + navigate(`/projects/${projectId}/edit`) + } + tooltipProps={{ title: 'Edit project' }} + data-loading + > + + + { + setShowDelDialog(true); + }} + tooltipProps={{ title: 'Delete project' }} + data-loading + > + + + +

@@ -198,40 +234,6 @@ const Project = () => {
- - - navigate(`/projects/${projectId}/edit`) - } - tooltipProps={{ title: 'Edit project' }} - data-loading - > - - - { - setShowDelDialog(true); - }} - tooltipProps={{ title: 'Delete project' }} - data-loading - > - - -

diff --git a/frontend/src/component/project/ProjectCard/ProjectCard.tsx b/frontend/src/component/project/ProjectCard/ProjectCard.tsx index 9aa5ec690d3..defd9fcfaa3 100644 --- a/frontend/src/component/project/ProjectCard/ProjectCard.tsx +++ b/frontend/src/component/project/ProjectCard/ProjectCard.tsx @@ -56,7 +56,7 @@ export const ProjectCard = ({ const canDeleteProject = hasAccess(DELETE_PROJECT, id) && id !== DEFAULT_PROJECT_ID; - const onFavorite = async (e: Event) => { + const onFavorite = async (e: React.SyntheticEvent) => { e.preventDefault(); if (isFavorite) { await unfavorite(id);