-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
47d98eb
commit c6a36ea
Showing
4 changed files
with
40 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import type { ColorSystemOptions } from './createThemeWithVars'; | ||
import createPalette from './createPalette'; | ||
import getOverlayAlpha from './getOverlayAlpha'; | ||
|
||
const defaultDarkOverlays = [...Array(25)].map((_, index) => { | ||
if (index === 0) { | ||
return undefined; | ||
} | ||
const overlay = getOverlayAlpha(index); | ||
return `linear-gradient(rgba(255 255 255 / ${overlay}), rgba(255 255 255 / ${overlay}))`; | ||
}); | ||
|
||
export function getOpacity(mode: 'light' | 'dark') { | ||
return { | ||
inputPlaceholder: mode === 'dark' ? 0.5 : 0.42, | ||
inputUnderline: mode === 'dark' ? 0.7 : 0.42, | ||
switchTrackDisabled: mode === 'dark' ? 0.2 : 0.12, | ||
switchTrack: mode === 'dark' ? 0.3 : 0.38, | ||
}; | ||
} | ||
export function getOverlays(mode: 'light' | 'dark') { | ||
return mode === 'dark' ? defaultDarkOverlays : []; | ||
} | ||
|
||
export default function createColorScheme(options: ColorSystemOptions) { | ||
const { palette = {}, opacity, overlays, ...rest } = options; | ||
return { | ||
palette: createPalette(palette), | ||
opacity: { ...getOpacity(palette.mode || 'light'), ...opacity }, | ||
overlays: overlays || getOverlays(palette.mode || 'light'), | ||
...rest, | ||
} as unknown as ColorSystemOptions; | ||
} |
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