Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit bed8a4a

Browse files
committed
refactor(sidebar-footer): badic scroll shadow ux
1 parent d4edf47 commit bed8a4a

File tree

8 files changed

+28
-20
lines changed

8 files changed

+28
-20
lines changed

src/containers/Sidebar/Footer.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { ICON_CMD } from '@config'
44

55
import { Wrapper, InnerWrapper, SettingIcon } from './styles/footer'
66

7-
const Footer = ({ pin }) => (
8-
<Wrapper pin={pin}>
7+
const Footer = ({ pin, showFooterBarShadow }) => (
8+
<Wrapper pin={pin} dropShadow={showFooterBarShadow}>
99
<InnerWrapper pin={pin}>
1010
<SettingIcon src={`${ICON_CMD}/setting.svg`} />
1111
</InnerWrapper>

src/containers/Sidebar/Header.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@ import {
1515
SearchIcon,
1616
SiteLogo,
1717
} from './styles/header'
18-
import {
19-
searchOnBlur,
20-
searchOnFocus,
21-
searchCommunityValueOnChange,
22-
} from './logic'
18+
import { searchOnFocus, searchCommunityValueOnChange } from './logic'
2319

2420
const Header = ({ pin, searchCommunityValue }) => (
2521
<Wrapper pin={pin}>
@@ -35,7 +31,6 @@ const Header = ({ pin, searchCommunityValue }) => (
3531
value={searchCommunityValue}
3632
onChange={e => searchCommunityValueOnChange(e)}
3733
placeholder="订阅的社区"
38-
onBlur={searchOnBlur}
3934
onFocus={searchOnFocus}
4035
/>
4136
</SearchContent>

src/containers/Sidebar/MenuList.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { SortableContainer, SortableElement } from 'react-sortable-hoc'
55
import { OverlayScrollbarsComponent } from 'overlayscrollbars-react'
66

77
import MenuBar from './MenuBar'
8-
import { scrollOnTop, scrollOffTop } from './logic'
8+
import { anchorTop, anchorOffTop, anchorBottom, anchorOffBottom } from './logic'
99
import { Wrapper, ScrollWrapper } from './styles/menu_list'
1010

1111
const SortableMenuBar = SortableElement(
@@ -41,7 +41,7 @@ const MenuList = SortableContainer(
4141
>
4242
<ScrollWrapper>
4343
<React.Fragment>
44-
<Waypoint onEnter={scrollOnTop} onLeave={scrollOffTop} />
44+
<Waypoint onEnter={anchorTop} onLeave={anchorOffTop} />
4545
{sortableCommunities.map((item, index) => (
4646
<SortableMenuBar
4747
index={index}
@@ -52,6 +52,7 @@ const MenuList = SortableContainer(
5252
forceRerender={forceRerender}
5353
/>
5454
))}
55+
<Waypoint onEnter={anchorBottom} onLeave={anchorOffBottom} />
5556
</React.Fragment>
5657
</ScrollWrapper>
5758
</OverlayScrollbarsComponent>

src/containers/Sidebar/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const SidebarContainer = ({ sidebar }) => {
2626
pin,
2727
searchCommunityValue,
2828
showHomeBarShadow,
29+
showFooterBarShadow,
2930
communitiesData,
3031
forceRerender,
3132
} = sidebar
@@ -46,7 +47,7 @@ const SidebarContainer = ({ sidebar }) => {
4647
onSortEnd={onSortMenuEnd}
4748
distance={5}
4849
/>
49-
<Footer pin={pin} />
50+
<Footer pin={pin} showFooterBarShadow={showFooterBarShadow} />
5051
</Wrapper>
5152
)
5253
}

src/containers/Sidebar/logic.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,24 @@ let sub$ = null
2727

2828
export const setPin = () => store.mark({ pin: !store.pin })
2929

30-
export const scrollOnTop = () => {
30+
export const anchorTop = () => {
3131
if (store) store.mark({ showHomeBarShadow: false })
3232
}
3333

34-
export const scrollOffTop = () => {
34+
export const anchorOffTop = () => {
3535
if (store) store.mark({ showHomeBarShadow: true })
3636
}
3737

38-
export const searchOnBlur = () => {
39-
log('searchOnBlur')
38+
export const anchorBottom = () => {
39+
if (store) store.mark({ showFooterBarShadow: false })
4040
}
4141

42-
export const searchOnFocus = () => {
43-
store.mark({ pin: true })
42+
export const anchorOffBottom = () => {
43+
if (store) store.mark({ showFooterBarShadow: true })
4444
}
4545

46+
export const searchOnFocus = () => store.mark({ pin: true })
47+
4648
export const searchCommunityValueOnChange = e =>
4749
store.mark({ searchCommunityValue: e.target.value })
4850

src/containers/Sidebar/store.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ const SidebarStore = t
1414
.model('SidebarStore', {
1515
// open: t.optional(t.boolean, false),
1616
pin: t.optional(t.boolean, false),
17-
// add shadow effect when user scroll the communities list
17+
// add shadow effect to homebar when user scroll the communities list
1818
showHomeBarShadow: t.optional(t.boolean, false),
19+
// add shadow effect to footer when user scroll the communities list
20+
showFooterBarShadow: t.optional(t.boolean, false),
1921
searchCommunityValue: t.optional(t.string, ''),
2022

2123
/*

src/containers/Sidebar/styles/footer.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@ export const Wrapper = styled.div`
77
// margin-bottom: ${({ pin }) => (pin ? '0' : '20px')};
88
margin-top: -20px;
99
background: ${theme('sidebar.bg')};
10-
box-shadow: -1px -4px 4px 0px rgba(0,0,0,0.2);
11-
border-top: 1px dashed #316d7b;
10+
11+
box-shadow: ${({ dropShadow }) =>
12+
dropShadow ? theme('sidebar.bottomShadow') : 'none'};
13+
border-bottom: ${({ dropShadow }) =>
14+
dropShadow ? theme('sidebar.bottomShadowBorderBottom') : ''};
15+
1216
z-index: 1;
1317
`
1418
export const InnerWrapper = styled.div`

utils/themes/skins/cyan.js

+3
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ const cyan = {
111111
borderColor: '#14363E',
112112
topShadow: '0px 6px 4px 0px rgba(0,0,0,0.2)',
113113
topShadowBorderBottom: '1px dashed #316d7b',
114+
bottomShadow: '-1px -4px 4px 0px rgba(0,0,0,0.2)',
115+
bottomShadowBorderBottom: '1px dashed #316d7b',
116+
114117
searchInputBottom: '#2b6775',
115118
searchInputBottomActive: '#61ABB2',
116119
searchInputHolder: '#3a7786',

0 commit comments

Comments
 (0)