From 43b0be5207f9936d55f5d2da35ca886e7f4dd056 Mon Sep 17 00:00:00 2001 From: Maxim Karpov Date: Sun, 31 Mar 2024 11:36:19 +0300 Subject: [PATCH] feat: hide lang control if no langs (#228) --- src/components/Controls/Controls.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/Controls/Controls.tsx b/src/components/Controls/Controls.tsx index c1a5a9b9..ac2723ca 100644 --- a/src/components/Controls/Controls.tsx +++ b/src/components/Controls/Controls.tsx @@ -54,6 +54,10 @@ type Defined = { [P in keyof ControlsProps]-?: ControlsProps[P]; }; +function hasLangs(langs?: Lang[]) { + return langs?.length && langs.length > 1; +} + const Controls = memo((props) => { const {isVerticalView} = useContext(ControlsLayoutContext); const { @@ -88,7 +92,7 @@ const Controls = memo((props) => { const withSettingsControl = Boolean( onChangeWideFormat || onChangeTheme || onChangeShowMiniToc || onChangeTextSize, ); - const withLangControl = Boolean(lang && onChangeLang); + const withLangControl = Boolean(lang && hasLangs(langs) && onChangeLang); const withSinglePageControl = Boolean(onChangeSinglePage); const withPdfControl = Boolean(pdfLink); const withEditControl = Boolean(!singlePage && !hideEditControl && vcsUrl);