diff --git a/src/lib/components/layout/__snapshots__/Layout.component.test.js.snap b/src/lib/components/layout/__snapshots__/Layout.component.test.js.snap index a5806a1193..f21e73cf6d 100644 --- a/src/lib/components/layout/__snapshots__/Layout.component.test.js.snap +++ b/src/lib/components/layout/__snapshots__/Layout.component.test.js.snap @@ -11,7 +11,7 @@ exports[`Storyshots Layout Sidebar docked 1`] = ` className="sc-jTzLTM drTWqF" >

-
- EN + FR
-
-
@@ -179,7 +171,6 @@ exports[`Storyshots Layout Sidebar docked 1`] = ` onFocus={[Function]} size="larger" tabIndex="0" - title="Scality Apps" >
-
-
@@ -205,7 +192,6 @@ exports[`Storyshots Layout Sidebar docked 1`] = ` onFocus={[Function]} size="larger" tabIndex="0" - title="Help" >
- -
@@ -231,7 +213,6 @@ exports[`Storyshots Layout Sidebar docked 1`] = ` onFocus={[Function]} size="larger" tabIndex="0" - title="Carlito" >

-
- EN + FR
-
-
@@ -614,7 +587,6 @@ exports[`Storyshots Layout Sidebar expanded 1`] = ` onFocus={[Function]} size="larger" tabIndex="0" - title="Scality Apps" >
-
-
@@ -640,7 +608,6 @@ exports[`Storyshots Layout Sidebar expanded 1`] = ` onFocus={[Function]} size="larger" tabIndex="0" - title="Help" >
-
-
@@ -666,7 +629,6 @@ exports[`Storyshots Layout Sidebar expanded 1`] = ` onFocus={[Function]} size="larger" tabIndex="0" - title="Carlito" > ; -type User = { - name: string, - actions: Items +type Action = { + type: string, + items?: Array }; + +type Actions = Array; type Tab = { title: string, selected?: boolean, @@ -22,13 +23,9 @@ type Tab = { export type Props = { onToggleClick?: () => void, - toggleVisible?: boolean, + rightActions: Actions, productName?: string, - applications?: Items, - help?: Items, - user?: User, logo?: Node, - languages?: Items, tabs?: Array }; @@ -95,14 +92,16 @@ const NavbarMenuItem = styled.div` display: flex; justify-content: center; align-items: center; + .sc-dropdown { + .trigger { + height: ${defaultTheme.navbarHeight}; + font-size: ${defaultTheme.fontSize.base}; + } + } - button { + .sc-button { margin: 0; border-radius: 0; - height: ${defaultTheme.navbarHeight}; - width: ${defaultTheme.navbarItemWidth}; - } - .trigger { height: ${defaultTheme.navbarHeight}; font-size: ${defaultTheme.fontSize.base}; } @@ -125,27 +124,35 @@ const LogoContainer = styled.div` } `; +const getActionRenderer = ({ type, items = null, ...rest }) => { + if (type === "dropdown") { + return items ? ( + + ) : null; + } else if (type === "button") { + return

- EN + FR
-

-
@@ -226,7 +221,6 @@ exports[`Storyshots Navbar Default 1`] = ` onFocus={[Function]} size="larger" tabIndex="0" - title="Scality Apps" >
-
-
@@ -252,7 +242,6 @@ exports[`Storyshots Navbar Default 1`] = ` onFocus={[Function]} size="larger" tabIndex="0" - title="Help" >
-
-
+
@@ -278,7 +293,6 @@ exports[`Storyshots Navbar Default 1`] = ` onFocus={[Function]} size="larger" tabIndex="0" - title="Carlito" >

- EN + FR
-

-
@@ -488,7 +497,6 @@ exports[`Storyshots Navbar Default 1`] = ` onFocus={[Function]} size="larger" tabIndex="0" - title="Scality Apps" >
-
-
@@ -514,7 +518,6 @@ exports[`Storyshots Navbar Default 1`] = ` onFocus={[Function]} size="larger" tabIndex="0" - title="Help" >
-
-
+
@@ -540,7 +569,6 @@ exports[`Storyshots Navbar Default 1`] = ` onFocus={[Function]} size="larger" tabIndex="0" - title="Carlito" >

- EN + FR
-

-
@@ -720,7 +743,6 @@ exports[`Storyshots Navbar Default 1`] = ` onFocus={[Function]} size="larger" tabIndex="0" - title="Scality Apps" >
-
-
@@ -746,7 +764,6 @@ exports[`Storyshots Navbar Default 1`] = ` onFocus={[Function]} size="larger" tabIndex="0" - title="Help" >
-
-
+
@@ -772,7 +815,6 @@ exports[`Storyshots Navbar Default 1`] = ` onFocus={[Function]} size="larger" tabIndex="0" - title="Carlito" >
, + items: [ + { + label: "English", + name: "EN", + onClick: action("English selected") + } + ] }, { - label: "Onboarding", - onClick: action("Onboarding clicked"), - "data-cy": "Onboarding" - } -]; - -const user = { - name: "Carlito", - actions: [ - { label: "Log out", onClick: action("Logout clicked"), "data-cy": "Logout" } - ] -}; - -const languages = [ + type: "dropdown", + icon: , + items: [ + { label: "Hyperdrive UI", onClick: action("Hyperdrive UI clicked") } + ] + }, { - label: "Français", - name: "FR", - onClick: action("French selected"), - selected: false + type: "dropdown", + icon: , + items: [ + { label: "About", onClick: action("About clicked") }, + { label: "Documentation", onClick: action("Documentation clicked") }, + { label: "Onboarding", onClick: action("Onboarding clicked") } + ] }, { - label: "English", - name: "EN", - onClick: action("English selected"), - selected: true + type: "dropdown", + text: "Carlito", + icon: , + items: [{ label: "Log out", onClick: action("Logout clicked") }] } ]; storiesOf("Layout", module) .addDecorator(withKnobs) .add("Sidebar docked", () => { - const toggle = boolean("Sidebar Toogle Visible", true); const expanded = boolean("Sidebar Expanded", false); const sidebar = { @@ -85,12 +77,8 @@ storiesOf("Layout", module) const navbar = { onToggleClick: action("toggle clicked"), - toggleVisible: toggle, productName: "Harware UI", - languages, - applications, - help, - user + rightActions }; return ( @@ -107,12 +95,8 @@ storiesOf("Layout", module) const navbar = { onToggleClick: action("toggle clicked"), - toggleVisible: true, productName: "Harware UI", - languages, - applications, - help, - user + rightActions }; return ( diff --git a/stories/navbar.js b/stories/navbar.js index bf69adb785..894ca064fb 100644 --- a/stories/navbar.js +++ b/stories/navbar.js @@ -4,21 +4,6 @@ import Navbar from "../src/lib/components/navbar/Navbar.component"; import { action } from "@storybook/addon-actions"; import { storiesOf } from "@storybook/react"; -const applications = [ - { label: "Hyperdrive UI", onClick: action("Hyperdrive UI clicked") } -]; - -const help = [ - { label: "About", onClick: action("About clicked") }, - { label: "Documentation", onClick: action("Documentation clicked") }, - { label: "Onboarding", onClick: action("Onboarding clicked") } -]; - -const user = { - name: "Carlito", - actions: [{ label: "Log out", onClick: action("Logout clicked") }] -}; - const tabs = [ { selected: true, @@ -47,18 +32,45 @@ const tabs = [ } ]; -const languages = [ +const rightActions = [ + { + type: "dropdown", + text: "FR", + icon: , + items: [ + { + label: "English", + name: "EN", + onClick: action("English selected") + } + ] + }, + { + type: "dropdown", + icon: , + items: [ + { label: "Hyperdrive UI", onClick: action("Hyperdrive UI clicked") } + ] + }, { - label: "Français", - name: "FR", - onClick: action("French selected"), - selected: false + type: "dropdown", + icon: , + items: [ + { label: "About", onClick: action("About clicked") }, + { label: "Documentation", onClick: action("Documentation clicked") }, + { label: "Onboarding", onClick: action("Onboarding clicked") } + ] }, { - label: "English", - name: "EN", - onClick: action("English selected"), - selected: true + type: "button", + icon: , + onClick: action("Theme toggle clicked") + }, + { + type: "dropdown", + text: "Carlito", + icon: , + items: [{ label: "Log out", onClick: action("Logout clicked") }] } ]; @@ -68,39 +80,26 @@ storiesOf("Navbar", module).add("Default", () => {

Navbar with toggle

Navbar without toggle

Navbar with customized logo

} tabs={tabs} />

Navbar with only tabs

- +
); });