-
-
Notifications
You must be signed in to change notification settings - Fork 45
Consolidate Heading Components into a Single Typography Component #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consolidate Heading Components into a Single Typography Component #23
Conversation
|
Good idea. thanks for the great work. |
|
Yes, we could have used a component name like |
|
like every typography types(heading, p, quotes, code...) all in the same component? |
|
btw are you in our Discord server? |
No, just |
|
|
makes sense. I started a poll on the community server. let's see if others have any opinion on this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we don't need both variant and tag, let's combine both and make it as
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason for both the tag and variants is to allow users to apply sizes and styles from other elements to the specified tag. If we remove the variants, we will lose that feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you mean to let users do something like this <Text variant="h2" tag="p" />?
packages/ui/Text/Text.tsx
Outdated
|
|
||
| const textVariants = cva("font-head", { | ||
| variants: { | ||
| variant: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
variants: {
as: {
p: ""
}
....There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean I should update the variant prop to as?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
ariflogs
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the great work 🚀
packages/ui/Text/Text.tsx
Outdated
| } | ||
|
|
||
| export const Text = <T extends TagsMap>(props: TextProps<T>) => { | ||
| const { className, tag = "p" as T, variant, ...otherProps } = props; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as = "p" as T
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you mean to let users do something like this <Text variant="h2" tag="p" />?
packages/ui/Text/Text.tsx
Outdated
|
|
||
| const textVariants = cva("font-head", { | ||
| variants: { | ||
| variant: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
Consolidate Heading Components into a Single
TextComponentThis pull request consolidates individual heading components (
H1,H2,H3,H4,H5, andH6) into a single, flexibleTextcomponent. This approach streamlines the implementation of headings while maintaining semantic HTML and accessibility.Features:
TextComponent: A unified component that allows users to specify the desired heading level (fromh1toh6andp) using props, while applying the appropriate styles for each level.className,component, and additional HTML attributes, allowing for extensive customization and integration.Usage Example: