UNPKG

1.14 kBJavaScriptView Raw
1import createPalette from "./createPalette.js";
2import getOverlayAlpha from "./getOverlayAlpha.js";
3const defaultDarkOverlays = [...Array(25)].map((_, index) => {
4 if (index === 0) {
5 return 'none';
6 }
7 const overlay = getOverlayAlpha(index);
8 return `linear-gradient(rgba(255 255 255 / ${overlay}), rgba(255 255 255 / ${overlay}))`;
9});
10export function getOpacity(mode) {
11 return {
12 inputPlaceholder: mode === 'dark' ? 0.5 : 0.42,
13 inputUnderline: mode === 'dark' ? 0.7 : 0.42,
14 switchTrackDisabled: mode === 'dark' ? 0.2 : 0.12,
15 switchTrack: mode === 'dark' ? 0.3 : 0.38
16 };
17}
18export function getOverlays(mode) {
19 return mode === 'dark' ? defaultDarkOverlays : [];
20}
21export default function createColorScheme(options) {
22 const {
23 palette: paletteInput = {
24 mode: 'light'
25 },
26 // need to cast to avoid module augmentation test
27 opacity,
28 overlays,
29 ...rest
30 } = options;
31 const palette = createPalette(paletteInput);
32 return {
33 palette,
34 opacity: {
35 ...getOpacity(palette.mode),
36 ...opacity
37 },
38 overlays: overlays || getOverlays(palette.mode),
39 ...rest
40 };
41}
\No newline at end of file