forked from reformcollective/library
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefaultConfig.ts
More file actions
66 lines (63 loc) · 1.92 KB
/
Copy pathdefaultConfig.ts
File metadata and controls
66 lines (63 loc) · 1.92 KB
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
/**
* config schema and config defaults for the reform util library
* see libraryConfig.ts for the actual config
*/
type Config<TransitionNames = never, GroupNames = never> = {
/**
* if true, the fresponsive util will scale on fullWidth breakpoints
*/
scaleFully: boolean
/**
* should the page preserve the scroll position when reloading or when clicking back/forward
*/
scrollRestoration: boolean
/**
* should anchor names be saved to the URL? when e.g. scrolling to a section
*/
saveAnchorNames: boolean
/**
* transition names, if applicable
*/
transitionNames: TransitionNames[]
/**
* choose between a tablet breakpoint or a large mobile breakpoint
*/
tabletBreakpoint: "tablet" | "largeMobile"
/**
* page section group names for sanity studio, if applicable
* this is only used for autocomplete & checking during development
*/
pageSectionGroups: GroupNames[]
/**
* styling system to use
*/
stylingSystem: "vanilla" | "restyle" | "both"
/**
* for the vanilla extract styling system, which engine to use
* "calc" will wrap each px value in a calc() function that calculates the value based on breakpoints
* "media" will wrap entire statements in a media query based on breakpoints
*/
vanillaExtractEngine: "calc" | "media"
/**
* if true, override any preloader resolvers that have already been registered
* in most cases you won't want to use this
*/
overridePreloaderResolvers?: boolean
}
const defaultConfig = {
scaleFully: false,
scrollRestoration: true,
saveAnchorNames: true,
transitionNames: [],
tabletBreakpoint: "tablet",
pageSectionGroups: [],
stylingSystem: "both",
vanillaExtractEngine: "calc",
overridePreloaderResolvers: false,
} as const satisfies Config
export const defineLibraryConfig = <const TransitionNames, const GroupNames>(
config: Partial<Config<TransitionNames, GroupNames>>,
): Config<TransitionNames, GroupNames> => ({
...defaultConfig,
...config,
})