Skip to content
This repository was archived by the owner on Jun 23, 2023. It is now read-only.

Commit 63f9b4a

Browse files
staydecentadriaanwm
authored andcommitted
Sync with winston (#6)
* Update server file. * Update utils/components with changes made in Winston. Improve some existing components, and adds new. * Fix linting. * Add missing util for pagination. * Remove React Date Picker from forms. * Fix withState references.
1 parent 10a1bac commit 63f9b4a

File tree

34 files changed

+1000
-134
lines changed

34 files changed

+1000
-134
lines changed

app/assets/images/loader.svg

Lines changed: 49 additions & 0 deletions
Loading

app/components/elements/carousel/base.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
import {map} from 'wasmuth'
22

3+
import Link from '/components/elements/link'
4+
35
export default function render ({
46
active,
57
prev,
68
next,
79
className = 'carousel-slide',
810
getRef,
911
getStyle,
12+
wrapperClass,
1013
children
1114
}) {
12-
return <div className='carousel-block carousel'>
15+
return <div className={`carousel-block carousel ${wrapperClass}`}>
1316
<div className='card-carousel-content row'>
14-
<nav>
15-
<a onClick={prev} href='#' className='carousel-btn left'>&nbsp;</a>
17+
<nav className='nav prev'>
18+
<Link to={prev} />
1619
</nav>
1720
<div className='slides'>
1821
{map((c, idx) =>
@@ -23,8 +26,8 @@ export default function render ({
2326
>{c}</div>
2427
, children)}
2528
</div>
26-
<nav>
27-
<a onClick={next} href='#' className='carousel-btn right'>&nbsp;</a>
29+
<nav className='nav next'>
30+
<Link to={next} />
2831
</nav>
2932
</div>
3033
</div>

app/components/elements/carousel/index.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ function init () {
1414
)
1515
}
1616

17-
function componentDidMount () {
18-
window.requestAnimationFrame(() =>
19-
this.setState({...this.state, width: this.ref.offsetWidth})
20-
)
21-
}
22-
2317
function next (ev) {
2418
ev.preventDefault()
2519
const n = this.state.active >= this.props.children.length - 1
@@ -37,8 +31,11 @@ function prev (ev) {
3731
}
3832

3933
function getRef (ref) {
40-
if (!ref) return
34+
if (!ref || this.ref) return
4135
this.ref = ref
36+
window.requestAnimationFrame(() =>
37+
this.setState({...this.state, width: this.ref.offsetWidth})
38+
)
4239
}
4340

4441
function getStyle (idx, active) {
@@ -51,7 +48,6 @@ function getStyle (idx, active) {
5148

5249
export default compose(setNodeName('Carousel'), {
5350
init,
54-
componentDidMount,
5551
next,
5652
prev,
5753
getRef,

app/components/elements/dropdown/base.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function BaseDropdown ({
1919
? <button className='btn btn-dropdown black-ghost-btn' onClick={handleClick}>
2020
<Level noPadding>{buttonText} <DownArrow /></Level>
2121
</button>
22-
: <Trigger className='btn btn-dropdown' onClick={handleClick} />}
22+
: <Trigger className='btn-dropdown' onClick={handleClick} />}
2323
{noWrapper
2424
? isOpen && children
2525
: <div className={cls}>

app/components/elements/dropdown/index.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
set,
55
dispatch,
66
getState,
7-
mapStateToProps
7+
withState
88
} from '/store'
99

1010
import BaseDropdown from './base'
@@ -32,18 +32,22 @@ document.body.addEventListener('click', (ev) => {
3232
dispatch(set(['dropdowns'], {}))
3333
})
3434

35-
export default mapStateToProps(
36-
({dropdowns}, {uid, ...props}) => {
35+
export default withState(
36+
({dropdowns}, {uid}) => {
3737
if (!uid) {
3838
console.warn('<Dropdown> must include a uid prop.')
3939
}
4040
return {
41-
uid,
4241
isOpen: !!dropdowns[uid],
43-
handleClick: (ev) =>
44-
ev.preventDefault() ||
45-
dispatch(set(['dropdowns', uid], !dropdowns[uid])),
46-
...props
42+
dropdowns
4743
}
4844
}
49-
)(BaseDropdown)
45+
)(({isOpen, dropdowns, uid, ...props}) =>
46+
BaseDropdown({
47+
...props,
48+
isOpen,
49+
handleClick: (ev) =>
50+
ev.preventDefault() ||
51+
dispatch(set(['dropdowns', uid], !dropdowns[uid]))
52+
})
53+
)

0 commit comments

Comments
 (0)