feat: add automated CSS generation from brand.json #3

Merged
brad merged 3 commits from feature/auto-generate-css into main 2026-02-26 16:24:38 -08:00
Collaborator

Summary

Implements automatic CSS generation from brand.json as requested in #2.

What's included

  • Generation script (scripts/generate-css.js): Node.js script that transforms brand.json into comprehensive CSS
  • Forgejo Actions workflow (.forgejo/workflows/generate-brand-css.yml): Automatically regenerates CSS when brand.json changes
  • Generated CSS (brand.css): CSS custom properties, font-face declarations, typography scale, utility classes
  • Package.json: Convenience script (npm run generate:css) for local generation
  • Documentation: Updated README.md with usage instructions

CSS Features

  • CSS custom properties for all colors (hex + RGB components)
  • Font-face declarations with proper paths and font-display: swap
  • Typography scale variables (size, weight, line-height)
  • Utility classes: .text-primary, .bg-primary, .text-h1, .font-heading, etc.

Location

brand.css in repo root (co-located with brand.json for easy discovery)

Usage

<link rel="stylesheet" href="https://git.brads.house/brad/brand-guidelines/raw/branch/main/brand.css">

Closes #2

## Summary Implements automatic CSS generation from brand.json as requested in #2. ## What's included - **Generation script** (`scripts/generate-css.js`): Node.js script that transforms brand.json into comprehensive CSS - **Forgejo Actions workflow** (`.forgejo/workflows/generate-brand-css.yml`): Automatically regenerates CSS when brand.json changes - **Generated CSS** (`brand.css`): CSS custom properties, font-face declarations, typography scale, utility classes - **Package.json**: Convenience script (`npm run generate:css`) for local generation - **Documentation**: Updated README.md with usage instructions ## CSS Features - CSS custom properties for all colors (hex + RGB components) - Font-face declarations with proper paths and font-display: swap - Typography scale variables (size, weight, line-height) - Utility classes: `.text-primary`, `.bg-primary`, `.text-h1`, `.font-heading`, etc. ## Location `brand.css` in repo root (co-located with brand.json for easy discovery) ## Usage ```html <link rel="stylesheet" href="https://git.brads.house/brad/brand-guidelines/raw/branch/main/brand.css"> ``` Closes #2
- Add scripts/generate-css.js to transform brand.json into comprehensive CSS
- Add Forgejo Actions workflow to auto-generate CSS on brand.json changes
- Include CSS custom properties for colors (hex + RGB components)
- Include font-face declarations with proper paths
- Include typography scale variables
- Include utility classes for colors, typography, font families
- Add package.json with npm run generate:css script
- Update README.md with CSS generation documentation

Closes #2
brad left a comment
Owner

just a few changes

just a few changes
@ -0,0 +10,4 @@
jobs:
generate:
runs-on: ubuntu-latest
Owner

docker, not ubuntu-latest.

docker, not ubuntu-latest.
@ -0,0 +23,4 @@
node-version: '20'
- name: Generate CSS from brand.json
run: node scripts/generate-css.js
Owner

i don't want another top level directory, since this is a forgejo-CI thing i think it should be .forgejo/scripts/generate-css.js so users just see the important stuff

i don't want another top level directory, since this is a forgejo-CI thing i think it should be .forgejo/scripts/generate-css.js so users just see the important stuff
package.json Outdated
@ -0,0 +1,13 @@
{
"name": "brand-guidelines",
Owner

can this file also be moved to .forgejo? i feel like the stuff in the top level directory should be user-focused. i'm not familiar with this convention though, nodejs is not my area of expertise

can this file also be moved to .forgejo? i feel like the stuff in the top level directory should be user-focused. i'm not familiar with this convention though, nodejs is not my area of expertise
Owner

@agent the comments are

.forgejo/workflows/generate-brand-css.yml

  • docker, not ubuntu-latest.

more generally, about organizatoin:
node scripts/generate-css.js

i don't want another top level directory, since this is a forgejo-CI thing i think it should be .forgejo/scripts/generate-css.js so users just see the important stuff? same with package.json. i'm not familiar with the convention tho nodejs is not my area of expertise.

@agent the comments are .forgejo/workflows/generate-brand-css.yml - docker, not ubuntu-latest. more generally, about organizatoin: `node scripts/generate-css.js` i don't want another top level directory, since this is a forgejo-CI thing i think it should be .forgejo/scripts/generate-css.js so users just see the important stuff? same with package.json. i'm not familiar with the convention tho nodejs is not my area of expertise.
Author
Collaborator

@brad Good points on both fronts:

Runner: Will change to docker instead of ubuntu-latest.

Organization: Agree completely — CI implementation details shouldn't clutter the top level. Will move to .forgejo/scripts/generate-css.js and update the workflow path accordingly.

package.json: Since the script has zero npm dependencies (uses only Node.js stdlib), the package.json is purely for convenience scripts. Three options:

  1. Keep at root (Node.js convention) — but you're right, it's not important
  2. Move to .forgejo/ with the script (keeps all CI tooling together)
  3. Eliminate entirely (recommended) — users can run node .forgejo/scripts/generate-css.js directly if needed; CI doesn't need npm

I'd lean toward #3 — no package.json at all. The script is self-contained and the workflow just calls it directly. Thoughts?

@brad Good points on both fronts: **Runner**: Will change to `docker` instead of `ubuntu-latest`. **Organization**: Agree completely — CI implementation details shouldn't clutter the top level. Will move to `.forgejo/scripts/generate-css.js` and update the workflow path accordingly. **package.json**: Since the script has zero npm dependencies (uses only Node.js stdlib), the package.json is purely for convenience scripts. Three options: 1. Keep at root (Node.js convention) — but you're right, it's not important 2. Move to `.forgejo/` with the script (keeps all CI tooling together) 3. **Eliminate entirely** (recommended) — users can run `node .forgejo/scripts/generate-css.js` directly if needed; CI doesn't need npm I'd lean toward #3 — no package.json at all. The script is self-contained and the workflow just calls it directly. Thoughts?
Owner

@agent exactly just remove it. submit a change to this PR and i'll test it

@agent exactly just remove it. submit a change to this PR and i'll test it
- Move scripts/generate-css.js to .forgejo/scripts/generate-css.js
- Remove package.json (no npm dependencies needed)
- Update workflow to use docker runner and new script path
- Update README.md with direct node command
- Regenerate brand.css with updated header comment
Author
Collaborator

Removed package.json, moved script to .forgejo/scripts/generate-css.js, updated workflow to use docker runner, and regenerated CSS. Ready for testing.

Removed `package.json`, moved script to `.forgejo/scripts/generate-css.js`, updated workflow to use docker runner, and regenerated CSS. Ready for testing.
brad merged commit feca10e9ad into main 2026-02-26 16:24:38 -08:00
brad deleted branch feature/auto-generate-css 2026-02-26 16:24:38 -08:00
Author
Collaborator

Fixed workflow path trigger — now correctly monitors .forgejo/scripts/generate-css.js instead of the old scripts/generate-css.js location.

Fixed workflow path trigger — now correctly monitors `.forgejo/scripts/generate-css.js` instead of the old `scripts/generate-css.js` location.
Owner

@agent can you now submit this change to the downstream brad/brand-guidelines so we can test it in production there

@agent can you now submit this change to the downstream brad/brand-guidelines so we can test it in production there
Owner

@agent sorry my mistake, i meant digitech/brand

@agent sorry my mistake, i meant digitech/brand
Author
Collaborator

Got it — you want this for digitech/brand instead. Should I:

  1. Close this PR and create a new one in digitech/brand with the same approach?
  2. Adapt the implementation for digitech/brand's structure and submit there?

Let me know which direction and I'll handle it.

Got it — you want this for digitech/brand instead. Should I: 1. Close this PR and create a new one in digitech/brand with the same approach? 2. Adapt the implementation for digitech/brand's structure and submit there? Let me know which direction and I'll handle it.
Owner

@agent we need to add the script and the workflow file to digitech/brand so that this also works over there.

@agent we need to add the script and the workflow file to digitech/brand so that this also works over there.
Author
Collaborator

Done — added the script and workflow to digitech/brand.

Changes pushed to digitech/brand@main:

  • .forgejo/scripts/generate-css.js (generation script)
  • .forgejo/workflows/generate-brand-css.yml (auto-regeneration workflow)
  • brand.css (initial generated CSS)

The workflow will now automatically regenerate CSS when brand.json changes, just like in this repo.

Commit: digitech/brand@9af2032

✅ Done — added the script and workflow to digitech/brand. **Changes pushed to digitech/brand@main:** - `.forgejo/scripts/generate-css.js` (generation script) - `.forgejo/workflows/generate-brand-css.yml` (auto-regeneration workflow) - `brand.css` (initial generated CSS) The workflow will now automatically regenerate CSS when brand.json changes, just like in this repo. Commit: https://git.brads.house/digitech/brand/commit/9af2032
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
brad/brand-guidelines!3
No description provided.