-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added dark/light theme switching support to AddressInput and AmountIn…
…put components using @radix-ui/colors and Tailwind.
- Loading branch information
Showing
5 changed files
with
66 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,56 @@ | ||
import { | ||
blue, | ||
blueDark, | ||
red, | ||
redDark, | ||
slate, | ||
slateDark, | ||
} from '@radix-ui/colors' | ||
|
||
/** | ||
* Convert keys of the given object from "slate1" to "slateDark1". | ||
* | ||
* @param {object} obj | ||
* @param {string} colorName | ||
* @returns | ||
*/ | ||
const prefixDarkColors = (obj, colorName) => { | ||
return Object.entries(obj).reduce((acc, [key, value]) => { | ||
// Extract just the number from the key | ||
const numberKey = key.replace(/^[a-zA-Z]+/, '') | ||
acc[`${colorName}Dark${numberKey}`] = value | ||
return acc | ||
}, {}) | ||
} | ||
|
||
/** @type {import('tailwindcss').Config} */ | ||
module.exports = { | ||
content: [ | ||
"./src/**/*.{ts,tsx}", | ||
// Support multiple approaches for switching between light and dark mode. | ||
darkMode: [ | ||
'variant', | ||
[ | ||
'@media (prefers-color-scheme: dark) { &:not(.light *) }', | ||
'&:is(.dark *)', | ||
], | ||
], | ||
content: ['./src/**/*.{ts,tsx}'], | ||
theme: { | ||
extend: {}, | ||
extend: { | ||
colors: { | ||
...slate, | ||
...blue, | ||
...red, | ||
...prefixDarkColors(slateDark, 'slate'), | ||
...prefixDarkColors(blueDark, 'blue'), | ||
...prefixDarkColors(redDark, 'red'), | ||
}, | ||
}, | ||
}, | ||
plugins: [], | ||
corePlugins: { | ||
preflight: false, | ||
}, | ||
experimental: { | ||
optimizeUniversalDefaults: true, | ||
} | ||
}, | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.