Git Product home page Git Product logo

wn-tailwindui-plugin's Introduction

Tailwind UI Backend Skin

Tailwind_UI_Plugin

NOTE: This plugin is in active development, and requires v1.2.3+ of Winter CMS.

Tailwind UI is a Tailwind CSS component library designed by the authors of Tailwind CSS. This is a Winter CMS plugin that provides a custom, TailwindUI-based skin for the backend.

Screenshots

Before After
stock-winter tailwind-ui-light

Dark Mode!

Dark mode and user preferences are also supported.

tailwind-ui-dark

tailwind-preferences

Getting started

Use composer to install the plugin:

composer require winter/wn-tailwindui-plugin

Then, run the migrations to ensure the plugin is enabled:

php artisan migrate

Configuration

Configuration for this plugin is handled through a configuration file. In order to modify the configuration values and get started you can either add the values to your .env environment file or copy the plugins/winter/tailwindui/config/config.php file to config/winter/tailwindui/config.php and make your changes there.

Environment File Supported Values:

  • TAILWIND_SHOW_BREAKPOINT_DEBUGGER=false

Using Tailwind in other Plugins

The following steps should be taken in order to ensure the best compatibility between plugins when using Tailwind with other plugins in the Backend:

  • Use Laravel Mix to handle compiling your plugin's Tailwind styles
  • In your tailwind.config.js file, take the following actions:
    • Extend the Winter.TailwindUI plugin's configuration rather than the default Tailwind configuration (ex: const config = require('../../winter/tailwindui/tailwind.config.js');).
    • Ensure that the Preflight Tailwind plugin is disabled (ex: config.corePlugins = {preflight: false};).
    • Set config.content to include only your plugin's paths (ex: config.content = ['./formwidgets/**/*.{vue,php,htm}', './components/**/*.{php,htm}', './assets/src/js/**/*.{js,vue}'];).
  • In your package.json file, include postcss-prefixwrap to wrap your plugin's generated styles in a plugin-specific class to prevent overriding the styles elsewhere in the backend (ex. "postcss-prefixwrap": "~1.29.x",).
  • In your winter.mix.js file, use postcss-prefixwrap when compiling the Tailwind styles (ex. mix.postCss('assets/src/css/example.css', 'assets/dist/css/example.css', [..., require('postcss-prefixwrap')('.plugin-authorname-pluginname'), ...])).

Example tailwind.config.js:

// Extend the base tailwind config to avoid conflicts
const config = require('../../winter/tailwindui/tailwind.config.js');

config.content = [
    './formwidgets/**/*.{vue,php,htm}',
    './components/**/*.{php,htm}',
    './assets/src/js/**/*.{js,vue}',
];

config.corePlugins = {
    preflight: false,
};

module.exports = config;

Example winter.mix.js:

const mix = require('laravel-mix');

mix.setPublicPath(__dirname)

    // Compile Tailwind
    .postCss(
        'assets/src/css/myplugin.css',
        'assets/dist/css/myplugin.css',
        [
            require('postcss-import'),
            require('tailwindcss/nesting'),
            require('tailwindcss'),
            require('autoprefixer'),
            require('postcss-prefixwrap')('.myauthor-pluginname', {
                // Don't prefix wrap modals because we can't put the wrapping class on a high enough parent element to apply the styles
                ignoredSelectors: ['.modal'],
            })
        ]
    );

Example package.json:

{
    "name": "myauthor-pluginname",
    "version": "0.0.1",
    "private": true,
    "version": "1.0.0",
    "devDependencies": {
        "postcss": "~8.4.x",
        "postcss-prefixwrap": "~1.29.x",
        "postcss-import": "~14.1.x",
        "tailwindcss": "~3.0.x",
        "@tailwindcss/typography": "0.5.8"
    }
}

Future Ideas

It would be ideal if it was also possible for other plugins to detect the classes that have already been generated by this plugin and prune them from their compiled styles. Pull Requests welcome to add that ability in the future if anyone has the time / motivation to do so.

Credits

This plugin was originally written by Joseph Blythe & Luke Towers for Spatial Media.

It has since been modified and re-released under the Winter namespace as a first party plugin for Winter CMS maintained by the Winter CMS team.

If you would like to contribute to this plugin's development, please feel free to submit issues or pull requests to the plugin's repository here: https://github.com/wintercms/wn-tailwindui-plugin

If you would like to support Winter CMS, please visit WinterCMS.com

wn-tailwindui-plugin's People

Contributors

luketowers avatar robertalexa avatar bennothommo avatar damsfx avatar joseph-sm avatar aic-bv avatar mjauvin avatar jaxwilko avatar josephblythe avatar josephcrowell avatar gergo85 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.