From fa1169337f98a924f10e955c6b6cc712dd45ff7d Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Fri, 29 Mar 2024 16:54:53 +0100 Subject: [PATCH] Fix/manga track binding card styling (#680) * Fix missing box shadow of active tracker card Due to missing side paddings the box shadow wasn't visible * Extract tracker card styling * Prevent breaking title when selecting manga * Limit max lines of titles --- src/components/MangaCard.tsx | 11 ++------- src/components/atoms/TypographyMaxLines.tsx | 24 +++++++++++++++++++ src/components/tracker/TrackManga.tsx | 9 ++++++- src/components/tracker/TrackerActiveCard.tsx | 17 +++++++++---- src/components/tracker/TrackerMangaCard.tsx | 12 ++++++---- src/components/tracker/TrackerSearch.tsx | 7 +++--- .../tracker/TrackerUntrackedCard.tsx | 3 ++- src/components/tracker/constants.ts | 22 +++++++++++++++++ 8 files changed, 82 insertions(+), 23 deletions(-) create mode 100644 src/components/atoms/TypographyMaxLines.tsx create mode 100644 src/components/tracker/constants.ts diff --git a/src/components/MangaCard.tsx b/src/components/MangaCard.tsx index 8620fdda..b93004a0 100644 --- a/src/components/MangaCard.tsx +++ b/src/components/MangaCard.tsx @@ -24,6 +24,7 @@ import { MangaActionMenuItems, SingleModeProps } from '@/components/manga/MangaA import { Menu } from '@/components/menu/Menu.tsx'; import { MigrateDialog } from '@/components/MigrateDialog.tsx'; import { Mangas } from '@/lib/data/Mangas.ts'; +import { TypographyMaxLines } from '@/components/atoms/TypographyMaxLines.tsx'; const BottomGradient = styled('div')({ position: 'absolute', @@ -41,15 +42,7 @@ const BottomGradientDoubledDown = styled('div')({ background: 'linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,1) 100%)', }); -const MangaTitle = styled(Typography)({ - lineHeight: '1.5rem', - maxHeight: '3rem', - display: '-webkit-box', - WebkitLineClamp: '2', - WebkitBoxOrient: 'vertical', - overflow: 'hidden', - textOverflow: 'ellipsis', -}); +const MangaTitle = TypographyMaxLines; const GridMangaTitle = styled(MangaTitle)({ fontSize: '1.05rem', diff --git a/src/components/atoms/TypographyMaxLines.tsx b/src/components/atoms/TypographyMaxLines.tsx new file mode 100644 index 00000000..9f474df7 --- /dev/null +++ b/src/components/atoms/TypographyMaxLines.tsx @@ -0,0 +1,24 @@ +/* + * Copyright (C) Contributors to the Suwayomi project + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ + +import styled from '@emotion/styled'; +import { Typography, TypographyProps } from '@mui/material'; + +export const TypographyMaxLines = styled(Typography, { + shouldForwardProp: (prop) => prop !== 'lines', +})<{ + lines?: number; +}>(({ lines = 2 }) => ({ + lineHeight: '1.5rem', + maxHeight: '3rem', + display: '-webkit-box', + WebkitLineClamp: `${lines}`, + WebkitBoxOrient: 'vertical', + overflow: 'hidden', + textOverflow: 'ellipsis', +})) as React.FC; diff --git a/src/components/tracker/TrackManga.tsx b/src/components/tracker/TrackManga.tsx index 45bd9482..33f1c194 100644 --- a/src/components/tracker/TrackManga.tsx +++ b/src/components/tracker/TrackManga.tsx @@ -83,7 +83,14 @@ export const TrackManga = ({ manga }: { manga: Pick + {trackerComponents} ); diff --git a/src/components/tracker/TrackerActiveCard.tsx b/src/components/tracker/TrackerActiveCard.tsx index c82bbe25..0e212d80 100644 --- a/src/components/tracker/TrackerActiveCard.tsx +++ b/src/components/tracker/TrackerActiveCard.tsx @@ -23,6 +23,7 @@ import { ListItemButton, MenuItem, Stack, + Tooltip, Typography, } from '@mui/material'; import MoreVertIcon from '@mui/icons-material/MoreVert'; @@ -34,6 +35,8 @@ import { NumberSetting } from '@/components/settings/NumberSetting.tsx'; import { DateSetting } from '@/components/settings/DateSetting.tsx'; import { makeToast } from '@/components/util/Toast.tsx'; import { Menu } from '@/components/menu/Menu'; +import { CARD_STYLING } from '@/components/tracker/constants.ts'; +import { TypographyMaxLines } from '@/components/atoms/TypographyMaxLines.tsx'; const TrackerActiveLink = ({ children, url }: { children: React.ReactNode; url: string }) => ( @@ -150,7 +153,11 @@ const TrackerActiveHeader = ({ - {trackRecord.title} + + + {trackRecord.title} + + @@ -207,12 +214,12 @@ export const TrackerActiveCard = ({ }; return ( - - + + - - + + ( - - {title} - - {selected && } + + + {title} + + + ); diff --git a/src/components/tracker/TrackerSearch.tsx b/src/components/tracker/TrackerSearch.tsx index d47851d2..5e256a26 100644 --- a/src/components/tracker/TrackerSearch.tsx +++ b/src/components/tracker/TrackerSearch.tsx @@ -21,6 +21,7 @@ import { TBaseTracker } from '@/lib/data/Trackers.ts'; import { SearchTextField } from '@/components/atoms/SearchTextField.tsx'; import { makeToast } from '@/components/util/Toast.tsx'; import { TrackerMangaCard } from '@/components/tracker/TrackerMangaCard.tsx'; +import { DIALOG_PADDING } from '@/components/tracker/constants.ts'; export const TrackerSearch = ({ mangaId, @@ -82,7 +83,7 @@ export const TrackerSearch = ({ return ( <> - + @@ -101,7 +102,7 @@ export const TrackerSearch = ({ /> - + {!trackerSearch.loading && !trackerSearch.error && !hasResults && ( )} @@ -132,7 +133,7 @@ export const TrackerSearch = ({ left: 0, right: 0, bottom: 0, - paddingBottom: '15px', + paddingBottom: DIALOG_PADDING, }} >