Giter VIP home page Giter VIP logo

tailwindui-crawler's Introduction

tailwindui-crawler

All Contributors

This script will crawl the tailwindui.com website and download all the components to the ./output folder.

๐Ÿ›  How to use

To install, clone this repo and run yarn or npm install to pull down the dependencies.

Then create a .env file with your email, password, and optional output folder.

EMAIL=youremail
PASSWORD=yourpassword
# OUTPUT optional, defaults to ./output
OUTPUT=/path/to/output
# LANGUAGES defaults to html
LANGUAGES=html,react,vue,alpine
# BUILDINDEX generate index file to view components offline
BUILDINDEX=(0 | 1)

NOTE: The tool uses dotenv-expand to support variable expansion like $HOME/path/to/output so if your password or any other value includes a $, make sure you add a \ (backslash) to escape the $. For example, PASSWORD=p@\$\$w0rd

Also, dotenv does not support inline comments, so do not do something like LANGUAGES=html,react,vue # some comment as it will not get the correct values.

Then finally, run yarn start or npm start

The script will login to tailwindui.com with your credentials, and download all the components as individual files in the ./output folder.

๐Ÿค” What's it for?

The benefit of pulling down all the components is that you can commit them to a local or private repo, and by running this periodically, you can see exactly which files were added or changed. Hopefully, some time in the future, they will open up a private repo for those that have purchased the library.

๐Ÿš€ New v3.0

The crawler now supports the new Tailwind UI site and can download HTML, React and Vue versions of the components.

You can also download the "alpine" version of the components. โš ๏ธ WARNING: the alpine code is NOT production ready. It does not support accesibility and is used to show a preview of how the component interactivity can be implemented.

It also adds the ability to generate an index page that emulates the tailwindui.com website so you can browse components offline.

๐Ÿ—‚ Preview page

You can set the .env key BUILDINDEX=1 to have the crawler generate an index file similar to the components page on tailwindui.com. Install and run the serve package to view the index.

NOTE: The HTML Preview does not apply transformers. It's a copy of the component site on tailwindui.com.

yarn global add serve
cd $OUTPUT/preview # change to your preview folder
serve

โš™๏ธ Example .env file

EMAIL=******
PASSWORD=******
OUTPUT=$HOME/Projects/tailwindui
LANGUAGES=html,react,vue,alpine
BUILDINDEX=1

๐Ÿค– Automatically keep a private GitHub Repository up-to-date

You can automatically keep a private GitHub repository up-to-date with component changes from TailwindUI by using this tool with GitHub Actions.

  1. Create a private GitHub repository.

  2. Add TAILWINDUI_EMAIL and TAILWINDUI_PASSWORD secrets to the GitHub repository.

  3. Optionally create a .env file with additional settings for the crawler.

  4. Create a new file .github/workflows/default.yml:

    name: Update
    on:
      schedule:
        - cron: '0 0 * * *' # Every day at midnight
    
    jobs:
      update:
        name: Update
        runs-on: ubuntu-latest
        steps:
          - name: Checkout
            uses: actions/checkout@v2
          - name: Run crawler
            uses: gregbrimble/[email protected]
            with:
              email: ${{ secrets.TAILWINDUI_EMAIL }}
              password: ${{ secrets.TAILWINDUI_PASSWORD }}

    NOTE: Make sure to update to the latest action v1.1.0 to support the crawler v3+

    Read more about the schedule cron syntax in the official GitHub Actions documentation.

    NOTE: if you're creating a new repository or have updated your default branch from master, you will have to specify with branch (and/or current_branch) like so:

    # ...
          - name: Run crawler
            uses: gregbrimble/[email protected]
            with:
              email: ${{ secrets.TAILWINDUI_EMAIL }}
              password: ${{ secrets.TAILWINDUI_PASSWORD }}
    +         branch: main
    +         current_branch: main

Email Notifications

To be emailed whenever there is a change to a component, simply setup GitHub Notifications on your repository.

๐Ÿšฆ Upgrading to v3.

This is a major change. Unfortunately, v2 will no longer work with the existing site due to the updates they may to add support for React/Vue components. Please also note that the GitHub Action has been updated from v1.0.0 to v1.1.0.

Currently, there is no support for transformers, as the need for them is not as critical since the components don't need to be converted to React or Vue.

NOTE: Since this script is essentially screen scraping, there's the potential of it breaking if the HTML structure changes. I will do my best to keep it in sync with the website.

๐Ÿ˜ Thank you

Thanks to Adam and Steve for making an amazing library. This has definitely made creating a UI for my applications a pleasant experience.

Enjoy and let me know if you have any questions.

Kiliman

Contributors โœจ

Thanks goes to these wonderful people (emoji key):


Kiliman

๐Ÿ’ป

Simon Waloschek

๐Ÿ’ป

Pavel Fomchenkov

๐Ÿ’ป

Robin Malfait

๐Ÿ’ป

Miguel Piedrafita

๐Ÿ’ป ๐Ÿ“– ๐Ÿค”

Vlad Dumitrescu

๐Ÿ“–

C-Bass

๐Ÿ’ป

Greg Brimble

๐Ÿ“– ๐Ÿ”ง

Yagnik

๐Ÿ’ป

This project follows the all-contributors specification. Contributions of any kind welcome!

tailwindui-crawler's People

Contributors

gregbrimble avatar imgbotapp avatar kiliman avatar m1guelpf avatar sonovice avatar vesper8 avatar vladdu avatar yagnik avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.