diff --git a/packages/avatar/components/Avatar.tsx b/packages/avatar/components/Avatar.tsx index 8b4eef907..52b662d60 100644 --- a/packages/avatar/components/Avatar.tsx +++ b/packages/avatar/components/Avatar.tsx @@ -19,11 +19,20 @@ export interface AvatarProps { * Which icon size to use for the width and height */ size?: IconSize; + /** + * Allows custom styling + */ + className?: string; } -const Avatar = ({ label, src, size = DEFAULT_AVATAR_SIZE }: AvatarProps) => ( +const Avatar = ({ + label, + src, + className, + size = DEFAULT_AVATAR_SIZE +}: AvatarProps) => (
{ const iconSize = parseInt(iconSizes[ICON_SIZE], 10); return ( - + {iconShape ? ( ) : ( diff --git a/packages/badge/components/badge.tsx b/packages/badge/components/badge.tsx index f5cc13ab0..23575cf4f 100644 --- a/packages/badge/components/badge.tsx +++ b/packages/badge/components/badge.tsx @@ -1,4 +1,5 @@ import * as React from "react"; +import { cx } from "@emotion/css"; import { badge } from "../style"; export type BadgeAppearance = @@ -12,11 +13,19 @@ export type BadgeAppearance = export interface BadgeProps { appearance?: BadgeAppearance; children: React.ReactNode | string; + /** + * Allows custom styling + */ + className?: string; } -export const Badge = ({ appearance = "default", children }: BadgeProps) => { +export const Badge = ({ + appearance = "default", + children, + className +}: BadgeProps) => { return ( - + {children} ); diff --git a/packages/badge/components/badgeButton.tsx b/packages/badge/components/badgeButton.tsx index b578f4b4e..b61996f32 100644 --- a/packages/badge/components/badgeButton.tsx +++ b/packages/badge/components/badgeButton.tsx @@ -1,4 +1,4 @@ -import { css } from "@emotion/css"; +import { css, cx } from "@emotion/css"; import * as React from "react"; import Clickable from "../../clickable/components/clickable"; import { badge as badgeButton } from "../style"; @@ -11,6 +11,10 @@ export interface BadgeButtonProps { | "warning" | "danger" | "outline"; + /** + * Allows custom styling + */ + className?: string; onClick: (event?: React.SyntheticEvent) => void; /** * Tab index indicates if an element can be focused for more information see @@ -25,11 +29,12 @@ export interface BadgeButtonProps { const BadgeButton = ({ appearance = "default", children, + className, onClick, tabIndex = -1, "data-cy": dataCy = "badgeButton" }: BadgeButtonProps) => { - const className = css` + const defaultClassName = css` outline: none; cursor: pointer; ${badgeButton(appearance)}; @@ -37,7 +42,7 @@ const BadgeButton = ({ return ( - {children} + {children} ); }; diff --git a/packages/button/components/ButtonBase.tsx b/packages/button/components/ButtonBase.tsx index 084103023..61a7d572e 100644 --- a/packages/button/components/ButtonBase.tsx +++ b/packages/button/components/ButtonBase.tsx @@ -42,6 +42,10 @@ export interface ButtonProps extends LinkProps { */ ariaLabel?: string; children?: React.ReactNode | string; + /** + * Allows custom styling + */ + className?: string; /** * whether or not the button is enabled */ @@ -88,7 +92,6 @@ export interface ButtonProps extends LinkProps { export interface ButtonBaseProps extends ButtonProps { appearance: ButtonAppearances; - className?: string; } const ButtonContent = ({ iconStart, iconEnd, isProcessing, children }) => { diff --git a/packages/card/components/ButtonCard.tsx b/packages/card/components/ButtonCard.tsx index 776dc9a21..2a3b664ee 100644 --- a/packages/card/components/ButtonCard.tsx +++ b/packages/card/components/ButtonCard.tsx @@ -27,6 +27,10 @@ export interface ButtonCardProps extends CardProps { * Whether the component's child input has focus */ hasFocus?: boolean; + /** + * Allows custom styling + */ + className?: string; } const ButtonCard = ({ @@ -35,6 +39,7 @@ const ButtonCard = ({ disabled, hasFocus, onClick, + className, onKeyPress, ...other }: ButtonCardProps) => { @@ -64,13 +69,17 @@ const ButtonCard = ({ return ( { * Size can be set to "s", "m", or "l" to increase the header height. If not specified, size will default to medium. */ size?: HeaderSizes; + /** + * Allows custom header styling + */ + className?: string; }; - + /** + * Allows custom styling + */ className?: string; } @@ -62,7 +68,13 @@ const Card = ({ {...other} > {header?.headerImg && ( -
+
{header.headerImgAltText
)} diff --git a/packages/icon/components/Icon.tsx b/packages/icon/components/Icon.tsx index 869cde2e3..af409258d 100644 --- a/packages/icon/components/Icon.tsx +++ b/packages/icon/components/Icon.tsx @@ -11,17 +11,33 @@ const DEFAULT_ICON_SIZE: IconSize = "s"; export type IconShapes = SystemIcons | ProductIcons; export interface IconProps { - /** If an icon is more than decorative and requires further context include a description for screen readers */ + /** + * If an icon is more than decorative and requires further context include a description for screen readers + */ ariaLabel?: string; - /** The fill color of the icon */ + /** + * Allows custom styling + */ + className?: string; + /** + * The fill color of the icon + */ color?: string; - /** The id of the SVG symbol we're rendering from a generated sprite */ + /** + * The id of the SVG symbol we're rendering from a generated sprite + */ shape: SystemIcons | ProductIcons; - /** Which icon size to use for the width and height of the icon */ + /** + * Which icon size to use for the width and height of the icon + */ size?: IconSize; - /** human-readable selector used for writing tests */ + /** + * human-readable selector used for writing tests + */ ["data-cy"]?: string; - /** Sets display to block if true */ + /** + * Sets display to block if true + */ block?: boolean; } @@ -31,7 +47,8 @@ const Icon = ({ shape, ariaLabel, "data-cy": dataCy, - block + block, + className }: IconProps) => { const svgColor = color || "currentColor"; const iconSize = iconSizes[size]; @@ -44,7 +61,7 @@ const Icon = ({ viewBox={`0 0 ${parseInt(iconSize, 10)} ${parseInt(iconSize, 10)}`} role="img" aria-label={ariaLabel || `${shape} icon`} - className={cx(icon, tintSVG(svgColor), block ? blockIcon : "")} + className={cx(icon, tintSVG(svgColor), block ? blockIcon : "", className)} data-cy={["icon", dataCy].filter(Boolean).join(" ")} > diff --git a/packages/inlineBorderedItems/components/InlineBorderedItems.tsx b/packages/inlineBorderedItems/components/InlineBorderedItems.tsx index 56bb30a90..ad156ffe0 100644 --- a/packages/inlineBorderedItems/components/InlineBorderedItems.tsx +++ b/packages/inlineBorderedItems/components/InlineBorderedItems.tsx @@ -1,4 +1,5 @@ import * as React from "react"; +import { cx } from "@emotion/css"; import { SpaceSize } from "../../shared/styles/styleUtils/modifiers/modifierUtils"; import { inlineBorderedItems } from "../style"; @@ -6,14 +7,21 @@ export interface InlineBorderedItemsProps { children: | Array> | React.ReactElement; + /** + * Allows custom styling + */ + className?: string; gutterSize?: SpaceSize; } const InlineBorderedItems = ({ children, + className, gutterSize = "s" }: InlineBorderedItemsProps) => ( -
{children}
+
+ {children} +
); export default InlineBorderedItems;