Skip to content

Commit

Permalink
feat(Card): add labelClose prop
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
use labelClose prop to add title for close button
  • Loading branch information
mainframev committed Apr 17, 2023
1 parent b1614e6 commit 71d6cc4
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 5 deletions.
Expand Up @@ -48,6 +48,7 @@ interface Props {
dataA11ySection?: string;
header?: React.ReactNode;
expandable?: boolean;
labelClose?: React.ReactNode;
expanded?: boolean;
handleKeyDown: React.KeyboardEventHandler<HTMLDivElement>;
onClick?: React.MouseEventHandler<HTMLDivElement>;
Expand All @@ -64,6 +65,7 @@ const CardSectionHeader = ({
isContent,
expandable,
expanded,
labelClose,
onClick,
slideID,
labelID,
Expand All @@ -89,6 +91,7 @@ const CardSectionHeader = ({
title={title}
titleAs={titleAs}
description={description}
labelClose={labelClose}
icon={icon}
expandable={expandable}
header={header}
Expand Down
Expand Up @@ -10,6 +10,7 @@ export type Props = {|
+onClose?: () => void | Promise<any>,
+title?: React.Node,
+titleAs?: As,
+labelClose?: React.Node,
+isSection?: boolean,
+dataA11ySection?: string,
+expandable?: boolean,
Expand Down
Expand Up @@ -9,7 +9,6 @@ import Stack from "../../../Stack";
import Heading from "../../../Heading";
import Text from "../../../Text";
import Close from "../../../icons/Close";
import useTranslate from "../../../hooks/useTranslate";
import ButtonLink from "../../../ButtonLink";
import type { Props } from "./types";

Expand All @@ -29,15 +28,14 @@ const StyledCloseContainer = styled.div`
z-index: 1;
`;

const CardCloseButton = ({ onClick }) => {
const translate = useTranslate();
const CardCloseButton = ({ onClick, labelClose }) => {
return (
<ButtonLink
type="secondary"
size="small"
iconLeft={<Close />}
onClick={onClick}
title={translate("button_close")}
title={labelClose}
/>
);
};
Expand All @@ -48,6 +46,7 @@ const Header = ({
title,
titleAs,
isSection,
labelClose,
actions,
dataA11ySection,
onClose,
Expand Down Expand Up @@ -89,7 +88,7 @@ const Header = ({
)}
{onClose && !actions && (
<StyledCloseContainer>
<CardCloseButton onClick={onClose} />
<CardCloseButton onClick={onClose} labelClose={labelClose} />
</StyledCloseContainer>
)}
</Stack>
Expand Down
Expand Up @@ -10,6 +10,7 @@ export interface Props {
onClose?: Common.Event<React.SyntheticEvent<HTMLButtonElement | HTMLAnchorElement>>;
title?: React.ReactNode;
titleAs?: As;
labelClose?: React.ReactNode;
isSection?: boolean;
dataA11ySection?: string;
expandable?: boolean;
Expand Down
1 change: 1 addition & 0 deletions packages/orbit-components/src/Card/index.js.flow
Expand Up @@ -17,6 +17,7 @@ export type Props = {|
+margin?: string | number | ObjectProperty,
+description?: React.Node,
+icon?: React.Node,
+labelClose?: React.Node,
+actions?: React.Node,
+onClose?: () => void | Promise<any>,
+loading?: boolean,
Expand Down
2 changes: 2 additions & 0 deletions packages/orbit-components/src/Card/index.tsx
Expand Up @@ -37,6 +37,7 @@ const Card = ({
actions,
description,
children,
labelClose,
dataTest,
id,
onClose,
Expand Down Expand Up @@ -91,6 +92,7 @@ const Card = ({
dataA11ySection={dataA11ySection}
actions={actions}
title={title}
labelClose={labelClose}
titleAs={titleAs}
onClose={onClose}
header={header}
Expand Down
1 change: 1 addition & 0 deletions packages/orbit-components/src/Card/types.d.ts
Expand Up @@ -14,6 +14,7 @@ export interface Props extends Common.Globals, Common.SpaceAfter {
readonly titleAs?: As;
readonly margin?: React.CSSProperties["margin"] | Common.ObjectProperty;
readonly description?: React.ReactNode;
readonly labelClose?: React.ReactNode;
readonly icon?: React.ReactNode;
readonly actions?: React.ReactNode;
readonly onClose?: Common.Event<React.SyntheticEvent<HTMLButtonElement | HTMLAnchorElement>>;
Expand Down

0 comments on commit 71d6cc4

Please sign in to comment.