Skip to content

Conversation

dani-moreno
Copy link
Collaborator

@dani-moreno dani-moreno commented Aug 11, 2025

Description

Text is a typography component that handles styling of different semantic usages of texts across Factorial. It features:

  • Semantic variants. Choose between different semantic variants like "heading", "description", "body", etc., and the component handles the styling.
  • Text alignment. Align text to the left, center, or right.
  • Ellipsis. Optionally display text with an ellipsis and a tooltip showing the full text.
  • Semantic HTML tag. The text is rendered in a semantic tag depending on the variant selected. For example, if you set the variant as heading, it will render a h2, but if you use body, it will render a p. Optionally, the user can choose a different element to render, through the as prop.

Screenshots

image image
image Code Image Usage (1)

Implementation details

  • Component is separated into an internal one and the one we actually export. This is because we want to have private props (like ⁠className) and private variants, only used inside the design system, but not in Factorial.
  • Shared list of allowed elements. Both in OneEllipsis (component used for the ellipsis) and F0Text, there's a prop to choose in which HTML element is the text rendered. I've added that option to OneEllipsis.

Copy link
Contributor

github-actions bot commented Aug 11, 2025

🔍 Visual review for your branch is published 🔍

Here are the links to:

@dani-moreno dani-moreno marked this pull request as ready for review August 12, 2025 09:47
@dani-moreno dani-moreno requested a review from a team as a code owner August 12, 2025 09:47
import { textVariants } from "./variants"

export type AsAllowedList =
| "div"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why would we want to have a text as a div? 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've seen it used a lot for generic layouts, but it's probably bad for accessibility, given that we have plenty of other tags that suit text better. I can remove it if we feel it doesn't fit there 👍

Copy link
Collaborator

Choose a reason for hiding this comment

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

div is a way to render the text as block element.
Maybe we can remove span and div and use the prop block or inline to render them block or inline

import { textVariants } from "./variants"

export type AsAllowedList =
| "div"
Copy link
Collaborator

Choose a reason for hiding this comment

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

div is a way to render the text as block element.
Maybe we can remove span and div and use the prop block or inline to render them block or inline

| "p"
| "label"
| "span"
| "h1"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wondering If makes sense to create an specific component F0Heading for the headings, its a way to control what is a heading or not, visually can be similar to text, but semantic are diferent

Copy link
Contributor

github-actions bot commented Sep 22, 2025

Coverage Report for packages/react

Status Category Percentage Covered / Total
🔵 Lines 21.55% 16231 / 75317
🔵 Statements 21.55% 16231 / 75317
🔵 Functions 36.85% 596 / 1617
🔵 Branches 74.75% 1809 / 2420
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/react/src/components/exports.ts 0% 0% 0% 0% 1-12
packages/react/src/components/F0Text/Text.tsx 100% 100% 100% 100%
packages/react/src/components/F0Text/TextInternal.tsx 72.72% 66.66% 100% 72.72% 81-95
packages/react/src/components/F0Text/index.tsx 0% 0% 0% 0% 1
packages/react/src/components/F0Text/types.ts 100% 100% 100% 100%
packages/react/src/components/F0Text/variants.ts 100% 100% 100% 100%
packages/react/src/components/F0Text/__stories__/Text.stories.tsx 0% 100% 100% 0% 2-88
packages/react/src/components/OneEllipsis/OneEllipsis.tsx 100% 85% 100% 100%
Generated in workflow #7951 for commit c941d26 by the Vitest Coverage Report Action

Copy link
Contributor

github-actions bot commented Sep 22, 2025

size-limit report 📦

Path Size
JS: Stable 393.29 KB (+0.1% 🔺)
JS: Experimental 734.07 KB (+0.1% 🔺)
CSS 71.61 KB (0%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants