Feature/merge source and extensions screen on desktop (#535)

* Merge "source" and "extension" screen for desktop

* Move "tab" related components into new folder

* Reuse "tab" components for "browse" screen

* Prevent extension list from being taller than 100% of the parents height

- remove margin - virtuoso has issues calculating the height otherwise
- change group title styling, fontSize caused issues

* Align "source" list group header with "extension"

* Remove bottom padding from "ExtensionCard"

* Move "GroupedVirtuoso" related components into folder

* Use "GroupedVirtuoso" for "extensions"

There was an issue with the height calculation of the virtuoso list, which apparently was caused by the conditional rendering of the group title and item as list items.
Due to this, while scrolling down, the virtuoso list caused an overflow, which rendered the scrollbar, which in turn caused the list items to shrink in width.
The end result of this was, that the list items "jumped" slightly on the initial render of the items, due to the scrollbar appearing and disappearing
This commit is contained in:
schroda
2024-01-02 23:32:49 +01:00
committed by GitHub
parent 9caca6e753
commit db65b9df44
15 changed files with 226 additions and 145 deletions

View File

@@ -0,0 +1,25 @@
/*
* 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 React from 'react';
interface IProps {
children: React.ReactNode;
index: any;
currentIndex: any;
}
export function TabPanel(props: IProps) {
const { children, index, currentIndex } = props;
return (
<div role="tabpanel" hidden={index !== currentIndex} id={`simple-tabpanel-${index}`}>
{currentIndex === index && children}
</div>
);
}

View File

@@ -0,0 +1,45 @@
/*
* 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, Tabs, TabsProps } from '@mui/material';
const StyledTabsMenu = styled(Tabs)(({ theme }) => ({
display: 'flex',
position: 'fixed',
top: '64px',
width: 'calc(100% - 64px)',
zIndex: 1,
backgroundColor: theme.palette.background.default,
border: 0,
borderBottomWidth: 2,
borderStyle: 'solid',
borderColor: theme.palette.divider,
[theme.breakpoints.down('sm')]: {
top: '56px', // header height
width: '100%',
},
}));
export const TabsMenu = ({ children, tabsCount, ...props }: TabsProps & { tabsCount: number }) => {
// Visual Hack: 160px is min-width for viewport width of >600
const scrollableTabs = window.innerWidth < tabsCount * 160;
return (
<StyledTabsMenu
{...props}
indicatorColor="primary"
textColor="primary"
centered={!scrollableTabs}
variant={scrollableTabs ? 'scrollable' : 'fullWidth'}
scrollButtons
allowScrollButtonsMobile
>
{children}
</StyledTabsMenu>
);
};

View File

@@ -0,0 +1,23 @@
/*
* 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 { Box, styled } from '@mui/material';
export const TabsWrapper = styled(Box)(({ theme }) => ({
// TabsMenu height + TabsMenu bottom padding - grid item top padding
marginTop: `calc(48px + 13px - 8px)`,
// header height - TabsMenu height - TabsMenu bottom padding + grid item top padding
minHeight: 'calc(100vh - 64px - 48px - 13px + 8px)',
position: 'relative',
[theme.breakpoints.down('sm')]: {
// TabsMenu - 8px margin diff header height (56px) + TabsMenu bottom padding - grid item top padding
marginTop: `calc(48px - 8px + 13px - 8px)`,
// header height (+ 8px margin) - footer height - TabsMenu height
minHeight: 'calc(100vh - 64px - 64px - 48px)',
},
}));