Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
26 changes: 15 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ npx style-forge.colors

## 🎨 Supported Input Formats

| Format | Example Input | Example Output |
|--------|-------------------|--------------------------|
| `HSL` | `259 100 42` | `hsl(259, 100%, 42%)` |
| `RGB` | `120 200 255` | `rgb(120, 200, 255)` |
| `HEX` | `#FF00AA` | `#ff00aa` |
| Format | Example Input | Example Output |
|--------|---------------|-----------------------|
| `HSL` | `259 100 42` | `hsl(259, 100%, 42%)` |
| `RGB` | `120 200 255` | `rgb(120, 200, 255)` |
| `HEX` | `#FF00AA` | `#ff00aa` |

You can use any of the above formats when generating a color CSS file.
The output includes a fully scoped, theme-aware CSS module for light, dark, and auto modes.
Expand All @@ -41,12 +41,16 @@ The output includes a fully scoped, theme-aware CSS module for light, dark, and

Style-Forge Colors provides utility modifiers to fine-tune element behavior:

| Suffix | Meaning | Applies to |
|------------|--------------------------------------|----------|
| `:st` | Static. Ignores theme-based changes. | `bg`, `txt` |
| `:txt` | Text color based on contrast logic. | `txt` |
| `:txt:st` | Static text color. | `txt` |
| `:txt:rv` | Reversed text (for strong contrast). | `txt` |
| Suffix | Meaning | Applies to |
|-----------|-------------------------------------------|-------------|
| `:var` | Declares the HSL color as a CSS variable. | `universal` |
| `:st` | Static. Ignores theme-based changes. | `bg`, `txt` |
| `:txt` | Text color based on contrast logic. | `txt` |
| `:txt:st` | Static text color. | `txt` |
| `:txt:rv` | Reversed text (for strong contrast). | `txt` |
| `:bd` | Border color synced with base color. | `bd` |
| `:bd:st` | Static border color (not theme-aware). | `bd` |
| `:bd:rv` | Reversed border color for contrast. | `bd` |

> Combine them like `.sf-c-180:100:50:txt:st` for consistent control across themes.

Expand Down
9 changes: 9 additions & 0 deletions generators/styleBlocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ export function generateSingleColorCSS(H, S, L) {
// Text
lines.push(`${SELECTOR}\\:txt, ${SELECTOR}\\:txt\\:st, ${SELECTOR}\\:txt\\:rv { color: ${HSL} }`)

// Border
lines.push(`${SELECTOR}\\:bd, ${SELECTOR}\\:bd\\:st, ${SELECTOR}\\:bd\\:rv { border-color: ${HSL} }`)

lines.push('')

// dark
Expand All @@ -35,6 +38,9 @@ export function generateSingleColorCSS(H, S, L) {
lines.push(`html[data-theme='dark'] ${SELECTOR}\\:txt, html.dark ${SELECTOR}\\:txt { color: hsl(${H}, ${S}%, ${90}%) }`)
lines.push(`html[data-theme='dark'] ${SELECTOR}\\:txt\\:st, html.dark ${SELECTOR}\\:txt\\:st { color: ${HSL} }`)
lines.push(`html[data-theme='dark'] ${SELECTOR}\\:txt\\:rv, html.dark ${SELECTOR}\\:txt\\:rv { color: hsl(${H}, ${S}%, ${10}%) }`)
lines.push(`html[data-theme='dark'] ${SELECTOR}\\:bd, html.dark ${SELECTOR}\\:bd { border-color: hsl(${H}, ${S}%, ${90}%) }`)
lines.push(`html[data-theme='dark'] ${SELECTOR}\\:bd\\:st, html.dark ${SELECTOR}\\:bd\\:st { border-color: ${HSL} }`)
lines.push(`html[data-theme='dark'] ${SELECTOR}\\:bd\\:rv, html.dark ${SELECTOR}\\:bd\\:rv { border-color: hsl(${H}, ${S}%, ${10}%) }`)

lines.push('')

Expand All @@ -45,6 +51,9 @@ export function generateSingleColorCSS(H, S, L) {
lines.push(` html[data-theme='auto'] ${SELECTOR}\\:txt, html.auto ${SELECTOR}\\:txt { color: hsl(${H}, ${S}%, ${90}%) }`)
lines.push(` html[data-theme='auto'] ${SELECTOR}\\:txt\\:st, html.auto ${SELECTOR}\\:txt\\:st { color: ${HSL} }`)
lines.push(` html[data-theme='auto'] ${SELECTOR}\\:txt\\:rv, html.auto ${SELECTOR}\\:txt\\:rv { color: hsl(${H}, ${S}%, ${10}%) }`)
lines.push(` html[data-theme='auto'] ${SELECTOR}\\:bd, html.auto ${SELECTOR}\\:bd { border-color: hsl(${H}, ${S}%, ${90}%) }`)
lines.push(` html[data-theme='auto'] ${SELECTOR}\\:bd\\:st, html.auto ${SELECTOR}\\:bd\\:st { border-color: ${HSL} }`)
lines.push(` html[data-theme='auto'] ${SELECTOR}\\:bd\\:rv, html.auto ${SELECTOR}\\:bd\\:rv { border-color: hsl(${H}, ${S}%, ${10}%) }`)
lines.push(`}`)

return lines.join('\n')
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "style-forge.colors",
"version": "2025.5.16",
"version": "2025.5.18",
"description": "Style-Forge Colors: atomic HSL-based color palette generator and CSS module for scalable design systems.",
"type": "module",
"bin": {
Expand Down