mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Merge pull request #4783 from grafixeyehero/Add-AlphabetPicker-mui
This commit is contained in:
commit
e0b51753e3
2 changed files with 86 additions and 2 deletions
85
src/apps/experimental/components/library/AlphabetPicker.tsx
Normal file
85
src/apps/experimental/components/library/AlphabetPicker.tsx
Normal file
|
@ -0,0 +1,85 @@
|
|||
import React, { useCallback } from 'react';
|
||||
import classNames from 'classnames';
|
||||
|
||||
import Box from '@mui/material/Box';
|
||||
import ToggleButton from '@mui/material/ToggleButton';
|
||||
import ToggleButtonGroup from '@mui/material/ToggleButtonGroup';
|
||||
|
||||
import { LibraryViewSettings } from 'types/library';
|
||||
import 'components/alphaPicker/style.scss';
|
||||
|
||||
interface AlphabetPickerProps {
|
||||
className?: string;
|
||||
libraryViewSettings: LibraryViewSettings;
|
||||
setLibraryViewSettings: React.Dispatch<
|
||||
React.SetStateAction<LibraryViewSettings>
|
||||
>;
|
||||
}
|
||||
|
||||
const AlphabetPicker: React.FC<AlphabetPickerProps> = ({
|
||||
className,
|
||||
libraryViewSettings,
|
||||
setLibraryViewSettings
|
||||
}) => {
|
||||
const handleValue = useCallback(
|
||||
(
|
||||
event: React.MouseEvent<HTMLElement>,
|
||||
newValue: string | null | undefined
|
||||
) => {
|
||||
setLibraryViewSettings((prevState) => ({
|
||||
...prevState,
|
||||
StartIndex: 0,
|
||||
Alphabet: newValue
|
||||
}));
|
||||
},
|
||||
[setLibraryViewSettings]
|
||||
);
|
||||
|
||||
const containerClassName = classNames(
|
||||
'alphaPicker',
|
||||
className,
|
||||
'alphaPicker-fixed-right'
|
||||
);
|
||||
|
||||
const btnClassName = classNames(
|
||||
'paper-icon-button-light',
|
||||
'alphaPickerButton'
|
||||
);
|
||||
|
||||
const letters = ['#', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
|
||||
|
||||
return (
|
||||
<Box
|
||||
className={containerClassName}
|
||||
sx={{
|
||||
position: 'fixed',
|
||||
bottom: '1.5em',
|
||||
fontSize: {
|
||||
xs: '80%',
|
||||
lg: '88%'
|
||||
}
|
||||
}}
|
||||
>
|
||||
<ToggleButtonGroup
|
||||
orientation='vertical'
|
||||
value={libraryViewSettings.Alphabet}
|
||||
exclusive
|
||||
color='primary'
|
||||
size='small'
|
||||
onChange={handleValue}
|
||||
>
|
||||
{letters.map((l) => (
|
||||
<ToggleButton
|
||||
key={l}
|
||||
value={l}
|
||||
className={btnClassName}
|
||||
>
|
||||
{l}
|
||||
</ToggleButton>
|
||||
))}
|
||||
</ToggleButtonGroup>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default AlphabetPicker;
|
|
@ -62,6 +62,5 @@ export interface LibraryViewSettings {
|
|||
ShowTitle: boolean;
|
||||
ShowYear?: boolean;
|
||||
Filters?: Filters;
|
||||
NameLessThan?: string | null;
|
||||
NameStartsWith?: string | null;
|
||||
Alphabet?: string | null;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue