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

Add primitives.css index file #961

Merged
merged 2 commits into from
May 30, 2024
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
5 changes: 5 additions & 0 deletions .changeset/short-pots-look.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/primitives": patch
---

Add `primitives.css` index file
29 changes: 29 additions & 0 deletions scripts/buildTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {ConfigGeneratorOptions, StyleDictionaryConfigGenerator} from '../sr
import type {TokenBuildInput} from '../src/types/TokenBuildInput'
import glob from 'fast-glob'
import {themes} from './themes.config'
import fs from 'fs'

/**
* getStyleDictionaryConfig
Expand Down Expand Up @@ -212,6 +213,34 @@ export const buildDesignTokens = (buildOptions: ConfigGeneratorOptions): void =>
* Copy `removed` files
* ----------------------------------- */
copyFromDir(`src/tokens/removed`, `${buildOptions.buildPath}removed`)

const excludePaths = [
(path: string) => {
return path === 'dist/css/functional/size/viewport.css'
},
(path: string) => {
return path.startsWith('dist/css/functional/themes/')
},
]

const all: string[] = []

for (const cssFile of glob.sync('dist/css/{base,functional}/**/*.css')) {
let skip = false

for (const matcher of excludePaths) {
if (matcher(cssFile)) {
skip = true
break
}
}

if (skip) continue

all.push(fs.readFileSync(cssFile, {encoding: 'utf8'}).trim())
}

fs.writeFileSync('dist/css/primitives.css', `${all.join('\n')}\n`)
}

/** -----------------------------------
Expand Down