Code Monkey home page Code Monkey logo

tailwind-mode-aware-colors's People

Contributors

iaguirre88 avatar javierm42 avatar pretzeljohn avatar tommy-mitchell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

tailwind-mode-aware-colors's Issues

Should this work the same way with Nativewind

I really want to use this with my nativewind project. However not sure if it works or not. It just seems to default to light and doesn't switch mode when the appearance changes.

Feature request: Add support for textColor, backgroundColor, outlineColor, and borderColor

The plugin currently only supports theme.colors and extend.theme.colors, but it would be very useful to also have:

  • theme.textColor and extend.theme.textColor
  • theme.backgroundColor and extend.theme.backgroundColor
  • theme.borderColor and extend.theme.borderColor
  • theme.outlineColor and extend.theme.outlineColor

Why? So I can use text-primary instead of text-text-primary in my classnames, or bg-surface instead of bg-background-surface. It helps simplify the naming scheme when working with existing design systems. Thanks!

Media strategy outputting malformed css

Hi there,

I found a problem with Tailwinds media dark mode strategy. Whenever I try to use darkMode: 'media' together with the tailwind-mode-aware-colors plugin, it outputs a malformed css for the dark mode colors. It isn't wrapping the color vars in the html { } selector. This only happens for the media dark mode strategy, while the class strategy is working. I'm using Vite as asset bundler.

My tailwind.config.js looks like this:

const colors = require('./resources/tailwind/colors');

/** @type {import('tailwindcss').Config} */
module.exports = require('tailwind-mode-aware-colors')({
    theme: {
         colors: {
            'primary': {
                light: colors.primary['40'],
                dark: colors.primary['80'],
            },
            'on-primary': {
                light: colors.primary['100'],
                dark: colors.primary['20']
            }
            ...
        }
    }
});

The colors in the array:

module.exports = {
    primary: {
        100: '#ffffff',
        99: '#fffbff',
        98: '#fff8f3',
        95: '#ffeeda',
        ...
    },
    ...
}

And the generated css looks like this:

html {
    --color-primary: 127 86 0;
    --color-on-primary: 255 255 255;
    ...
}

@media (prefers-color-scheme: dark) {
    --color-primary: 252 187 74;
    --color-on-primary: 67 44 0;
    ...
    {}
}

While the expected css would look like this:

html {
    --color-primary: 127 86 0;
    --color-on-primary: 255 255 255;
    ...
}

@media (prefers-color-scheme: dark) {
    html {
        --color-primary: 252 187 74;
        --color-on-primary: 67 44 0;
        ...
    }
}

Doesn't support `colors` defined as a function

Defining theme.colors as a function generates an empty config.colors value ({}):

const config = {
  theme: {
    colors: ({ colors }) => ({
      black: colors.black,
      white: colors.white,
      primary: {
        light: '#bbffa3',
        dark: '#144b00'
      },
    }),
  },
};

A workaround is to import the default colors instead:

const colors = require('tailwindcss/colors')

const config = {
  theme: {
    colors: {
      black: colors.black,
      white: colors.white,
      primary: {
        light: '#bbffa3',
        dark: '#144b00'
      },
    },
  },
};

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.