Git Product home page Git Product logo

twd's Introduction

twd v0.4.8

ci

Simple tailwind like CLI tool for deno ๐Ÿฆ•

This tool uses twind internally.

Install

deno install --allow-read=. --allow-write=. --allow-net=deno.land,esm.sh,cdn.esm.sh -fq https://deno.land/x/[email protected]/cli.ts

Usage

Call twd command with input html files.

twd input.html

This outputs the tailwind compatible stylesheet which is needed by the input file.

You can specify more than 1 input file.

twd input-foo.html input-bar.html

This outputs the stylesheet for both input-foo.html and input-bar.html.

Or you can input the files under the directory by specifying the directory.

twd dir/

Watch files

You can watch files with -w, --watch option.

twd -w input-a.html input-b.html -o styles.css

When you use -w option, you also need to specify -o, --output option, which specifies the output file for generated styles.

Config

You can configure the output styles through config file 'twd.ts'.

You can create the boilerplate code with -i (--init) option.

$ twd -i
Creating config file 'twd.ts'
Done!

This creates the config file 'twd.ts' like the below:

import { Config } from "https://deno.land/x/[email protected]/types.ts";

export const config: Config = {
  preflight: true,
  theme: {},
  plugins: {},
};

Theme

Theming works almost the same way as theming in tailwind, or theming in twind.

The example of overriding values in the theme:

import { Config } from "https://deno.land/x/[email protected]/types.ts";

export const config: Config = {
  preflight: true,
  theme: {
    fontFamily: {
      sans: ["Helvetica", "sans-serif"],
      serif: ["Times", "serif"],
    },
    extend: {
      spacing: {
        128: "32rem",
        144: "36rem",
      },
    },
  },
};

Colors

The Tailwind v2 compatible color palette is available from https://deno.land/x/[email protected]/colors.ts.

import { Config } from "https://deno.land/x/[email protected]/types.ts";
import * as colors from "https://deno.land/x/[email protected]/colors.ts";

export const config: Config = {
  theme: {
    colors: {
      // Build your palette here
      gray: colors.trueGray,
      red: colors.red,
      blue: colors.lightBlue,
      yellow: colors.amber,
    },
  },
};

To extend the existing color palette use theme.extend:

import { Config } from "https://deno.land/x/[email protected]/types.ts";
import * as colors from "https://deno.land/x/[email protected]/colors.ts";

export const config: Config = {
  theme: {
    extend: {
      colors: {
        gray: colors.trueGray,
      },
    },
  },
};

Preflight

twd automatically provides reset stylesheet, modern-normalize, in the same way as tailwind or twind. By default twd inserts these styles at the beginning of the other styles.

This behavior can be disabled by preflight option in 'twd.ts' config file.

import { Config } from "https://deno.land/x/[email protected]/types.ts";

export const config: Config = {
  preflight: false,
};

Plugins

You can provide plugins in config file. Plugins are not tailwind compatible, but it follows the rules of twind plugins.

In twd.ts:

export config: Config = {
  plugins: {
    'scroll-snap': (parts) => ({ 'scroll-snap-type': parts[0] }),
  },
};

This generates the style .scroll-snap-x { scroll-snap-type: x; } in the output. See more details in twind plugin docs about what kind of plugins are possible.

TODOs

  • Expose APIs like generate(files, opts), watch(files, opts) to enable easily integrate this tool into another tool.

License

MIT

twd's People

Contributors

kt3k avatar satyarohith 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

Watchers

 avatar  avatar

Forkers

muskanmahajan37

twd's Issues

Install cli error on Deno 1.12

kyle@kyle-XPS-15-9560:~/Projects/deno/tailwinds-example$ deno --version
deno 1.12.2 (release, x86_64-unknown-linux-gnu)
v8 9.2.230.14
typescript 4.3.5
kyle@kyle-XPS-15-9560:~/Projects/deno/tailwinds-example$ deno install --allow-read=. --allow-write=. --allow-net=deno.land,esm.sh,cdn.esm.sh -fq https://deno.land/x/[email protected]/cli.ts
error: TS2345 [ERROR]: Argument of type '(path: string | URL, options?: ReadFileOptions | undefined) => Promise<string>' is not assignable to parameter of type '(value: string, index: number, array: string[]) => Promise<string>'.
  Types of parameters 'options' and 'index' are incompatible.
    Type 'number' is not assignable to type 'ReadFileOptions | undefined'.
    await Promise.all(files.map(Deno.readTextFile)),
                                ~~~~~~~~~~~~~~~~~
    at https://deno.land/x/[email protected]/cli.ts:163:33
kyle@kyle-XPS-15-9560:~/Projects/deno/tailwinds-example$ 

I was able to get it to work by downgrading deno to 1.11.5

kyle@kyle-XPS-15-9560:~/Projects/deno/tailwinds-example$ deno --versiondeno 1.11.5 (release, x86_64-unknown-linux-gnu)
v8 9.1.269.35
typescript 4.3.2
kyle@kyle-XPS-15-9560:~/Projects/deno/tailwinds-example$ deno install --allow-read=. --allow-write=. --allow-net=deno.land,esm.sh,cdn.esm.sh -fq https://deno.land/x/[email protected]/cli.ts
โœ… Successfully installed twd
/home/kyle/.deno/bin/twd
kyle@kyle-XPS-15-9560:~/Projects/deno/tailwinds-example$ 

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.