Skip to content

Commit

Permalink
paragraph default variant
Browse files Browse the repository at this point in the history
  • Loading branch information
Barsnes committed Jun 20, 2024
1 parent cff869e commit 1fbed80
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions packages/react/src/components/Typography/Paragraph/Paragraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,24 @@ export type ParagraphProps = {
size?: 'xs' | 'sm' | 'md' | 'lg';
/** Adds margin-bottom */
spacing?: boolean;
/** Adjusts styling for paragraph length */
variant?: 'long' | 'short';
/**
* Adjusts styling for paragraph length
* @default `default`
*/
variant?: 'long' | 'default' | 'short';
/**
* Change the default rendered element for the one passed as a child, merging their props and behavior.
* @default false
*/
asChild?: boolean;
} & HTMLAttributes<HTMLParagraphElement>;

const lineHeightMap = {
short: 'ds-line-height--sm',
default: 'ds-line-height--md',
long: 'ds-line-height--lg',
};

/** Use `Paragraph` to display text with paragraph text styles. */
export const Paragraph = forwardRef<HTMLParagraphElement, ParagraphProps>(
({ className, spacing, size = 'md', asChild, variant, ...rest }, ref) => {
Expand All @@ -34,9 +43,8 @@ export const Paragraph = forwardRef<HTMLParagraphElement, ParagraphProps>(
'ds-paragraph',

spacing && 'ds-paragraph--spacing',
variant
? `ds-paragraph-${variant}--${size}`
: `ds-paragraph--${size}`, // TODO find a better solution for this
`ds-paragraph--${size}`,
lineHeightMap[variant ?? 'default'],
className,
)}
{...rest}
Expand Down

0 comments on commit 1fbed80

Please sign in to comment.