mirror of
https://github.com/supabase/supabase.git
synced 2026-10-17 23:29:08 +03:00
* new packages * new transforms * Update package.json * new internal files * Update cleanse-css-for-tailwind.js * updated css files * remove old code * update tokens * Delete global.css * update themes * Update tailwind-theming.md * Update tailwind-theming.md * Update tailwind-theming.md * Update tailwind-theming.md * Update tailwind-theming.md * Update tailwind-theming.md --------- Co-authored-by: Francesco Sansalvadore <f.sansalvadore@gmail.com>
42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
const glob = require('glob')
|
|
const fs = require('fs')
|
|
|
|
const cssFiles = glob.sync('build/css/**/*.css')
|
|
|
|
function transformCssFiles(precision) {
|
|
cssFiles.forEach((file) => {
|
|
const css = fs.readFileSync(file, 'utf8')
|
|
|
|
let transformedCss = css
|
|
|
|
// transform hsl values to degrees, percentages
|
|
transformedCss = transformedCss.replace(
|
|
/hsl\(([\d.]+)[,\s]+([\d.]+)%[,\s]+([\d.]+)%\)/g,
|
|
(match, hue, saturation, lightness) => {
|
|
hue = `${roundNumber(hue, precision)}deg`
|
|
saturation = `${roundNumber(saturation, precision)}%`
|
|
lightness = `${roundNumber(lightness, precision)}%`
|
|
return `${hue} ${saturation} ${lightness}`
|
|
}
|
|
)
|
|
|
|
// remove --core prefix from files
|
|
transformedCss = transformedCss.replace(/--core-/g, '--')
|
|
|
|
fs.writeFileSync(file, transformedCss)
|
|
})
|
|
|
|
function roundNumber(number, precision) {
|
|
const rounded = parseFloat(number).toFixed(precision)
|
|
const str = rounded.toString()
|
|
const match = str.match(/^(\d+)\.(\d+)$/)
|
|
if (match && match[2] === '0'.repeat(match[2].length)) {
|
|
return match[1]
|
|
}
|
|
return rounded
|
|
}
|
|
}
|
|
|
|
// Example usage:
|
|
transformCssFiles(1)
|