npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@astrogoat/tailwindcss-prose

v1.6.0

Published

Tailwind CSS plugin to help generate Strata's prose editor classes.

Downloads

40

Readme

Tailwind CSS plugin for Strata's Prose editor

Tailwind CSS plugin to help generate Strata's prose editor classes.

Usage

Add the plugin to your list of Tailwind CSS plugins.

module.exports = {
    plugins: [
        // ...
        require('@astrogoat/tailwindcss-prose')
    ],
}

Purging classes

If you're purging classes make sure to add the generated classes to you safelist. By default, all Strata Prose editor classes are prefixed with strata- by default.

module.exports = {
    plugins: [
        // ...
        require('@astrogoat/tailwindcss-prose')
    ],
    safelist: [
        { pattern: /strata-/ },
    ],
}

Exposing options

Most of the time it you want the editor to have your own set of classes as defined in your Strata PHP config file. In order for those classes to be generated correctly based on your Tailwind configuration we need to tell the plugin about which styles you want it to generate

To do this we invoke the plugin with a configuration object where you can define the prefix and the styles.

If you don't provide a set of options for a style your full Tailwind theme config while be used instead. I.e. if you don't provide a set of options for textColor, all available colors from your Tailwind config will be generated. Warning, this can make your stylesheet file unnecessary big, so it's always a good idea to limit the number of colors to be available.

module.exports = {
    plugins: [
        // ...
        require('@astrogoat/tailwindcss-prose')({
            prefix: 'my-editor',
            styles: {
                textColor: {
                    prefix: 'my-text-color',
                    options: [
                        'evergreen',
                        'sand',
                        'sand-dark',
                        'sprout',
                    ],
                },
                backgroundColor: {
                    options: [
                        'evergreen',
                        'sand',
                        'sand-dark',
                        'sprout',
                    ],
                }
            }
        })
    ],
    safelist: [
        { pattern: /my-editor-/ },
    ],
}

This will produce something like so:

.my-editor-my-text-color-evergreen{
    background-color: #00513E;
}
.my-editor-my-text-color-sand{
    background-color: #D4C4BA;
}
.my-editor-my-text-color-sand_dark{
    background-color: #CBB7AB;
}
.my-editor-my-text-color-sprout{
    background-color: #158F48;
}
.my-editor-background-color-sprout{
    background-color: #158F48;
}
.my-editor-background-color-evergreen{
    background-color: #00513E;
}
.my-editor-background-color-sand{
    background-color: #D4C4BA;
}
.my-editor-background-color-sand_dark{
    background-color: #CBB7AB;
}
.my-editor-text-size-xs{
    font-size: 0.75rem;
}
.my-editor-text-size-sm{
    font-size: 0.875rem;
}
/* ... and so on ... */

Notice the sand-dark variant example, any dashes (-) in the CSS class name will be replaced with an underscore (_).
This is a limitation of the Quill.js editor Strata is using under the hood.

.my-editor-my-text-color-sand_dark { background-color: #CBB7AB; }

Options

These are the style options that are exposed to be customized. All have an option to define the prefix for the style and the options that it should limit/generate.

Text color

module.exports = {
    styles: {
        textColor: {
            prefix: 'text-color',
            options: [
                // ...
            ],
        },
        // ...
    }
}

Background color

module.exports = {
    styles: {
        backgroundColor: {
            prefix: 'background-color',
            options: [
                // ...
            ],
        },
        // ...
    }
}

Text size

module.exports = {
    styles: {
        textSize: {
            prefix: 'text-size',
            options: [
                // ...
            ],
        },
        // ...
    }
}

Font family

module.exports = {
    styles: {
        fontFamily: {
            prefix: 'font-family',
            options: [
                // ...
            ],
        },
        // ...
    }
}

Text align

module.exports = {
    styles: {
        textAlign: {
            prefix: 'text-align',
            options: [
                // ...
            ],
        },
        // ...
    }
}

Text indent

module.exports = {
    styles: {
        textIndent: {
            prefix: 'text-indent',
            options: [
                // ...
            ],
        },
        // ...
    }
}