Git Product home page Git Product logo

tailwindcss-color-palette-generator's Issues

Missing 950 and Divide by Zero Errors

Awesome library, thanks for sharing.

I might jump in here and fix these over the next few weeks, but no time at the moment. So just documenting for now.

  1. Tailwind classes should go 50-950, but currently hardcoded 50-900.
  2. Pure Black/White seems to fail in current library
  3. Library currently sets all colors to 500, which makes for an inconsistent palette
  4. Library seems to fail with very dark or very light colors

I'm using this library in conjunction with PHPLeague color extrator to get the dominant color from an image, then convert to a tailwind palette, which can then dynamically theme parts of a site (using this concept, similar to yours tailwindlabs/tailwindcss#12640)

I'm more or less trying to emulate https://uicolors.app/create which works exceptionally well with all colors.

I've created a few methods to auto-adjust based on HSL, and when you adjust those colors above to 900 you get the Divide By Zero errors:

generateTailwindPalette('#06104B', 900)
generateTailwindPalette('#0B0E2D', 900)

I'll create a PR when I figure it out.

PHP 8 Deprecation: Implicit conversion from float to int loses precision

Hi there,

I'm hitting the following error, when trying to run getHex() on a Color. Latest version of the package + PHP v8.0.11:

PHP Deprecated: Implicit conversion from float 0.5759627129540341 to int loses precision in A:\laragon\www\twenty-for\vendor\lukapeharda\tailwindcss-color-palette-generator\src\Color.php on line 234

Here's the method & hexcode I'm running:

$paletteGenerator = new PaletteGenerator;
$paletteGenerator->setBaseColor( Color::fromHex('007a33') );
return $paletteGenerator->getPalette();

Thanks for building this package! Handy concept, if I'm able to get it working. Let me know if there's anything else I can provide or help with, here.

$this when not in object context

Getting

Fatal error: Uncaught Error: Using $this when not in object context in /Users/jamesauble/Projects/wauble/wp-content/themes/wauble-tailwind/vendor/lukapeharda/tailwindcss-color-palette-generator/src/Color.php:85 Stack trace: #0 /Users/jamesauble/Projects/wauble/wp-content/themes/wauble-tailwind/template-parts/theme-css-vars.php(9): LukaPeharda\TailwindCssColorPaletteGenerator\Color::fromRgb(255, 255, 0) #1 /Users/jamesauble/Projects/wauble/wp-includes/template.php(772): require('/Users/jamesaub...') #2 /Users/jamesauble/Projects/wauble/wp-includes/template.php(716): load_template('/Users/jamesaub...', false, Array) #3 /Users/jamesauble/Projects/wauble/wp-includes/general-template.php(204): locate_template(Array, true, false, Array) #4 /Users/jamesauble/Projects/wauble/wp-content/themes/wauble-tailwind/template-parts/header.php(8): get_template_part('template-parts/...') #5 /Users/jamesauble/Projects/wauble/wp-includes/template.php(772): require('/Users/jamesaub...') #6 /Users/jamesauble/Projects/wauble/wp-includes/template.php(716): load_template('/Users/jamesaub...', false, Array) #7 /Users/jamesauble/Projects/wauble/wp-includes/general-template.php(204): locate_template(Array, true, false, Array) #8 /Users/jamesauble/Projects/wauble/wp-content/themes/wauble-tailwind/front-page.php(1): get_template_part('template-parts/...') #9 /Users/jamesauble/Projects/wauble/wp-includes/template-loader.php(106): include('/Users/jamesaub...') #10 /Users/jamesauble/Projects/wauble/wp-blog-header.php(19): require_once('/Users/jamesaub...') #11 /Users/jamesauble/Projects/wauble/index.php(17): require('/Users/jamesaub...') #12 {main} thrown in /Users/jamesauble/Projects/wauble/wp-content/themes/wauble-tailwind/vendor/lukapeharda/tailwindcss-color-palette-generator/src/Color.php on line 85

This some new strictness with PHP 8? I thought you couldn't use $this in a static function but I'm not very great at PHP OOP.

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.