Adjust missed styling for rtl direction

This commit is contained in:
schroda
2024-04-26 12:53:31 +02:00
parent 1626771e92
commit 741489ad49
5 changed files with 28 additions and 12 deletions

View File

@@ -29,12 +29,14 @@ import {
Ref, Ref,
} from 'react'; } from 'react';
import ChevronRightIcon from '@mui/icons-material/ChevronRight'; import ChevronRightIcon from '@mui/icons-material/ChevronRight';
import ChevronLeftIcon from '@mui/icons-material/ChevronLeft';
import Box from '@mui/material/Box'; import Box from '@mui/material/Box';
import { OverridableComponent } from '@mui/material/OverridableComponent'; import { OverridableComponent } from '@mui/material/OverridableComponent';
import { SvgIconTypeMap } from '@mui/material/SvgIcon'; import { SvgIconTypeMap } from '@mui/material/SvgIcon';
import { isMobile } from 'react-device-detect'; import { isMobile } from 'react-device-detect';
import { IconMenuItem } from '@/components/menu/IconMenuItem.tsx'; import { IconMenuItem } from '@/components/menu/IconMenuItem.tsx';
import { getOptionForDirection } from '@/theme.ts';
export type NestedMenuItemProps = Omit<MuiMenuItemProps, 'button'> & { export type NestedMenuItemProps = Omit<MuiMenuItemProps, 'button'> & {
parentMenuOpen: boolean; parentMenuOpen: boolean;
@@ -57,7 +59,7 @@ const NestedMenuItem = forwardRef<HTMLLIElement | null, NestedMenuItemProps>((pr
parentMenuOpen, parentMenuOpen,
label, label,
renderLabel, renderLabel,
RightIcon = ChevronRightIcon, RightIcon = getOptionForDirection(ChevronRightIcon, ChevronLeftIcon),
LeftIcon, LeftIcon,
children, children,
className, className,
@@ -191,11 +193,11 @@ const NestedMenuItem = forwardRef<HTMLLIElement | null, NestedMenuItemProps>((pr
style={{ pointerEvents: 'none' }} style={{ pointerEvents: 'none' }}
anchorEl={menuItemRef.current} anchorEl={menuItemRef.current}
anchorOrigin={{ anchorOrigin={{
horizontal: 'right', horizontal: getOptionForDirection('right', 'left'),
vertical: 'top', vertical: 'top',
}} }}
transformOrigin={{ transformOrigin={{
horizontal: 'left', horizontal: getOptionForDirection('left', 'right'),
vertical: 'top', vertical: 'top',
}} }}
open={open} open={open}

View File

@@ -26,11 +26,13 @@ import SettingsIcon from '@mui/icons-material/Settings';
import ArrowBack from '@mui/icons-material/ArrowBack'; import ArrowBack from '@mui/icons-material/ArrowBack';
import { useLocation } from 'react-router-dom'; import { useLocation } from 'react-router-dom';
import { createPortal } from 'react-dom'; import { createPortal } from 'react-dom';
import ArrowForwardIcon from '@mui/icons-material/ArrowForward';
import { NavbarItem } from '@/typings'; import { NavbarItem } from '@/typings';
import { NavBarContext } from '@/components/context/NavbarContext'; import { NavBarContext } from '@/components/context/NavbarContext';
import { DesktopSideBar } from '@/components/navbar/navigation/DesktopSideBar'; import { DesktopSideBar } from '@/components/navbar/navigation/DesktopSideBar';
import { MobileBottomBar } from '@/components/navbar/navigation/MobileBottomBar'; import { MobileBottomBar } from '@/components/navbar/navigation/MobileBottomBar';
import { useBackButton } from '@/util/useBackButton.ts'; import { useBackButton } from '@/util/useBackButton.ts';
import { getOptionForDirection } from '@/theme.ts';
const navbarItems: Array<NavbarItem> = [ const navbarItems: Array<NavbarItem> = [
{ {
@@ -107,7 +109,7 @@ export function DefaultNavBar() {
size="large" size="large"
onClick={handleBack} onClick={handleBack}
> >
<ArrowBack /> {getOptionForDirection(<ArrowBack />, <ArrowForwardIcon />)}
</IconButton> </IconButton>
)} )}
<Typography <Typography

View File

@@ -22,7 +22,7 @@ import Divider from '@mui/material/Divider';
import FormControl from '@mui/material/FormControl'; import FormControl from '@mui/material/FormControl';
import MenuItem from '@mui/material/MenuItem'; import MenuItem from '@mui/material/MenuItem';
import Tooltip from '@mui/material/Tooltip'; import Tooltip from '@mui/material/Tooltip';
import { styled, useTheme } from '@mui/material/styles'; import { styled } from '@mui/material/styles';
import ListItem from '@mui/material/ListItem'; import ListItem from '@mui/material/ListItem';
import ListItemText from '@mui/material/ListItemText'; import ListItemText from '@mui/material/ListItemText';
import Collapse from '@mui/material/Collapse'; import Collapse from '@mui/material/Collapse';
@@ -32,6 +32,7 @@ import { ReaderSettingsOptions } from '@/components/reader/ReaderSettingsOptions
import { useBackButton } from '@/util/useBackButton.ts'; import { useBackButton } from '@/util/useBackButton.ts';
import { useSetDefaultBackTo } from '@/components/context/NavbarContext.tsx'; import { useSetDefaultBackTo } from '@/components/context/NavbarContext.tsx';
import { Select } from '@/components/atoms/Select.tsx'; import { Select } from '@/components/atoms/Select.tsx';
import { getOptionForDirection } from '@/theme.ts';
const Root = styled('div')({ const Root = styled('div')({
zIndex: 10, zIndex: 10,
@@ -132,7 +133,6 @@ interface IProps {
export function ReaderNavBar(props: IProps) { export function ReaderNavBar(props: IProps) {
const { t } = useTranslation(); const { t } = useTranslation();
const theme = useTheme();
const navigate = useNavigate(); const navigate = useNavigate();
const location = useLocation<{ const location = useLocation<{
@@ -201,7 +201,14 @@ export function ReaderNavBar(props: IProps) {
return ( return (
<Root> <Root>
<Slide direction="right" in={drawerOpen} timeout={200} appear={false} mountOnEnter unmountOnExit> <Slide
direction={getOptionForDirection('right', 'left')}
in={drawerOpen}
timeout={200}
appear={false}
mountOnEnter
unmountOnExit
>
<NavContainer <NavContainer
sx={{ sx={{
position: 'fixed', position: 'fixed',
@@ -218,7 +225,7 @@ export function ReaderNavBar(props: IProps) {
onClick={() => updateDrawer(false)} onClick={() => updateDrawer(false)}
size="large" size="large"
> >
<KeyboardArrowLeftIcon /> {getOptionForDirection(<KeyboardArrowLeftIcon />, <KeyboardArrowRightIcon />)}
</IconButton> </IconButton>
</Tooltip> </Tooltip>
)} )}
@@ -310,7 +317,7 @@ export function ReaderNavBar(props: IProps) {
disabled={disableChapterNavButtons || chapter.sourceOrder <= 1} disabled={disableChapterNavButtons || chapter.sourceOrder <= 1}
onClick={() => openNextChapter(ChapterOffset.PREV)} onClick={() => openNextChapter(ChapterOffset.PREV)}
> >
{theme.direction === 'ltr' ? <KeyboardArrowLeftIcon /> : <KeyboardArrowRightIcon />} {getOptionForDirection(<KeyboardArrowLeftIcon />, <KeyboardArrowRightIcon />)}
</IconButton> </IconButton>
</Tooltip> </Tooltip>
<FormControl <FormControl
@@ -350,7 +357,7 @@ export function ReaderNavBar(props: IProps) {
} }
onClick={() => openNextChapter(ChapterOffset.NEXT)} onClick={() => openNextChapter(ChapterOffset.NEXT)}
> >
{theme.direction === 'ltr' ? <KeyboardArrowRightIcon /> : <KeyboardArrowLeftIcon />} {getOptionForDirection(<KeyboardArrowRightIcon />, <KeyboardArrowLeftIcon />)}
</IconButton> </IconButton>
</Tooltip> </Tooltip>
</ChapterNavigation> </ChapterNavigation>
@@ -368,7 +375,7 @@ export function ReaderNavBar(props: IProps) {
onClick={() => updateDrawer(true)} onClick={() => updateDrawer(true)}
size="large" size="large"
> >
<KeyboardArrowRightIcon /> {getOptionForDirection(<KeyboardArrowRightIcon />, <KeyboardArrowLeftIcon />)}
</OpenDrawerButton> </OpenDrawerButton>
</Tooltip> </Tooltip>
</Fade> </Fade>

View File

@@ -13,6 +13,7 @@ import Stack from '@mui/material/Stack';
import { useEffect, useMemo, useState } from 'react'; import { useEffect, useMemo, useState } from 'react';
import IconButton from '@mui/material/IconButton'; import IconButton from '@mui/material/IconButton';
import ArrowBack from '@mui/icons-material/ArrowBack'; import ArrowBack from '@mui/icons-material/ArrowBack';
import ArrowForwardIcon from '@mui/icons-material/ArrowForward';
import DialogContent from '@mui/material/DialogContent'; import DialogContent from '@mui/material/DialogContent';
import DialogTitle from '@mui/material/DialogTitle'; import DialogTitle from '@mui/material/DialogTitle';
import { requestManager } from '@/lib/requests/RequestManager.ts'; import { requestManager } from '@/lib/requests/RequestManager.ts';
@@ -23,6 +24,7 @@ import { SearchTextField } from '@/components/atoms/SearchTextField.tsx';
import { makeToast } from '@/components/util/Toast.tsx'; import { makeToast } from '@/components/util/Toast.tsx';
import { TrackerMangaCard } from '@/components/tracker/TrackerMangaCard.tsx'; import { TrackerMangaCard } from '@/components/tracker/TrackerMangaCard.tsx';
import { DIALOG_PADDING } from '@/components/tracker/constants.ts'; import { DIALOG_PADDING } from '@/components/tracker/constants.ts';
import { getOptionForDirection } from '@/theme.ts';
export const TrackerSearch = ({ export const TrackerSearch = ({
mangaId, mangaId,
@@ -87,7 +89,7 @@ export const TrackerSearch = ({
<DialogTitle sx={{ padding: DIALOG_PADDING }}> <DialogTitle sx={{ padding: DIALOG_PADDING }}>
<Stack direction="row" gap="10px" alignItems="center"> <Stack direction="row" gap="10px" alignItems="center">
<IconButton onClick={closeSearchMode}> <IconButton onClick={closeSearchMode}>
<ArrowBack /> {getOptionForDirection(<ArrowBack />, <ArrowForwardIcon />)}
</IconButton> </IconButton>
<SearchTextField <SearchTextField
sx={{ width: '100%' }} sx={{ width: '100%' }}

View File

@@ -67,3 +67,6 @@ export const createTheme = (dark?: boolean, direction: Direction = 'ltr') => {
return suwayomiTheme; return suwayomiTheme;
}; };
export const getOptionForDirection = <T>(ltrOption: T, rtlOption: T): T =>
(theme?.direction ?? 'ltr') === 'ltr' ? ltrOption : rtlOption;