Giter Site home page Giter Site logo

atomico-tailwindcss's Introduction

Atomico + Tailwindcss + Estack

I've created @uppercod/postcss-import for Postcss that allows to point to selectors of an import to compose new CSS, I've tried it with Atomico + Tailwindcss and the result is pleasantly small.

Atomico is an amazing library of only 2.9KB for creating webcomponents just using functions.

webcomponent

import { c } from "atomico";
import html from "atomico/html";
import style from "./t-button.css";

function button({ elevated, disabled, outline, roundedFull }) {
  const cn = ["btn"];
  if (elevated) cn.push("elevated");
  if (disabled) cn.push("disabled");
  if (outline) cn.push("disabled");
  if (roundedFull) cn.push("rounded-full");
  return html`<host shadowDom>
    <style>
      ${style}
    </style>
    <button class=${cn.join(" ")}><slot></slot></button>
  </host>`;
}

button.props = {
  rounded: Boolean,
  disabled: Boolean,
  elevated: Boolean,
  roundedFull: Boolean,
};

customElements.define("t-button", c(button));

style

@import "https://unpkg.com/[email protected]/dist/tailwind.css" (as: T);

.btn {
  @extend T"button",
    T.bg-blue-500,
    T.text-white,
    T.font-bold,
    T.py-2,
    T.px-4,
    T.rounded;
  border: none;
}

.btn:hover {
  @extend T.hover\:bg-blue-700:hover;
}

.rounded-full {
  @extend T.rounded-full;
}

.disabled {
  @extend T.opacity-50, T.cursor-not-allowed;
}
.elevated {
  @extend T.shadow;
}

atomico-tailwindcss's People

Contributors

uppercod 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.