Skip to content
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

refactor: replace supabase/ui in design system typography components #1438

Conversation

babblebey
Copy link
Contributor

@babblebey babblebey commented Jul 26, 2023

Description

This pull request aims to refactor the typography components (Title and Text) in the design system to improve consistency, maintainability, and extensibility. The changes in this branch replaces supabase/ui typography component with native html alternatives leveraging @tailwindcss/typography and introduce enhancements to provide flexibility.

Notable Change

Introduce the TypographyWrapper component

This component serves as a wrapper around child components exposing children components to the prose utility class from @tailwindcss/typography which adds beautiful typographic defaults to uncontrollable vanilla HTML, like HTML rendered from Markdown.

It also serves as a primary wrapper for the Title and Text components.

Implementation

const TypographyWrapper: React.FC<TypographyWrapperProps> = ({ children, className, size = "sm", ...props }) => {
  return (
    <span className={clsx(
      "prose", 
      `prose-${size}`, 
      className)} 
      {...props}
    >
      {children}
    </span>
  );
};
  • The Component accepts the className and size props which uses as/to modify the below classes for the returned element

    • "prose": This is a default CSS class that provides basic typographic styles, such as margins and line heights, to improve readability of the text.
    • "prose-${size}": This class is dynamically generated based on the size prop. For example, if size is set to "sm", it will apply the class "prose-sm", which provides smaller font size and line height. Similarly, for other size values, appropriate styles will be applied.
    • className: This is used to apply any additional CSS classes passed through the className prop.
  • The component also passes any other props that might be provided to the TypographyWrapper through the ...props spread operator. This allows developers to use additional attributes on the wrapper element.

Use Cases

  • As Primary Wrapper for Title components.
const Title: React.FC<TitleProps> = ({ children, level = 1, weight = "medium", className, ...props }) => {
  const TitleTag = `h${level}` as keyof JSX.IntrinsicElements;

  return (
    <TypographyWrapper> // <- 🍕🍕🍕🍕🍕
      <TitleTag className={clsx(className, `font-${weight}`)} {...props}>
        {children}
      </TitleTag>
    </TypographyWrapper> // <- 🍕🍕🍕🍕🍕
  );
};
  • Useable sparingly (maybe for Blogposts highlight type 🍕)
<TypographyWrapper>
  <p>We get lots of complaints about it actually, with people regularly asking us things like:</p>
  <blockquote>
    <p>Why is Tailwind removing the default styles on my <code>h1</code> elements? How do I disable this? What do you mean I lose all the other base styles too?</p>
  </blockquote>
</TypographyWrapper>

screenshot-localhost_3000-2023 08 01-15_42_44

Other Changes

  • Text component very much follows similar implementation and integrates exactly as that in the initial set-up without regression.
<Text>
  Normal Text
</Text>

<Text className="!text-2xl !text-red-500">
  Normal Text (with ClassNames)
</Text>

<Text keyboard>
  Keyboard Text
</Text>

<Text code>
  Code Text
</Text>

<Text underline>
  Underlined Text
</Text>

<Text strikethrough>
  Strikethrough Text
</Text>

<Text small>
  Small Text
</Text>

screenshot-localhost_3000-2023 08 01-16_14_02

  • Title component also follows similar implementation and integrates exactly as that in the initial set-up.
<Title>
  Title Default Level and Weight
</Title>

<Title level={1} weight="light">
  Title Level 1 with light weight
</Title>

<Title level={3} className="!text-yellow-400">
  Title Level 3 with className
</Title>

screenshot-localhost_3000-2023 08 01-16_33_55

What type of PR is this? (check all applicable)

  • 🍕 Feature
  • 🐛 Bug Fix
  • 📝 Documentation Update
  • 🎨 Style
  • 🧑‍💻 Code Refactor
  • 🔥 Performance Improvements
  • ✅ Test
  • 🤖 Build
  • 🔁 CI
  • 📦 Chore (Release)
  • ⏩ Revert

Related Tickets & Documents

Fixes #1133

Mobile & Desktop Screenshots/Recordings

Added tests?

  • 👍 yes
  • 🙅 no, because they aren't needed
  • 🙋 no, because I need help

Added to documentation?

  • 📜 README.md
  • 📓 docs.opensauced.pizza
  • 🍕 dev.to/opensauced
  • 📕 storybook
  • 🙅 no documentation needed

[optional] Are there any post-deployment tasks we need to perform?

Install @tailwindcss/typography for local development

[optional] What gif best describes this PR or how it makes you feel?

@netlify
Copy link

netlify bot commented Jul 26, 2023

Deploy Preview for oss-insights ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 1df8154
🔍 Latest deploy log https://app.netlify.com/sites/oss-insights/deploys/64cb5a32af7ef900088ff230
😎 Deploy Preview https://deploy-preview-1438--oss-insights.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify
Copy link

netlify bot commented Jul 26, 2023

Deploy Preview for design-insights ready!

Name Link
🔨 Latest commit 1df8154
🔍 Latest deploy log https://app.netlify.com/sites/design-insights/deploys/64cb5a32fbf4fd00088559a5
😎 Deploy Preview https://deploy-preview-1438--design-insights.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@brandonroberts brandonroberts requested a review from OgDev-01 July 31, 2023 18:46
@OgDev-01
Copy link
Contributor

Hey @babblebey, is this ready for review?

@babblebey
Copy link
Contributor Author

babblebey commented Jul 31, 2023

is this ready for review?

@OgDev-01.... In a bit 🤞

@babblebey babblebey marked this pull request as ready for review August 1, 2023 19:06
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

PR Compliance Checks

Thank you for your Pull Request! We have run several checks on this pull request in order to make sure it's suitable for merging into this project. The results are listed in the following section.

Watched Files

This pull request modifies specific files that require careful review by the maintainers.

Files Matched

  • npm-shrinkwrap.json
  • package.json

Copy link
Contributor

@OgDev-01 OgDev-01 left a comment

Choose a reason for hiding this comment

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

LGTM... Thanks for taking a step forward and adding the tailwinds typography plugin 🍕

Quite a well crafted novel on the typography-wrapper story though 😁

@OgDev-01 OgDev-01 added the needs review PRs that need review from core engineering team label Aug 3, 2023
@brandonroberts brandonroberts merged commit 38cfb30 into open-sauced:beta Aug 4, 2023
open-sauced bot pushed a commit that referenced this pull request Aug 4, 2023
## [1.59.0-beta.3](v1.59.0-beta.2...v1.59.0-beta.3) (2023-08-04)

### 🧑‍💻 Code Refactoring

* replace supabase/ui in design system typography components ([#1438](#1438)) ([38cfb30](38cfb30))

### 🐛 Bug Fixes

* update release workflow to use GitHub app for semantic versioning ([#1484](#1484)) ([3f1ce84](3f1ce84))
open-sauced bot pushed a commit that referenced this pull request Aug 8, 2023
## [1.59.0](v1.58.0...v1.59.0) (2023-08-08)

### 🧑‍💻 Code Refactoring

* replace supabase/ui in design system typography components ([#1438](#1438)) ([38cfb30](38cfb30))

### 🍕 Features

* add a user notifications page ([#1478](#1478)) ([022dc69](022dc69))
* add conditional routing to single highlight dialog close action ([#1473](#1473)) ([1341cba](1341cba))
* add github link to profile ([#1459](#1459)) ([d42bc6d](d42bc6d))
* add support for highlight.new ([#1487](#1487)) ([3daa5c0](3daa5c0))
* improved the UX on the feeds page and scroll behaviour ([#1506](#1506)) ([31c1593](31c1593))
* onboarding auto fetch timezone ([#1488](#1488)) ([ae5cdd7](ae5cdd7))

### 🐛 Bug Fixes

* Feed page responsiveness  ([#1490](#1490)) ([67662b2](67662b2))
* feeds page typography and styles improvements ([#1467](#1467)) ([a3b289e](a3b289e))
* on page reload Insights page redirecting to Dashboard ([#1517](#1517)) ([397c36e](397c36e))
* update environment variable for Sentry ([#1521](#1521)) ([56ac14b](56ac14b))
* update release workflow to use GitHub app for semantic versioning ([#1484](#1484)) ([3f1ce84](3f1ce84))
* update user interest logo error for machine learning ([#1474](#1474)) ([a286eda](a286eda))
* uses session to update user info for notifications check ([#1486](#1486)) ([60d787e](60d787e))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs review PRs that need review from core engineering team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor: Replace supabase typography with native paragraph
3 participants