Git Product home page Git Product logo

typescript-plugin-tw-template's Introduction

Deprecated!

This plugin was written at a time when the official VSCode extension didn't have support for twin.macro. Recently, it added support for custom completion contexts, which gives support for tailwind intellisense outside of the class prop, including for twin.macro.

While it doesn't warn on unknown classes at the time of writing this, everything else the extension offers (hover info, color decorators, more speed) more than makes up for it, so I strongly recommend using it instead of this. For details on how to configure with twin.macro, see this post. I'll keep this repo un-archived in case there are further updates.

typescript-plugin-tw-template

Provides editor support for tw`...` tagged template syntax, like twin.macro, including:

  • Autocomplete for tailwind classes
  • Warnings on unknown classes

Note: the classes found by this plugin may be different from those supported by twin.macro or other solutions, so you may get false warnings, or some valid classes might be missing from autocomplete. YMMV

Install

# yarn
yarn add -D typescript-plugin-tw-template tailwindcss

# npm
npm install -D typescript-plugin-tw-template tailwindcss

Usage

Add it to the "plugins" section in tsconfig.json or jsconfig.json

{
  "compilerOptions": {
    // other options...
    "plugins": [{ "name": "typescript-plugin-tw-template" }]
  }
}

The plugin will read from a custom tailwind.config.js file at the project root, or use the default config

Make sure you're using the workspace TS version! In VSCode, you can do this by opening any TS file, then click on the TS version number in the bottom right.

TODO

  • Config for custom tailwind config filename
  • Custom pragma config
  • Show CSS source for class names in autocomplete info
  • Show CSS source when hovering over class names
  • Warnings on unknown tailwind classes
  • Filter out already used class names in autocomplete
  • Unit Tests
  • Support tw prop (?)
  • Integration / e2e tests (?)
  • Support ! suffix from twin.macro
  • Autocomplete classes and variants separately (?)

typescript-plugin-tw-template's People

Contributors

itsmapleleaf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

typescript-plugin-tw-template's Issues

Example usage?

I've followed config directions but I'm not exactly sure what I'm supposed to be seeing.

I'm not getting any autocomplete on

<div css={tw`bg-NoAutoComplete`}>...</div>

Also not getting any special errors in VSCode or terminal.

<div css={tw`bg-black THROW_AN_ERROR_PLEASE`}>...</div>

Will show this (in terminal, not in VSCode hints):

$ โœ• pie was not found

But it also shows that without your plugin...

I'm somewhat new to Typescript so forgive me if it's obvious. Thank you.

All Tailwind classes unknown

For some reason all default Tailwind classes are returning warnings for unknown tailwind class.

For example:

import React from 'react';
import styled from '@emotion/styled/macro';
import tw from 'twin.macro';

const StyledApp = styled.div([
  tw`
    p-4
  `,
]);

When I hover over p-4 in VS Code, I get the warning unknown tailwind class "p-4".

Any idea why this might be happening?

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.