mirror of
https://github.com/supabase/supabase.git
synced 2026-10-07 18:35:07 +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>
46 lines
1.7 KiB
JavaScript
46 lines
1.7 KiB
JavaScript
const formattedVariables = require('./formattedVariables')
|
|
const fileHeader = require('./fileHeader')
|
|
|
|
const filteredTokens = (dictionary, filterFn) => {
|
|
const filtered = dictionary.allTokens.filter(token => filterFn(token))
|
|
return {
|
|
...dictionary,
|
|
...{
|
|
allProperties: filtered,
|
|
allTokens: filtered
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = ({ dictionary, options, file }) => {
|
|
const opts = options ?? {}
|
|
const { outputReferences } = opts
|
|
const groupedTokens = {
|
|
// if you export the prefixes use token.path[0] instead of [1]
|
|
light: filteredTokens(dictionary, (token) => token.path[1].toLowerCase() === 'light'),
|
|
dark: filteredTokens(dictionary, (token) => token.path[1].toLowerCase() === 'dark'),
|
|
rest: filteredTokens(dictionary, (token) => !['light', 'dark'].includes(token.path[1].toLowerCase()))
|
|
}
|
|
|
|
return (
|
|
fileHeader({ file }) +
|
|
':root {\n' +
|
|
formattedVariables({ format: 'css', dictionary: groupedTokens.rest, outputReferences }) +
|
|
'\n}\n\n' +
|
|
'@media (prefers-color-scheme: light) {\n' +
|
|
' :root {\n' +
|
|
formattedVariables({ format: 'css', dictionary: groupedTokens.light, outputReferences }) +
|
|
'\n }\n}\n\n' +
|
|
'@media (prefers-color-scheme: dark) {\n' +
|
|
' :root {\n' +
|
|
formattedVariables({ format: 'css', dictionary: groupedTokens.dark, outputReferences }) +
|
|
'\n }\n}\n\n' +
|
|
'html[data-theme="light"] {\n' +
|
|
formattedVariables({ format: 'css', dictionary: groupedTokens.light, outputReferences }) +
|
|
'\n}\n\n' +
|
|
'html[data-theme="dark"] {\n' +
|
|
formattedVariables({ format: 'css', dictionary: groupedTokens.dark, outputReferences }) +
|
|
'\n}\n'
|
|
)
|
|
}
|