From 72cbd3718206ceb15c0c2b68e53039ff2fc466db Mon Sep 17 00:00:00 2001 From: grafixeyehero Date: Thu, 15 Dec 2022 22:54:58 +0300 Subject: [PATCH] apply suggestion --- src/elements/emby-button/Button.tsx | 25 +++++++++++++------ src/elements/emby-button/IconButton.tsx | 18 ++++++++----- src/elements/emby-button/LinkButton.tsx | 9 ++++--- .../emby-scrollbuttons/ScrollButtons.tsx | 4 +-- src/elements/emby-scroller/Scroller.tsx | 8 +++--- 5 files changed, 41 insertions(+), 23 deletions(-) diff --git a/src/elements/emby-button/Button.tsx b/src/elements/emby-button/Button.tsx index ba3e7b9d11..8f742c41bb 100644 --- a/src/elements/emby-button/Button.tsx +++ b/src/elements/emby-button/Button.tsx @@ -3,6 +3,11 @@ import classNames from 'classnames'; import layoutManager from '../../components/layoutManager'; import './emby-button.scss'; +enum IconPosition { + RIGHT = 'RIGHT', + LEFT = 'LEFT', + } + interface ButtonProps extends DetailedHTMLProps, HTMLButtonElement > { @@ -20,21 +25,27 @@ const Button: React.FC = ({ onClick, ...rest }) => { - let cssClass = classNames('emby-button', className); + const btnClass = classNames( + 'emby-button', + className, + { 'show-focus': layoutManager.tv } + ); - if (layoutManager.tv) { - cssClass += ' show-focus'; - } + const iconClass = classNames( + 'material-icons', + iconClassName, + icon + ); return ( ); }; diff --git a/src/elements/emby-button/IconButton.tsx b/src/elements/emby-button/IconButton.tsx index e908a81920..3f4f66e198 100644 --- a/src/elements/emby-button/IconButton.tsx +++ b/src/elements/emby-button/IconButton.tsx @@ -19,21 +19,27 @@ const IconButton: React.FC = ({ onClick, ...rest }) => { - let cssClass = classNames('paper-icon-button-light', className); + const btnClass = classNames( + 'paper-icon-button-light', + className, + { 'show-focus': layoutManager.tv } + ); - if (layoutManager.tv) { - cssClass += ' show-focus'; - } + const iconClass = classNames( + 'material-icons', + iconClassName, + icon + ); return ( ); }; diff --git a/src/elements/emby-button/LinkButton.tsx b/src/elements/emby-button/LinkButton.tsx index fdf88cca29..2a175bd177 100644 --- a/src/elements/emby-button/LinkButton.tsx +++ b/src/elements/emby-button/LinkButton.tsx @@ -43,11 +43,12 @@ const LinkButton: React.FC = ({ if (isAutoHideEnabled === true && !appHost.supports('externallinks')) { return null; } - let cssClass = classNames('emby-button', className); - if (layoutManager.tv) { - cssClass += ' show-focus'; - } + const cssClass = classNames( + 'emby-button', + className, + { 'show-focus': layoutManager.tv } + ); return ( = ({ scrollerFactoryRef, scrollState }) => { - const [localeScrollPos, SetLocaleScrollPos] = useState(0); + const [localeScrollPos, setLocaleScrollPos] = useState(0); const scrollButtonsRef = useRef(null); const scrollToPosition = useCallback((pos: number, immediate: boolean) => { @@ -54,7 +54,7 @@ const ScrollButtons: FC = ({ scrollerFactoryRef, scrollState if (globalize.getIsElementRTL(scrollButtonsRef.current)) { localeAwarePos *= -1; } - SetLocaleScrollPos(localeAwarePos); + setLocaleScrollPos(localeAwarePos); }, [scrollState.scrollPos]); return ( diff --git a/src/elements/emby-scroller/Scroller.tsx b/src/elements/emby-scroller/Scroller.tsx index 1956b1d664..6cd83fc784 100644 --- a/src/elements/emby-scroller/Scroller.tsx +++ b/src/elements/emby-scroller/Scroller.tsx @@ -32,7 +32,7 @@ const Scroller: FC = ({ isAllowNativeSmoothScrollEnabled, children }) => { - const [showControls, SetShowControls] = useState(false); + const [showControls, setShowControls] = useState(false); const [scrollState, setScrollState] = useState({ scrollSize: 0, scrollPos: 0, @@ -196,7 +196,7 @@ const Scroller: FC = ({ capture: false, passive: true }); - SetShowControls(true); + setShowControls(true); } return () => { @@ -229,12 +229,12 @@ const Scroller: FC = ({ return ( <> { - showControls && scrollState.scrollWidth > scrollState.scrollSize + 20 ? + showControls && scrollState.scrollWidth > scrollState.scrollSize + 20 && : null + /> }