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

fix(tailwind): new typography config for tailwind #914

Merged
merged 1 commit into from
Dec 4, 2024

Conversation

masoudmanson
Copy link
Contributor

@masoudmanson masoudmanson commented Dec 4, 2024

BREAKING CHANGE: Tailwind variable names have been updated, requiring refactoring to align with the new names in product teams. More info on this can be found in the ZeroHeight docs under Tailwind configuration.

Summary

Tailwind
Github issue: #913

The current design token definitions exported for Tailwind using Style Dictionary are incorrect. We need to ensure that the generated tailwind.json file adheres to the correct format and aligns with Tailwind’s configuration standards.

The new typography variables are defined in the sds tailwind.json file like so:

{
  "typography": {
    "sds-body-xxxs-400-narrow": {
      "css": {
        "fontFamily": "Inter, sans-serif",
        "fontSize": "12px",
        "fontStyle": "normal",
        "fontVariantNumeric": "normal",
        "fontWeight": "400",
        "letterSpacing": "0.1px",
        "lineHeight": "18px",
        "textTransform": "none"
      }
    }, 
    ...
  }
}

To include these typography variables in your Tailwind setup, you can import them from the sds tailwind.json file and feed them into the extend section of your tailwind.config.js file:

const sds = require("@czi-sds/components/dist/tailwind.json");
const typography = require('@tailwindcss/typography');

module.exports = {
  theme: {
    extend: {
      typography: sds.typography, // Add the imported typography variables
    },
  },
  plugins: [typography], // Ensure the typography plugin is included
};

Once the typography configuration is set up, you can apply the custom typography style in your HTML using the prose class along with the specific typography variant:

<div class="prose prose-sds-body-xxxs-400-narrow">
  <p>This text uses the custom typography style for narrow body text.</p>
</div>

Checklist

  • Default Story in Storybook
  • LivePreview Story in Storybook
  • Test Story in Storybook
  • Tests written
  • Variables from defaultTheme.ts used wherever possible
  • If updating an existing component, depreciate flag has been used where necessary
  • Chromatic build verified by @chanzuckerberg/sds-design

…phy plugin + fixed font vars

BREAKING CHANGE: More info on this can be found in the ZeroHeight docs under Tailwind configuration.
@masoudmanson masoudmanson linked an issue Dec 4, 2024 that may be closed by this pull request
@masoudmanson masoudmanson requested a review from tihuan December 4, 2024 19:32
@masoudmanson masoudmanson self-assigned this Dec 4, 2024
@masoudmanson masoudmanson added Bug Something isn't working P0 Ready for review This PR is ready for review labels Dec 4, 2024
Copy link
Contributor

@tihuan tihuan left a comment

Choose a reason for hiding this comment

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

LGTM!! Let's gooo! 🚀 😆

Copy link
Contributor

@codemonkey800 codemonkey800 left a comment

Choose a reason for hiding this comment

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

🔥 🔥 🔥

@masoudmanson masoudmanson added Ready for release This PR is ready for release and removed Ready for review This PR is ready for review labels Dec 4, 2024
@masoudmanson masoudmanson merged commit cc895e8 into main Dec 4, 2024
11 checks passed
@masoudmanson masoudmanson deleted the 913-fix-tailwind-design-token-variables branch December 4, 2024 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working P0 Ready for release This PR is ready for release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix tailwind design token variables
3 participants