-
Notifications
You must be signed in to change notification settings - Fork 440
/
styles.js
77 lines (67 loc) · 2.06 KB
/
styles.js
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
// @flow
// Carousel
import { containerCSS } from './components/Container'
import { navigationCSS, navigationPrevCSS, navigationNextCSS } from './components/Navigation'
import { viewCSS } from './components/View'
import { headerCSS, headerCloseCSS, headerFullscreenCSS } from './components/Header'
import { footerCSS, footerCaptionCSS, footerCountCSS } from './components/Footer'
// Modal
import { blanketCSS, dialogCSS, positionerCSS } from './components/Modal/styled'
type Props = { [key: string]: any }
type StyleDef = Props => Object
export type GetStyles = (string, Props) => {}
export type CarouselStyles = {
container: StyleDef,
footer: StyleDef,
footerCaption: StyleDef,
footerCount: StyleDef,
header: StyleDef,
headerClose: StyleDef,
headerFullscreen: StyleDef,
navigation: StyleDef,
navigationPrev: StyleDef,
navigationNext: StyleDef,
view: StyleDef,
}
export type ModalStyles = {
blanket: StyleDef,
dialog: StyleDef,
positioner: StyleDef,
}
export type CarouselStylesConfig = $Shape<CarouselStyles>
export type ModalStylesConfig = $Shape<ModalStyles>
export const defaultCarouselStyles: CarouselStyles = {
container: containerCSS,
footer: footerCSS,
footerCaption: footerCaptionCSS,
footerCount: footerCountCSS,
header: headerCSS,
headerClose: headerCloseCSS,
headerFullscreen: headerFullscreenCSS,
navigation: navigationCSS,
navigationPrev: navigationPrevCSS,
navigationNext: navigationNextCSS,
view: viewCSS,
}
export const defaultModalStyles: CarouselStyles = {
blanket: blanketCSS,
dialog: dialogCSS,
positioner: positionerCSS,
}
// Merge Utility
// Allows consumers to extend a base Carousel or Modal with additional styles
export function mergeStyles(source: Object, target: Object = {}) {
// initialize with source styles
const styles = { ...source }
// massage in target styles
Object.keys(target).forEach(key => {
if (source[key]) {
styles[key] = (rsCss, props) => {
return target[key](source[key](rsCss, props), props)
}
} else {
styles[key] = target[key]
}
})
return styles
}