Skip to content

Commit

Permalink
refactor: props & styles
Browse files Browse the repository at this point in the history
  • Loading branch information
kKaskak committed Jul 25, 2024
1 parent 37be201 commit 52aa5ee
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 18 deletions.
6 changes: 3 additions & 3 deletions src/common/MultiselectMenu/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type Props = {
menuOpen: boolean | (() => void);
level: number;
setLevel: (level: number) => void;
onSelect: (event: any) => void;
onSelect: (value: number) => void;
};

const Dropdown = ({ level, setLevel, options, onSelect, selectedOption, menuOpen }: Props) => {
Expand All @@ -25,11 +25,11 @@ const Dropdown = ({ level, setLevel, options, onSelect, selectedOption, menuOpen
};

return (
<div className={classNames(styles['dropdown'], { [styles['open']]: menuOpen })} role='listbox'>
<div className={classNames(styles['dropdown'], { [styles['open']]: menuOpen })} role={'listbox'}>
{
level > 0 ?
<Button className={styles['back-button']} onClick={onBackButtonClick}>
<Icon name={'chevron-left'} className={styles['back-button-icon']} />
<Icon name={'caret-left'} className={styles['back-button-icon']} />
{t('BACK')}
</Button>
: null
Expand Down
1 change: 0 additions & 1 deletion src/common/MultiselectMenu/Dropdown/Option/Option.less
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

.icon {
flex: none;
// display: none;
width: 0.5rem;
height: 0.5rem;
border-radius: 100%;
Expand Down
4 changes: 2 additions & 2 deletions src/common/MultiselectMenu/Dropdown/Option/Option.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Icon from '@stremio/stremio-icons/react';
type Props = {
option: MultiselectMenuOption;
selectedOption?: MultiselectMenuOption | null;
onSelect: (value: string) => void;
onSelect: (value: number) => void;
};

const Option = ({ option, selectedOption, onSelect }: Props) => {
Expand All @@ -32,7 +32,7 @@ const Option = ({ option, selectedOption, onSelect }: Props) => {
}
{
option.level ?
<Icon name={'chevron-right'} className={styles['option-chevron']} />
<Icon name={'caret-right'} className={styles['option-caret']} />
: null
}
</Button>
Expand Down
12 changes: 8 additions & 4 deletions src/common/MultiselectMenu/MultiselectMenu.less
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@
@border-radius: 2.75rem;

.multiselect-menu {
background-color: var(--overlay-color);
position: relative;
min-width: 150px;
min-width: 8.5rem;
overflow: visible;
border-radius: @border-radius;

&.disabled {
pointer-events: none;
opacity: 0.3;
}

.multiselect-button {
color: var(--primary-foreground-color);
background-color: rgba(255, 255, 255, 0.05);
padding: 0.75rem 1.5rem;
display: flex;
justify-content: space-between;
Expand All @@ -24,12 +23,17 @@
border-radius: @border-radius;

.icon {
width: 1.5rem;
width: 1rem;
color: var(--primary-foreground-color);
opacity: 0.6;

&.open {
transform: rotate(180deg);
}
}
}

&:hover {
background-color: var(--overlay-color);
}
}
9 changes: 4 additions & 5 deletions src/common/MultiselectMenu/MultiselectMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,16 @@ type Props = {
title?: string;
options: MultiselectMenuOption[];
selectedOption?: MultiselectMenuOption;
onSelect: (event: any) => void;
onSelect: (value: number) => void;
};

const MultiselectMenu = ({ className, title, options, selectedOption, onSelect }: Props) => {
const [menuOpen, , closeMenu, toggleMenu] = useBinaryState(false);
const multiselectMenuRef = useOutsideClick(() => closeMenu());
const [level, setLevel] = React.useState<number>(0);

const onOptionSelect = (event: any) => {
console.log(event.value);
level ? setLevel(level + 1) : onSelect(event), closeMenu();
const onOptionSelect = (value: number) => {
level ? setLevel(level + 1) : onSelect(value), closeMenu();
};

return (
Expand All @@ -37,7 +36,7 @@ const MultiselectMenu = ({ className, title, options, selectedOption, onSelect }
aria-expanded={menuOpen}
>
{title}
<Icon name={'chevron-down'} className={classNames(styles['icon'], { [styles['open']]: menuOpen })} />
<Icon name={'caret-down'} className={classNames(styles['icon'], { [styles['open']]: menuOpen })} />
</Button>
{
menuOpen ?
Expand Down
2 changes: 1 addition & 1 deletion src/common/MultiselectMenu/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
type MultiselectMenuOption = {
id?: number;
label: string;
value: string;
value: number;
destination?: string;
default?: boolean;
hidden?: boolean;
Expand Down
3 changes: 1 addition & 2 deletions src/routes/MetaDetails/VideosList/SeasonsBar/SeasonsBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ const SeasonsBar = ({ className, seasons, season, onSelect }) => {
});
}
}, [season, seasons, onSelect]);
const seasonOnSelect = React.useCallback((event) => {
const value = parseFloat(event.value);
const seasonOnSelect = React.useCallback((value) => {
if (typeof onSelect === 'function') {
onSelect({
type: 'select',
Expand Down

0 comments on commit 52aa5ee

Please sign in to comment.