Skip to content

Commit

Permalink
fix(Breacrumbs): change goBackTitle to accept React.Node
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
translation removed, use goBackTitle prop with Translate
  • Loading branch information
mainframev committed Apr 17, 2023
1 parent 5dc5d89 commit b1614e6
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/orbit-components/src/Breadcrumbs/README.md
Expand Up @@ -25,7 +25,7 @@ Table below contains all types of the props available in Breadcrumbs component.
| **children** | `React.Node` | | The content of the Breadcrumbs, normally [`BreadcrumbsItem`](#breadcrumbsitem). |
| onGoBack | `event => void \| Promise` | | Callback for handling back button action. If present the back button is visible. |
| backHref | `string` | | The location for the back button to direct to. Turns the back button into a link when present (renders as an `a` element). |
| goBackTitle | `Translation` | `"Back"` | Property for passing translation string when you want to use the `onGoBack` callback. |
| goBackTitle | `React.Node` | `"Back"` | Property for passing translation string when you want to use the `onGoBack` callback. |
| spaceAfter | `enum` | | Additional `margin-bottom` after component. [See spacing docs](https://github.com/kiwicom/orbit/tree/master/packages/orbit-components/src/common/getSpacingToken) |

## Functional specs
Expand Down
4 changes: 2 additions & 2 deletions packages/orbit-components/src/Breadcrumbs/index.js.flow
Expand Up @@ -4,7 +4,7 @@
*/
import * as React from "react";

import type { Globals, Translation } from "../common/common.js.flow";
import type { Globals } from "../common/common.js.flow";
import typeof BreadcrumbsItemType from "./BreadcrumbsItem/index.js.flow";
import type { spaceAfter } from "../common/getSpacingToken/index.js.flow";

Expand All @@ -13,7 +13,7 @@ export type Props = {|
+children: React.Node,
+onGoBack?: (ev: SyntheticEvent<HTMLElement>) => void | Promise<any>,
+backHref?: string,
+goBackTitle?: Translation,
+goBackTitle?: React.Node,
...spaceAfter,
|};

Expand Down
12 changes: 1 addition & 11 deletions packages/orbit-components/src/Breadcrumbs/index.tsx
Expand Up @@ -5,7 +5,6 @@ import type * as Common from "../common/types";
import defaultTheme from "../defaultTheme";
import ChevronBackward from "../icons/ChevronBackward";
import getSpacingToken from "../common/getSpacingToken";
import useTranslate from "../hooks/useTranslate";
import { right } from "../utils/rtl";
import TextLink from "../TextLink";
import Hide from "../Hide";
Expand Down Expand Up @@ -43,20 +42,11 @@ StyledBackButtonWrapper.defaultProps = {
};

const Breadcrumbs = (props: Props) => {
const translate = useTranslate();
const childEls = React.Children.toArray(
props.children,
) as React.ReactElement<BreadcrumbsItemProps>[];

const {
children,
dataTest,
onGoBack,
goBackTitle = translate("breadcrumbs_back"),
spaceAfter,
backHref,
id,
} = props;
const { children, dataTest, onGoBack, goBackTitle = "Back", spaceAfter, backHref, id } = props;
return (
<>
<Hide on={["smallMobile", "mediumMobile"]}>
Expand Down
2 changes: 1 addition & 1 deletion packages/orbit-components/src/Breadcrumbs/types.d.ts
Expand Up @@ -7,7 +7,7 @@ import type * as Common from "../common/types";

export interface Props extends Common.Globals, Common.SpaceAfter {
readonly children: React.ReactNode;
readonly goBackTitle?: Common.Translation;
readonly goBackTitle?: React.ReactNode;
readonly onGoBack?: Common.Event<React.SyntheticEvent<HTMLAnchorElement>>;
readonly backHref?: string;
}

0 comments on commit b1614e6

Please sign in to comment.