Skip to content

Commit

Permalink
Update Themer and Conic to use local TW default colors
Browse files Browse the repository at this point in the history
  • Loading branch information
endigo9740 committed Oct 11, 2022
1 parent 8ebdd6e commit 8d1f27f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/docs/DocsThemer/DocsThemer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// Helpers
import { getTailwindColor, randomTailwindColor, genHexPalette, generateThemeCss } from './helpers';
import { colorsTailwind } from './colors';
import { tailwindDefaultColors } from '$lib/tailwind/colors';
// Local
const regexValidHexCode = new RegExp(/^#[0-9a-f]{6}$/i);
Expand Down Expand Up @@ -167,7 +167,7 @@
<span class="text-white capitalize">{colorKey}</span>
{#if $storeMode}
<select class="capitalize" bind:value={$storeTailwindForm[colorKey]} on:change={()=>{onTailwindSelect()}}>
{#each colorsTailwind as c}<option value={c.label}>{c.label}</option>{/each}
{#each tailwindDefaultColors as c}<option value={c.label}>{c.label}</option>{/each}
</select>
{:else}
<input
Expand Down
6 changes: 3 additions & 3 deletions src/docs/DocsThemer/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

// @ts-ignore
import paletteGenerator from '@bobthered/tailwindcss-palette-generator';
import { colorsTailwind } from './colors';
import { tailwindDefaultColors } from '../../lib/tailwind/colors';

// Talwind: Get a Particular Color
export function getTailwindColor(colorName: string): any {
return colorsTailwind.find((c) => c.label === colorName);
return tailwindDefaultColors.find((c) => c.label === colorName);
}

// Tailwind: Pick Random Color
export function randomTailwindColor(): any {
return colorsTailwind[(Math.random() * colorsTailwind.length) | 0];
return tailwindDefaultColors[(Math.random() * tailwindDefaultColors.length) | 0];
}

// Hex: Source: https://github.com/bobthered/tailwindcss-palette-generator
Expand Down
13 changes: 3 additions & 10 deletions src/lib/components/ConicGradient/ConicGradient.svelte
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
<!--
https://developer.mozilla.org/en-US/docs/Web/CSS/gradient/conic-gradient
https://www.sitepoint.com/create-css-conic-gradients-pie-charts/
https://css-tricks.com/radial-gradient-recipes/
https://tailwindcss.com/docs/configuration#referencing-in-java-script
-->
<script lang="ts">
import tailwindColors from 'tailwindcss/colors';
import { tailwindDefaultColors } from '$lib/tailwind/colors';
import type { ConicStop } from './types';
// Props
Expand All @@ -32,8 +25,8 @@
// If string, keep as is
if (typeof color === 'string') return color;
// If object, provide default Tailwind color
const tw: any = tailwindColors;
return tw[color[0]][color[1]];
const colorSet = tailwindDefaultColors.find((c) => c.label === color[0]);
return colorSet.shades[color[1]].hex;
}
// Generate Conic Gradient style
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// https://tailwindcss.com/docs/customizing-colors#default-color-palette

export const colorsTailwind: any[] = [
export const tailwindDefaultColors: any[] = [
{
label: 'slate',
shades: {
Expand Down

0 comments on commit 8d1f27f

Please sign in to comment.