New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

styled2tailwind

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

styled2tailwind

Styled2Tailwind 🌀 Transform your Styled-Components into TailwindCSS with this handy codemod.

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
5
-44.44%
Maintainers
1
Weekly downloads
 
Created
Source

Styled2Tailwind 🌀

Transform your Styled-Components into TailwindCSS with this handy codemod.


Example of conversion using styled2tailwind
npm version badge npm bundle size license badge GitHub Workflow Status (with event)

🌟 Motivation

With Next.js introducing the new App Directory routing, it also introduced support for Server and Client components. Styled-components don't gel well with server components due to their heavy reliance on the JS runtime. Tailwind, on the other hand, slides right in and performs beautifully!

We also love Tailwind and we believe it enhances the development process, making it faster with a superior developer experience.

🚀 Getting Started

  • Begin by giving the repository a star! ⭐
  • Type the following command to dive into the CLI world:
$ npx styled2tailwind --help

🤔 How It Works

Our mechanism runs in four distinct steps:

  • Raw Input: We start by taking the RAW React Component as input (make sure it includes some styled components).
  • JavaScript AST: Convert the component to JavaScript AST using Babel.
  • From AST to CSS: Extract all TemplateLiterals data from the AST and morph it into CSS.
  • Tailwind Conversion: The final leg involves converting this CSS into TailwindCSS format.
flowchart LR
  RSI(Raw Styled Input) --> JSAST(JavaScript AST)
  JSAST --> RCSS(Raw CSS)
  RCSS --> TW(Tailwind CSS)

📋 Commands Overview

CommandDescription
styled2tailwind --helpDisplays help command.
styled2tailwind "src/*.jsx"Parses all .jsx files inside src directory (supports regex).
styled2tailwind "src/*.jsx" --no-replaceInstead of replacing styled components with tailwind, it appends the tailwind output at the end of the file.
styled2tailwind "src/*.jsx" --no-conflictsForcefully replaces styled components with tailwind in the markup without using git conflicts.

⚠️ Limitations

This project is still in early beta, we already tracked some limitations and we will ship fix for those in very near future!

  • Multi-Line Components: CLI can act mysteriously while one component is wrapped into multiple lines.
  • Dynamic React Props: Handling dynamic React props (especially functions) still poses a challenge.

🤝 Contribution

Contributions are always welcome! To contribute, please follow these steps:

  • Fork the repository.
  • Create a new branch with a descriptive name.
  • Make your changes, and commit them using the Conventional Commits format.
  • Push your changes to the forked repository.
  • Create a pull request, and we'll review your changes.

🫶 Support

If you're looking for help or simply want to share your thoughts about the project, we encourage you to join our Discord community. Here's the link: https://blazity.com/discord. It's a space where we exchange ideas and help one another. Everyone's input is appreciated, and we look forward to welcoming you.

📜 License

This project is licensed under the MIT License. For more information, see the LICENSE file.

FAQs

Package last updated on 10 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts