Skip to content

Commit

Permalink
feat(NavigationBar): add openTitle prop
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
translation removed, use openTitle with Translate instead
  • Loading branch information
mainframev committed Apr 17, 2023
1 parent c08c245 commit 2abe630
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
19 changes: 10 additions & 9 deletions packages/orbit-components/src/NavigationBar/README.md
Expand Up @@ -24,12 +24,13 @@ After adding import into your project you can use it simply like:

Table below contains all types of the props available in the NavigationBar component.

| Name | Type | Default | Description |
| :----------- | :---------------------- | :------ | :---------------------------------------------------------------------------------------------------- |
| **children** | `React.Node` | | The content of the NavigationBar. |
| dataTest | `string` | | Optional prop for testing purposes. |
| id | `string` | | Set `id` for `NavigationBar` |
| onMenuOpen | `() => void \| Promise` | | Function for handling onClick event on HamburgerMenu icon. If `null`, the HamburgerMenu won't appear. |
| onHide | `() => void \| Promise` | | Function for handling event when the NavigationBar disappears. |
| onShow | `() => void \| Promise` | | Function for handling event when the NavigationBar appears. |
| hideOnScroll | `boolean` | `true` | Turn on or off hiding navigation bar on scroll |
| Name | Type | Default | Description |
| :----------- | :---------------------- | :----------------------- | :---------------------------------------------------------------------------------------------------- |
| **children** | `React.Node` | | The content of the NavigationBar. |
| dataTest | `string` | | Optional prop for testing purposes. |
| id | `string` | | Set `id` for `NavigationBar` |
| onMenuOpen | `() => void \| Promise` | | Function for handling onClick event on HamburgerMenu icon. If `null`, the HamburgerMenu won't appear. |
| onHide | `() => void \| Promise` | | Function for handling event when the NavigationBar disappears. |
| onShow | `() => void \| Promise` | | Function for handling event when the NavigationBar appears. |
| hideOnScroll | `boolean` | `true` | Turn on or off hiding navigation bar on scroll |
| openTitle | `React.Node` | `"Open navigation menu"` | Property for passing translation string to open Button title |
1 change: 1 addition & 0 deletions packages/orbit-components/src/NavigationBar/index.js.flow
Expand Up @@ -8,6 +8,7 @@ export type Props = {|
+onShow?: () => void | Promise<any>,
+onHide?: () => void | Promise<any>,
+hideOnScroll?: boolean,
+openTitle?: React.Node,
+children: React.Node,
...Globals,
|};
Expand Down
5 changes: 2 additions & 3 deletions packages/orbit-components/src/NavigationBar/index.tsx
Expand Up @@ -7,7 +7,6 @@ import defaultTheme from "../defaultTheme";
import MenuHamburger from "../icons/MenuHamburger";
import ButtonLink from "../ButtonLink";
import useStateWithCallback from "../hooks/useStateWithCallback";
import useTranslate from "../hooks/useTranslate";
import mq from "../utils/mediaQuery";
import type { Props } from "./types";

Expand Down Expand Up @@ -57,12 +56,12 @@ const NavigationBar = ({
onMenuOpen,
children,
dataTest,
openTitle = "Open navigation menu",
id,
onShow,
onHide,
hideOnScroll = true,
}: Props) => {
const translate = useTranslate();
const resolveCallback = React.useCallback(
state => {
if (onHide && !state) onHide();
Expand Down Expand Up @@ -109,7 +108,7 @@ const NavigationBar = ({
type="secondary"
onClick={onMenuOpen}
iconLeft={<MenuHamburger />}
title={translate("navigationbar_open_menu")}
title={openTitle}
/>
)}
</StyledNavigationBar>
Expand Down
1 change: 1 addition & 0 deletions packages/orbit-components/src/NavigationBar/types.d.ts
Expand Up @@ -9,5 +9,6 @@ export interface Props extends Common.Globals {
readonly onShow?: Common.Callback;
readonly onHide?: Common.Callback;
readonly children: React.ReactNode;
readonly openTitle?: React.ReactNode;
readonly hideOnScroll?: boolean;
}

0 comments on commit 2abe630

Please sign in to comment.