-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Expand file tree
/
Copy pathcustomComponents.js
More file actions
49 lines (46 loc) · 1.25 KB
/
Copy pathcustomComponents.js
File metadata and controls
49 lines (46 loc) · 1.25 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
import React from 'react'
import { action } from '@storybook/react'
const customComponents = {
dateCellWrapper: dateCellWrapperProps => {
// Show 'click me' text in arbitrary places by using the range prop
const hasAlert = dateCellWrapperProps.range
? dateCellWrapperProps.range.some(date => {
return date.getDate() % 12 === 0
})
: false
const style = {
display: 'flex',
flex: 1,
borderLeft: '1px solid #DDD',
backgroundColor: hasAlert ? '#f5f5dc' : '#fff',
}
return (
<div style={style}>
{hasAlert && (
<a onClick={action('custom dateCellWrapper component clicked')}>
Click me
</a>
)}
{dateCellWrapperProps.children}
</div>
)
},
dayWrapper: dayWrapperProps => {
// Show different styles at arbitrary time
const hasCustomInfo = dayWrapperProps.value
? dayWrapperProps.value.getHours() === 4
: false
const style = {
display: 'flex',
flex: 1,
backgroundColor: hasCustomInfo ? '#f5f5dc' : '#fff',
}
return (
<div style={style}>
{hasCustomInfo && 'Custom Day Wrapper'}
{dayWrapperProps.children}
</div>
)
},
}
export default customComponents