Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull window options selection styles up #3842

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 23 additions & 29 deletions src/components/WindowThumbnailSettings.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
import { Component } from 'react';
import { styled } from '@mui/material/styles';
import FormControlLabel from '@mui/material/FormControlLabel';
import ListSubheader from '@mui/material/ListSubheader';
import MenuItem from '@mui/material/MenuItem';
import ThumbnailsOffIcon from '@mui/icons-material/CropDinSharp';
import PropTypes from 'prop-types';
import ThumbnailNavigationBottomIcon from './icons/ThumbnailNavigationBottomIcon';
import ThumbnailNavigationRightIcon from './icons/ThumbnailNavigationRightIcon';

const ThumbnailOption = styled(MenuItem, { name: 'WindowThumbnailSettings', slot: 'option' })(({ selected, theme }) => ({
'& .MuiFormControlLabel-label': {
borderBottom: '2px solid transparent',
...(selected && {
borderBottomColor: theme.palette.secondary.main,
}),
},
backgroundColor: 'transparent !important',
color: selected ? theme.palette.secondary.main : undefined,
display: 'inline-block',
}));

/**
*
*/
Expand Down Expand Up @@ -41,60 +55,40 @@ export class WindowThumbnailSettings extends Component {
<>
<ListSubheader role="presentation" disableSticky tabIndex={-1}>{t('thumbnails')}</ListSubheader>

<MenuItem sx={{ display: 'inline-block' }} onClick={() => { this.handleChange('off'); handleClose(); }}>
<ThumbnailOption selected={thumbnailNavigationPosition === 'off'} onClick={() => { this.handleChange('off'); handleClose(); }}>
<FormControlLabel
value="off"
sx={{
'&.MuiFormControlLabel-label': {
borderBottom: '2px solid',
borderBottomColor: thumbnailNavigationPosition === 'off' ? 'secondary.main' : 'transparent',
color: thumbnailNavigationPosition === 'off' ? 'secondary.main' : undefined,
},
}}
control={
<ThumbnailsOffIcon color={thumbnailNavigationPosition === 'off' ? 'secondary' : undefined} />
<ThumbnailsOffIcon color={thumbnailNavigationPosition === 'off' ? 'secondary' : undefined} fill="currentcolor" />
}
label={t('off')}
labelPlacement="bottom"
/>
</MenuItem>
<MenuItem sx={{ display: 'inline-block' }} onClick={() => { this.handleChange('far-bottom'); handleClose(); }}>
</ThumbnailOption>
<ThumbnailOption selected={thumbnailNavigationPosition === 'far-bottom'} onClick={() => { this.handleChange('far-bottom'); handleClose(); }}>
<FormControlLabel
value="far-bottom"
sx={{
'&.MuiFormControlLabel-label': {
borderBottom: '2px solid',
borderBottomColor: thumbnailNavigationPosition === 'off' ? 'secondary.main' : 'transparent',
color: thumbnailNavigationPosition === 'off' ? 'secondary.main' : undefined,
},
}}
control={
<ThumbnailNavigationBottomIcon color={thumbnailNavigationPosition === 'far-bottom' ? 'secondary' : undefined} />
<ThumbnailNavigationBottomIcon color={thumbnailNavigationPosition === 'far-bottom' ? 'secondary' : undefined} fill="currentcolor" />
}
label={t('bottom')}
labelPlacement="bottom"
/>
</MenuItem>
<MenuItem sx={{ display: 'inline-block' }} onClick={() => { this.handleChange('far-right'); handleClose(); }}>
</ThumbnailOption>
<ThumbnailOption selected={thumbnailNavigationPosition === 'far-right'} onClick={() => { this.handleChange('far-right'); handleClose(); }}>
<FormControlLabel
value="far-right"
sx={{
'&.MuiFormControlLabel-label': {
borderBottom: '2px solid',
borderBottomColor: thumbnailNavigationPosition === 'off' ? 'secondary.main' : 'transparent',
color: thumbnailNavigationPosition === 'off' ? 'secondary.main' : undefined,
},
}}
control={(
<ThumbnailNavigationRightIcon
color={thumbnailNavigationPosition === 'far-right' ? 'secondary' : undefined}
fill="currentcolor"
style={direction === 'rtl' ? { transform: 'rotate(180deg)' } : {}}
/>
)}
label={t('right')}
labelPlacement="bottom"
/>
</MenuItem>
</ThumbnailOption>
</>
);
}
Expand Down
28 changes: 17 additions & 11 deletions src/components/WindowViewSettings.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Component } from 'react';
import { styled } from '@mui/material/styles';
import FormControlLabel from '@mui/material/FormControlLabel';
import MenuItem from '@mui/material/MenuItem';
import ListSubheader from '@mui/material/ListSubheader';
Expand All @@ -8,6 +9,18 @@ import PropTypes from 'prop-types';
import BookViewIcon from './icons/BookViewIcon';
import GalleryViewIcon from './icons/GalleryViewIcon';

const ViewOption = styled(MenuItem, { name: 'WindowViewSettings', slot: 'option' })(({ selected, theme }) => ({
'& .MuiFormControlLabel-label': {
borderBottom: '2px solid transparent',
...(selected && {
borderBottomColor: theme.palette.secondary.main,
}),
},
backgroundColor: 'transparent !important',
color: selected ? theme.palette.secondary.main : undefined,
display: 'inline-block',
}));

/**
*
*/
Expand Down Expand Up @@ -49,26 +62,19 @@ export class WindowViewSettings extends Component {
/** Suspiciously similar to a component, yet if it is invoked through JSX
none of the click handlers work? */
const menuItem = ({ value, Icon }) => (
<MenuItem
<ViewOption
selected={windowViewType === value}
key={value}
sx={{ display: 'inline-block' }}
autoFocus={windowViewType === value}
onClick={() => { this.handleChange(value); handleClose(); }}
>
<FormControlLabel
value={value}
sx={{
'&.MuiFormControlLabel-label': {
borderBottom: '2px solid',
borderBottomColor: windowViewType === value ? 'secondary.main' : 'transparent',
color: 'secondary.main',
},
}}
control={<Icon color={windowViewType === value ? 'secondary' : undefined} />}
control={<Icon fill="currentcolor" color={windowViewType === value ? 'secondary' : undefined} />}
label={t(value)}
labelPlacement="bottom"
/>
</MenuItem>
</ViewOption>
);

if (viewTypes.length === 0) return null;
Expand Down