-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.mjs
92 lines (86 loc) · 2.67 KB
/
index.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import defaultTheme from "tailwindcss/defaultTheme";
import typography from "./typography.mjs";
import containerQueriesPlugin from "@tailwindcss/container-queries";
import typographyPlugin from "@tailwindcss/typography";
import utopiaPlugin from "@domchristie/tailwind-utopia";
import { merge } from "ts-deepmerge";
import {
ClipPathUtilities,
ColorScheme,
Combinators,
ContentDimensions,
Dynamic,
ExtendTheme,
Font,
Hocus,
LightMode,
NotDisabled,
NotEmpty,
OkLCH,
QuantityQueries,
SafeArea,
Scrollbar,
SpacingUtilities,
TextShadow,
} from "./Plugins/index.mjs";
const defaultPluginSettings = {
sliderContentDimensionAddedValue: 160,
contentDimensions: {
gap: defaultTheme.spacing["20"],
content: "56rem",
wide: defaultTheme.screens.xl,
},
oklch: {
precision: 6,
},
};
export default function config({ pluginSettings, theme, corePlugins } = {}) {
// Merge default settings with custom settings
theme = merge({ extend: { ...ExtendTheme, typography } }, theme || {});
pluginSettings = merge(defaultPluginSettings, pluginSettings || {});
corePlugins = corePlugins || {};
const setSliderContentDimensions = (key) => {
const sliderKey = `${key}Slider`;
if (pluginSettings.contentDimensions[sliderKey]) {
return;
}
const isPx = pluginSettings.contentDimensions[key].endsWith("px");
const isRem = pluginSettings.contentDimensions[key].endsWith("rem");
if (!isPx && !isRem) {
throw new Error(`The value of ${key} must be in px or rem`);
}
const rootValue = parseInt(pluginSettings.contentDimensions[key]);
const addValue = pluginSettings.sliderContentDimensionAddedValue / (isPx ? 1 : 16);
const unit = isPx ? "px" : "rem";
pluginSettings.contentDimensions[sliderKey] = rootValue + addValue + unit;
};
setSliderContentDimensions("content");
setSliderContentDimensions("wide");
/** @type {import('tailwindcss').Config} */
return {
darkMode: "class",
theme,
plugins: [
utopiaPlugin,
OkLCH(pluginSettings.oklch),
containerQueriesPlugin,
typographyPlugin,
ClipPathUtilities,
ColorScheme,
Combinators,
ContentDimensions(pluginSettings.contentDimensions),
Dynamic,
Font,
Hocus,
LightMode,
NotDisabled,
NotEmpty,
QuantityQueries,
SafeArea,
Scrollbar,
SpacingUtilities,
TextShadow,
],
corePlugins,
};
}