Skip to content

Commit 2bf3433

Browse files
committed
show fade edges for scrollable areas (closes #34)
1 parent e28b589 commit 2bf3433

File tree

6 files changed

+93
-4
lines changed

6 files changed

+93
-4
lines changed

packages/client/src/components/FeedBox/Body/Tabs/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import classNames from 'classnames'
44
import Tabs, { TabPane } from 'rc-tabs'
55
import TabContent from 'rc-tabs/lib/TabContent'
66
import ScrollableTabBar from 'rc-tabs/lib/ScrollableTabBar'
7-
import Scrollbar from 'react-custom-scrollbars'
87
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
98
import { faExclamationTriangle, faSync } from '@fortawesome/free-solid-svg-icons'
109
import 'rc-tabs/assets/index.css'
1110

1211
import { feedBoxType, feedType } from 'newsdash/components/propTypes'
1312
import { FEED_STATUS } from 'newsdash/constants'
13+
import Scrollbar from 'newsdash/components/Scrollbar'
1414
import Feed from 'newsdash/components/Feed'
1515
import css from './Tabs.sss'
1616

@@ -63,7 +63,7 @@ const FeedTabs = ({
6363
)
6464
return (
6565
<TabPane key={feed.id.toString()} tab={tabContent}>
66-
<Scrollbar autoHide>
66+
<Scrollbar bgColor={feedBox.colors.bg}>
6767
<Feed feed={feed} />
6868
</Scrollbar>
6969
</TabPane>

packages/client/src/components/FeedBox/Body/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import React from 'react'
22
import PropTypes from 'prop-types'
33
import { useDispatch } from 'react-redux'
4-
import Scrollbar from 'react-custom-scrollbars'
54

65
import { deleteFeedBox } from 'newsdash/store/actions/feedBox'
76
import { feedBoxType } from 'newsdash/components/propTypes'
87
import Feed from 'newsdash/components/Feed'
8+
import Scrollbar from 'newsdash/components/Scrollbar'
99
import Edit from './Edit'
1010
import Tabs from './Tabs'
1111
import css from './Body.sss'
@@ -51,7 +51,7 @@ const Body = ({
5151

5252
if (feeds.length === 1) {
5353
return (
54-
<Scrollbar autoHide>
54+
<Scrollbar bgColor={feedBox.colors.bg}>
5555
<Feed feed={feeds[0]} />
5656
</Scrollbar>
5757
)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
@import 'newsdash/style/common.sss'
2+
3+
%fader
4+
height: 30px
5+
pointer-events: none
6+
position: absolute
7+
transition: opacity $transition-speed-fast ease-in
8+
width: 100%
9+
z-index: 1
10+
11+
.scrollWrapper
12+
position: relative
13+
height: 100%
14+
width: 100%
15+
16+
.track
17+
$w: 8px
18+
border-radius: calc($w / 2)
19+
bottom: 2px
20+
right: 2px
21+
top: 2px
22+
width: $w !important
23+
z-index: 5
24+
25+
.faderTop
26+
@extend %fader
27+
top: 0
28+
29+
.faderBottom
30+
@extend %fader
31+
bottom: 0
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import React, { useState } from 'react'
2+
import PropTypes from 'prop-types'
3+
import ReactCustomScrollbars from 'react-custom-scrollbars'
4+
5+
import css from './Scrollbar.sss'
6+
7+
const getFaderStyle = (type, bgColor, top) => ({
8+
background: `linear-gradient(to ${type}, transparent, ${bgColor} 90%)`,
9+
opacity: (type === 'top' && top === 0.0)
10+
|| (type === 'bottom' && top === 1.0)
11+
? '0.0' : '1.0',
12+
})
13+
14+
const Track = ({ style }) => <div className={css.track} style={style} />
15+
16+
Track.propTypes = {
17+
style: PropTypes.shape({
18+
opacity: PropTypes.number.isRequired,
19+
position: PropTypes.string.isRequired,
20+
transition: PropTypes.string.isRequired,
21+
width: PropTypes.number.isRequired,
22+
}).isRequired,
23+
}
24+
25+
const Scrollbar = ({ bgColor, children }) => {
26+
const [top, setTop] = useState(0.0)
27+
28+
return (
29+
<div className={css.scrollWrapper}>
30+
<ReactCustomScrollbars
31+
autoHide
32+
onScrollFrame={({ top: newTop }) => setTop(newTop)}
33+
renderTrackVertical={Track}
34+
>
35+
{children}
36+
</ReactCustomScrollbars>
37+
<div
38+
className={css.faderTop}
39+
style={getFaderStyle('top', bgColor, top)}
40+
/>
41+
<div
42+
className={css.faderBottom}
43+
style={getFaderStyle('bottom', bgColor, top)}
44+
/>
45+
</div>
46+
)
47+
}
48+
49+
Scrollbar.propTypes = {
50+
bgColor: PropTypes.string.isRequired,
51+
children: PropTypes.node.isRequired,
52+
}
53+
54+
export default Scrollbar

packages/client/src/style/common.sss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ $padding-lg: 12px
3838

3939
$tooltip-opacity: 0.95
4040

41+
$transition-speed-fast: 100ms
4142
$transition-speed: 200ms
4243

4344
%text-shadow

packages/client/src/style/index.sss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,8 @@ select
4141
background-color: grey !important
4242
border-radius: $border-radius
4343

44+
:global(.react-resizable-handle)
45+
z-index: 10
46+
4447
:global(.lazyload):not([src])
4548
visibility: hidden

0 commit comments

Comments
 (0)