1 | import createPalette from "./createPalette.js";
|
2 | import getOverlayAlpha from "./getOverlayAlpha.js";
|
3 | const 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 | });
|
10 | export 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 | }
|
18 | export function getOverlays(mode) {
|
19 | return mode === 'dark' ? defaultDarkOverlays : [];
|
20 | }
|
21 | export default function createColorScheme(options) {
|
22 | const {
|
23 | palette: paletteInput = {
|
24 | mode: 'light'
|
25 | },
|
26 |
|
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 |