2020-03-30 15:04:00 +02:00
|
|
|
/*
|
2024-09-24 09:42:07 +02:00
|
|
|
* Copyright (c) 2020 - present Cloudogu GmbH
|
2020-03-30 15:04:00 +02:00
|
|
|
*
|
2024-09-24 09:42:07 +02:00
|
|
|
* This program is free software: you can redistribute it and/or modify it under
|
|
|
|
|
* the terms of the GNU Affero General Public License as published by the Free
|
|
|
|
|
* Software Foundation, version 3.
|
2020-03-30 15:04:00 +02:00
|
|
|
*
|
2024-09-24 09:42:07 +02:00
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
|
|
|
|
* details.
|
2020-03-30 15:04:00 +02:00
|
|
|
*
|
2024-09-24 09:42:07 +02:00
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
* along with this program. If not, see https://www.gnu.org/licenses/.
|
2020-03-30 15:04:00 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { storiesOf } from "@storybook/react";
|
|
|
|
|
import React, { ReactElement } from "react";
|
|
|
|
|
import SecondaryNavigation from "./SecondaryNavigation";
|
|
|
|
|
import SecondaryNavigationItem from "./SecondaryNavigationItem";
|
|
|
|
|
import styled from "styled-components";
|
|
|
|
|
import SubNavigation from "./SubNavigation";
|
|
|
|
|
import { Binder, ExtensionPoint, BinderContext } from "@scm-manager/ui-extensions";
|
|
|
|
|
import { MemoryRouter } from "react-router-dom";
|
|
|
|
|
|
|
|
|
|
const Columns = styled.div`
|
|
|
|
|
margin: 2rem;
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const starships = (
|
|
|
|
|
<SubNavigation to="/hitchhiker/starships" label="Starships">
|
|
|
|
|
<SecondaryNavigationItem
|
|
|
|
|
to="/hitchhiker/starships/heart-of-gold"
|
|
|
|
|
icon="fas fa-star"
|
|
|
|
|
label="Heart Of Gold"
|
|
|
|
|
title="Heart Of Gold"
|
|
|
|
|
/>
|
|
|
|
|
<SecondaryNavigationItem to="/hitchhiker/starships/titanic" label="Titanic" title="Starship Titanic" />
|
|
|
|
|
</SubNavigation>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const withRoute = (route: string) => {
|
|
|
|
|
return (story: ReactElement<any>) => <MemoryRouter initialEntries={[route]}>{story}</MemoryRouter>;
|
|
|
|
|
};
|
|
|
|
|
|
2021-11-04 08:33:11 +01:00
|
|
|
storiesOf("Secondary Navigation", module)
|
2023-12-12 09:18:50 +01:00
|
|
|
.addDecorator((story) => (
|
2020-03-30 15:04:00 +02:00
|
|
|
<Columns className="columns">
|
|
|
|
|
<div className="column is-3">{story()}</div>
|
|
|
|
|
</Columns>
|
|
|
|
|
))
|
|
|
|
|
.add("Default", () =>
|
|
|
|
|
withRoute("/")(
|
2020-03-31 08:26:01 +02:00
|
|
|
<SecondaryNavigation label="Hitchhiker">
|
|
|
|
|
<SecondaryNavigationItem to="/42" icon="fas fa-puzzle-piece" label="Puzzle 42" title="Puzzle 42" />
|
|
|
|
|
<SecondaryNavigationItem to="/heart-of-gold" icon="fas fa-star" label="Heart Of Gold" title="Heart Of Gold" />
|
2020-03-30 15:04:00 +02:00
|
|
|
</SecondaryNavigation>
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
.add("Sub Navigation", () =>
|
|
|
|
|
withRoute("/")(
|
2020-03-31 08:26:01 +02:00
|
|
|
<SecondaryNavigation label="Hitchhiker">
|
2020-03-30 15:04:00 +02:00
|
|
|
<SecondaryNavigationItem to="/42" icon="fas fa-puzzle-piece" label="Puzzle 42" title="Puzzle 42" />
|
|
|
|
|
{starships}
|
|
|
|
|
</SecondaryNavigation>
|
|
|
|
|
)
|
|
|
|
|
)
|
2020-03-31 08:26:01 +02:00
|
|
|
.add("Extension Point", () => {
|
2020-03-30 15:04:00 +02:00
|
|
|
const binder = new Binder("menu");
|
|
|
|
|
binder.bind("subnav.sample", starships);
|
|
|
|
|
return withRoute("/hitchhiker/starships/titanic")(
|
|
|
|
|
<BinderContext.Provider value={binder}>
|
2020-03-31 08:26:01 +02:00
|
|
|
<SecondaryNavigation label="Hitchhiker">
|
2020-03-30 15:04:00 +02:00
|
|
|
<SecondaryNavigationItem to="/42" icon="fas fa-puzzle-piece" label="Puzzle 42" title="Puzzle 42" />
|
|
|
|
|
<ExtensionPoint name="subnav.sample" renderAll={true} />
|
|
|
|
|
</SecondaryNavigation>
|
|
|
|
|
</BinderContext.Provider>
|
|
|
|
|
);
|
2020-06-17 14:49:54 +02:00
|
|
|
})
|
|
|
|
|
.add("Active when match", () =>
|
|
|
|
|
withRoute("/hog")(
|
|
|
|
|
<SecondaryNavigation label="Hitchhiker">
|
|
|
|
|
<SecondaryNavigationItem to="/42" icon="fas fa-puzzle-piece" label="Puzzle 42" title="Puzzle 42" />
|
|
|
|
|
<SecondaryNavigationItem
|
2023-12-12 09:18:50 +01:00
|
|
|
activeWhenMatch={(route) => route.location?.pathname === "/hog"}
|
2020-06-17 14:49:54 +02:00
|
|
|
to="/heart-of-gold"
|
|
|
|
|
icon="fas fa-star"
|
|
|
|
|
label="Heart Of Gold"
|
|
|
|
|
title="Heart Of Gold"
|
|
|
|
|
/>
|
|
|
|
|
</SecondaryNavigation>
|
|
|
|
|
)
|
|
|
|
|
);
|