fix: Hide layout switcher when only 1 layout is enabled (#9610)

* Hide layout switcher when only 1 layouts is enabled

* Ran prettier

---------

Co-authored-by: Jeroen Reumkens <hello@jeroenreumkens.nl>
This commit is contained in:
Ujwal Kumar
2023-06-19 08:55:25 +00:00
committed by GitHub
co-authored by Jeroen Reumkens
parent 0930121680
commit ed65b2a3ab
@@ -40,13 +40,14 @@ export function Header({
// Only reason we create this component, is because it is used 3 times in this component,
// and this way we can't forget to update one of the props in all places :)
const LayoutToggleWithData = () => (
<LayoutToggle onLayoutToggle={onLayoutToggle} layout={layout} enabledLayouts={enabledLayouts} />
);
const LayoutToggleWithData = () => {
return enabledLayouts.length <= 1 ? null : (
<LayoutToggle onLayoutToggle={onLayoutToggle} layout={layout} enabledLayouts={enabledLayouts} />
);
};
// In month view we only show the layout toggle.
if (isMonthView) {
if (enabledLayouts.length <= 1) return null;
return <LayoutToggleWithData />;
}