Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: rewrite the preset #24

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ temp
.vercel
docs/.vitepress/dist
docs/.vitepress/cache
.todo
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"cSpell.words": ["consts"]
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ export default defineConfig({

## Alphas

Alphas are available as extra shades in each scale. For example `bg-blue5` for solid, `bg-blue5A` for alpha.
Alphas are available as extra steps in each scale. For example `bg-blue5` for solid, `bg-blue5A` for alpha.

## Foregrounds

The optimized foreground colors are available as `-fg` shades. For example `text-blue-fg` for white `text-amber-fg` for white. These colors are based on [the Radix docs](https://www.radix-ui.com/colors/docs/palette-composition/composing-a-palette#choosing-a-brand-scale). This also works with hues and aliases.
The optimized foreground colors are available as `-fg` steps. For example `text-blue-fg` for white `text-amber-fg` for white. These colors are based on [the Radix docs](https://www.radix-ui.com/colors/docs/palette-composition/composing-a-palette#choosing-a-brand-scale). This also works with hues and aliases.

## Options

Expand Down
57 changes: 32 additions & 25 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
@@ -1,58 +1,65 @@
import { defineConfig } from "vitepress";
import { presetUno } from "unocss";
import { presetRadix, radixColors } from "../../src";
import unocss from "unocss/vite";
import { defineConfig } from 'vitepress';
import { presetUno } from 'unocss';
import { presetRadix } from '../../src';
import unocss from 'unocss/vite';
import { RADIX_HUES } from '../../src/consts';

// https://vitepress.dev/reference/site-config
export default defineConfig({
title: "unocss-preset-radix",
base: "/unocss-preset-radix/",
title: 'unocss-preset-radix',
base: '/unocss-preset-radix/',
vite: {
plugins: [
unocss({
presets: [
presetUno(),
presetRadix({
palette: radixColors,
darkSelector: ".dark",

darkSelector: '.dark',
lightSelector: ':root, .light',
aliases: {
testa: "red",
testb: "amber",
danger: 'red',
warning: 'amber',
accent: 'blue',
},
safelist: [...RADIX_HUES, 'danger', 'warning3', 'warning5A', 'warning-fg'],
}),
],
safelist: [
...radixColors.map((p) => `hue-${p}`),
...Array.from({ length: 12 }, (_, i) => `bg-hue${i + 1}`),
...Array.from({ length: 12 }, (_, i) => `bg-hue${i + 1}A`),
...['', 'A']
.map((alpha) =>
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12].map((step) => RADIX_HUES.map((hue) => `bg-${hue}${step}${alpha}`))
)
.flat()
.flat(),
...RADIX_HUES.map((h) => [`text-${h}9`, `text-${h}-fg`, `text-${h}12`, `text-${h}1`]).flat(),
],
}),
],
},
description: "A unocss preset for radix colors",
description: 'A unocss preset for radix colors',
themeConfig: {
nav: [{ text: "Home", link: "/" }],

nav: [{ text: 'Home', link: '/' }],
sidebar: [
{
text: "Guides",
text: 'Guides',
items: [
{ text: "Installation & Usage", link: "/usage" },
{ text: "Configuration", link: "/configuration" },
{ text: "Hue Utility", link: "/hues" },
{ text: 'Installation & Usage', link: '/v3/usage' },
{ text: 'Configuration', link: '/v3/configuration' },
{ text: 'Alias Utility', link: '/v3/alias-utility' },
{ text: 'Usage in CSS Variables', link: '/v3/usage-in-css-variables' },
{ text: 'Migrating from v2', link: '/v3/migrating-from-v2' },
],
},
{
text: "Other",
items: [{ text: "Colors", link: "/colors" }],
text: 'Other',
items: [{ text: 'Colors', link: '/v3/colors' }],
},
],

socialLinks: [
{
icon: "github",
link: "https://github.com/endigma/unocss-preset-radix",
icon: 'github',
link: 'https://github.com/endigma/unocss-preset-radix',
},
],
},
Expand Down
Loading