Skip to content

Commit

Permalink
feat: hide lang control if no langs (#228)
Browse files Browse the repository at this point in the history
  • Loading branch information
makamekm authored Mar 31, 2024
1 parent fe016ef commit 43b0be5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/components/Controls/Controls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<ControlsProps>((props) => {
const {isVerticalView} = useContext(ControlsLayoutContext);
const {
Expand Down Expand Up @@ -88,7 +92,7 @@ const Controls = memo<ControlsProps>((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);
Expand Down

0 comments on commit 43b0be5

Please sign in to comment.