Skip to content

Commit

Permalink
feat(Alert): add labelClose prop
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
translation removed, use labelClose prop
  • Loading branch information
mainframev committed Apr 17, 2023
1 parent e5aeb5a commit 5dc5d89
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/orbit-components/src/Alert/README.md
Expand Up @@ -29,6 +29,7 @@ The table below contains all types of the props available in Alert component.
| title | `Translation` | | The title of the Alert. |
| **type** | [`enum`](#enum) | `"info"` | The type of Alert. |
| suppressed | `boolean` | | If `suppressed` is on, Alert will not have colored background |
| labelClose | `React.Node` | | The label of the close button. |

### enum

Expand Down
1 change: 1 addition & 0 deletions packages/orbit-components/src/Alert/index.js.flow
Expand Up @@ -18,6 +18,7 @@ export type Props = {|
+closable?: boolean,
+suppressed?: boolean,
+inlineActions?: React.Node,
+labelClose?: React.Node,
+onClose?: () => void | Promise<any>,
...Globals,
...spaceAfter,
Expand Down
8 changes: 5 additions & 3 deletions packages/orbit-components/src/Alert/index.tsx
Expand Up @@ -19,7 +19,6 @@ import { rtlSpacing, right, left } from "../utils/rtl";
import getSpacingToken from "../common/getSpacingToken";
import { Item } from "../List/ListItem";
import { StyledText } from "../Text";
import useTranslate from "../hooks/useTranslate";
import { StyledHeading } from "../Heading";
import media from "../utils/mediaQuery";

Expand Down Expand Up @@ -247,14 +246,15 @@ const AlertCloseButton = ({
hasChildren,
dataTest,
onClick,
labelClose,
icon,
}: {
hasChildren: boolean;
dataTest: string;
labelClose?: React.ReactNode;
onClick?: Common.Callback;
icon: React.ReactNode;
}) => {
const translate = useTranslate();
return (
<CloseContainer hasChildren={hasChildren}>
<ButtonLink
Expand All @@ -263,7 +263,7 @@ const AlertCloseButton = ({
size="small"
iconLeft={icon}
type="secondary"
title={translate("button_close")}
title={labelClose}
/>
</CloseContainer>
);
Expand All @@ -282,6 +282,7 @@ const Alert = (props: Props) => {
spaceAfter,
suppressed,
inlineActions,
labelClose,
} = props;
return (
<StyledAlert
Expand Down Expand Up @@ -320,6 +321,7 @@ const Alert = (props: Props) => {
hasChildren={!!children}
dataTest={CLOSE_BUTTON_DATA_TEST}
onClick={onClose}
labelClose={labelClose}
icon={<Close size="small" color={type} />}
/>
)}
Expand Down
1 change: 1 addition & 0 deletions packages/orbit-components/src/Alert/types.d.ts
Expand Up @@ -13,6 +13,7 @@ export interface Props extends Common.Globals, Common.SpaceAfter {
readonly icon?: React.ReactNode;
readonly closable?: boolean;
readonly inlineActions?: React.ReactNode;
readonly labelClose?: React.ReactNode;
readonly onClose?: Common.Callback;
readonly suppressed?: boolean;
}

0 comments on commit 5dc5d89

Please sign in to comment.