Skip to content

Commit

Permalink
Merge pull request #2741 from SUI-Components/fix-primitive-typography…
Browse files Browse the repository at this point in the history
…-classname-prop

fix(components/primitive/typography): allow for use of className prop
  • Loading branch information
jordevo committed Jun 4, 2024
2 parents beb590b + 7a374d3 commit af00f9e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
1 change: 1 addition & 0 deletions components/primitive/typography/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const PrimitiveTypography = ({
...props
}) => {
const {...resultingProps} = useTypography({
className,
design,
variant,
as,
Expand Down
29 changes: 17 additions & 12 deletions components/primitive/typography/src/useTypography.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,23 @@ const getClassNames = ({
isBlurred,
isLinked
}) => {
return cx(BASE_CLASS, [`${BASE_CLASS}-design-${design}`, `${BASE_CLASS}-variant-${variant}`], {
[`${BASE_CLASS}-linked`]: isLinked,
[`${BASE_CLASS}-fontSize-${fontSize}`]: fontSize !== undefined,
[`${BASE_CLASS}-fontFamily-${fontFamily}`]: fontFamily !== undefined,
[`${BASE_CLASS}-fontWeight-${fontWeight}`]: fontWeight !== undefined,
[`${BASE_CLASS}-fontStyle-${fontStyle}`]: fontStyle !== undefined,
[`${BASE_CLASS}-fontStretch-${fontStretch}`]: fontStretch !== undefined,
[`${BASE_CLASS}-letterSpacing-${letterSpacing}`]: letterSpacing !== undefined,
[`${BASE_CLASS}-lineHeight-${lineHeight}`]: lineHeight !== undefined,
[`${BASE_CLASS}-textDecorationLine-${textDecorationLine}`]: textDecorationLine !== undefined,
[`${BASE_CLASS}-blurred-${isBlurred}`]: isBlurred !== undefined,
return cx(
BASE_CLASS,
[`${BASE_CLASS}-design-${design}`, `${BASE_CLASS}-variant-${variant}`],
{
[`${BASE_CLASS}-linked`]: isLinked,
[`${BASE_CLASS}-fontSize-${fontSize}`]: fontSize !== undefined,
[`${BASE_CLASS}-fontFamily-${fontFamily}`]: fontFamily !== undefined,
[`${BASE_CLASS}-fontWeight-${fontWeight}`]: fontWeight !== undefined,
[`${BASE_CLASS}-fontStyle-${fontStyle}`]: fontStyle !== undefined,
[`${BASE_CLASS}-fontStretch-${fontStretch}`]: fontStretch !== undefined,
[`${BASE_CLASS}-letterSpacing-${letterSpacing}`]: letterSpacing !== undefined,
[`${BASE_CLASS}-lineHeight-${lineHeight}`]: lineHeight !== undefined,
[`${BASE_CLASS}-textDecorationLine-${textDecorationLine}`]: textDecorationLine !== undefined,
[`${BASE_CLASS}-blurred-${isBlurred}`]: isBlurred !== undefined
},
className
})
)
}

const useTypography = ({
Expand Down Expand Up @@ -87,6 +91,7 @@ const useTypography = ({
isLinked
})
)

return {
...props,
...{
Expand Down

0 comments on commit af00f9e

Please sign in to comment.