Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions polaris-react/src/components/Box/Box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ export interface BoxProps {
children: ReactNode;
/** Color of children */
color?: ColorTokenScale;
/** HTML id attribute */
id?: string;
/** Spacing outside of container */
maxWidth?: string;
/** Spacing around children */
Expand Down Expand Up @@ -122,6 +124,7 @@ export const Box = forwardRef<HTMLElement, BoxProps>(
borderRadiusTopRight,
children,
color,
id,
maxWidth,
padding,
paddingBottom,
Expand Down Expand Up @@ -218,6 +221,7 @@ export const Box = forwardRef<HTMLElement, BoxProps>(
as,
{
className,
id,
ref,
style: sanitizeCustomProperties(style),
},
Expand Down
6 changes: 6 additions & 0 deletions polaris-react/src/components/Text/Text.scss
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,9 @@
font-size: var(--p-font-size-200);
line-height: var(--p-font-line-height-2);
}

.break {
word-wrap: break-word;
word-break: break-word;
overflow-wrap: break-word;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we double check we need all these properties?

}
13 changes: 12 additions & 1 deletion polaris-react/src/components/Text/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,16 @@ export interface TextProps {
alignment?: Alignment;
/** The element type */
as: Element;
/** Prevent text from overflowing */
breakWord?: boolean;
/** Text to display */
children: ReactNode;
/** Adjust color of text */
color?: Color;
/** Adjust weight of text */
fontWeight?: FontWeight;
/** HTML id attribute */
id?: string;
/** Truncate text overflow with ellipsis */
truncate?: boolean;
/** Typographic style of text */
Expand All @@ -61,9 +65,11 @@ export interface TextProps {
export const Text = ({
alignment,
as,
breakWord,
children,
color,
fontWeight,
id,
truncate = false,
variant,
visuallyHidden = false,
Expand All @@ -76,10 +82,15 @@ export const Text = ({
fontWeight ? styles[fontWeight] : styles[VariantFontWeightMapping[variant]],
(alignment || truncate) && styles.block,
alignment && styles[alignment],
breakWord && styles.break,
color && styles[color],
truncate && styles.truncate,
visuallyHidden && styles.visuallyHidden,
);

return <Component className={className}>{children}</Component>;
return (
<Component className={className} {...(id ? id : null)}>
{children}
</Component>
);
};