Skip to content

Commit 31ab20f

Browse files
committed
Cleanup ffooter show
1 parent 0f65465 commit 31ab20f

File tree

5 files changed

+49
-27
lines changed

5 files changed

+49
-27
lines changed

packages/react-app/src/components/field-input/amount-field-input.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ function AmountFieldInput({
221221
};
222222

223223
const amountField = (
224-
<FieldInput label={amountLabel} isLoading={isLoading} wide={wide} compact={compact}>
224+
<FieldInput label={amountLabel} wide={wide} compact={compact}>
225225
<AmountTokenWrapperStyled isEdit={isEdit} wide={wide}>
226226
{amount !== undefined &&
227227
(isEdit ? (
@@ -245,7 +245,6 @@ function AmountFieldInput({
245245
const tokenField = (
246246
<FieldInput
247247
label={tokenLabel}
248-
isLoading={isLoading}
249248
wide={wide}
250249
compact={compact}
251250
tooltip="Token"
@@ -291,7 +290,7 @@ function AmountFieldInput({
291290
label={label}
292291
tooltip={tooltip}
293292
tooltipDetail={tooltipDetail}
294-
isLoading={false}
293+
isLoading={isLoading}
295294
wide={wide}
296295
compact
297296
direction={!!amountLabel || !!tokenLabel ? 'column' : 'row'}

packages/react-app/src/components/field-input/field-input.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import styled from 'styled-components';
66
import { IconTooltip } from './icon-tooltip';
77

88
const FieldStyled = styled.div`
9-
${({ compact }: any) => (!compact ? `margin-bottom:${GUpx(2)}` : '')};
9+
${({ compact }: any) => (!compact ? `margin-bottom:${GUpx(1)}` : '')};
1010
${({ isLoading, wide }: any) => (isLoading || wide ? `width: 100%;` : 'max-width: 100%;')};
1111
`;
1212

@@ -38,6 +38,7 @@ const ContentWrapperStyled = styled.div`
3838
}
3939
}
4040
flex-direction: ${({ direction }: any) => direction};
41+
padding-left: ${GUpx(0.5)};
4142
`;
4243

4344
const SkeletonWrapperStyled = styled.div`
@@ -52,7 +53,7 @@ type Props = {
5253
tooltipDetail?: React.ReactNode;
5354
children: React.ReactNode;
5455
id?: string;
55-
isLoading: boolean;
56+
isLoading?: boolean;
5657
wide?: boolean;
5758
direction?: 'row' | 'column';
5859
align?: 'center' | 'baseline' | 'flex-start' | 'flex-end' | 'unset';

packages/react-app/src/components/main-view.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ function MainView({ children, toggleTheme, currentTheme }: Props) {
7070
main={children}
7171
side={page === ENUM_PAGES.List ? <Sidebar /> : undefined}
7272
footer={<Footer />}
73-
mainScrollable={page === ENUM_PAGES.List}
7473
/>
7574
</Root.Provider>
7675
</MainViewStyled>

packages/react-app/src/components/side-content-layout.tsx

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
import { useViewport } from '@1hive/1hive-ui';
22
import React, { useEffect, useRef, useState } from 'react';
3-
import { GUpx } from 'src/utils/css.util';
43
import styled from 'styled-components';
54
import { BREAKPOINTS } from '../styles/breakpoints';
65

76
const WrapperStyled = styled.div`
87
display: grid;
98
grid-template-areas: ${(props: any) =>
10-
props.twoCol ? "'m m s'\n'm m s'\n'f f f'" : "'s s s'\n'm m m'\n'f f f'"};
9+
props.isOneCol ? "'s s s'\n'm m m'\n'f f f'" : "'m m s'\n'm m s'\n'f f f'"};
1110
height: calc(100vh - 64px);
1211
overflow-y: auto;
1312
grid-template-columns: 1fr auto;
1413
scroll-behavior: smooth;
14+
::-webkit-scrollbar {
15+
display: none;
16+
}
17+
-ms-overflow-style: none;
18+
scrollbar-width: none;
1519
`;
1620

1721
const SideBlockStyled = styled.div`
@@ -20,6 +24,7 @@ const SideBlockStyled = styled.div`
2024

2125
const FooterStyled = styled.div`
2226
grid-area: f;
27+
transition: all 5s linear;
2328
`;
2429

2530
const ScrollViewStyled = styled.div`
@@ -36,53 +41,71 @@ const ScrollViewStyled = styled.div`
3641
`
3742
: ''}
3843
39-
${(props: any) => (props.twoCol ? `padding: ${GUpx(1)} ${GUpx(4)};` : `padding: ${GUpx(1)}`)};
4044
grid-area: m;
4145
`;
4246

4347
type Props = {
4448
main: React.ReactNode;
4549
side?: React.ReactNode;
4650
footer: React.ReactNode;
47-
mainScrollable?: boolean;
4851
};
4952

50-
function SideContentLayout({ main, side, footer, mainScrollable = true }: Props) {
53+
function SideContentLayout({ main, side, footer }: Props) {
5154
const { width: vw } = useViewport();
55+
const wrapperElement = document.getElementById('main-scroll');
5256
const scrollRef = useRef<HTMLDivElement>();
5357
const footerRef = useRef<HTMLDivElement>();
54-
const [twoCol, setTwoCol] = useState(true);
58+
const [isOneCol, setIsOneCol] = useState(false);
5559

5660
useEffect(() => {
5761
const handleWheelOnMain = (e: WheelEvent) => {
5862
const scrollElement = scrollRef.current as HTMLElement;
59-
const wrapperElement = document.getElementById('main-scroll');
60-
const footerElement = footerRef.current as HTMLElement;
61-
// scroll is bottom
62-
if (wrapperElement && scrollElement) {
63-
if (Math.round(wrapperElement.scrollTop) >= footerElement.clientHeight && e.deltaY < 0) {
64-
e.preventDefault();
65-
wrapperElement.scroll({ top: e.deltaY, behavior: 'smooth' });
63+
if (scrollElement && wrapperElement) {
64+
if (
65+
Math.round(scrollElement.scrollHeight - scrollElement.scrollTop) >=
66+
Math.round(scrollElement.clientHeight) &&
67+
e.deltaY < 0
68+
) {
69+
requestAnimationFrame(() =>
70+
wrapperElement.scroll({
71+
top: -footerRef.current!.clientHeight,
72+
left: 0,
73+
behavior: 'auto',
74+
}),
75+
);
76+
}
77+
if (
78+
Math.round(scrollElement.scrollHeight - scrollElement.scrollTop) ===
79+
Math.round(scrollElement.clientHeight) &&
80+
wrapperElement.scrollTop - scrollElement.scrollTop <= 0 &&
81+
e.deltaY > 0
82+
) {
83+
requestAnimationFrame(() =>
84+
wrapperElement.scroll({
85+
top: footerRef.current!.clientHeight,
86+
left: 0,
87+
behavior: 'auto',
88+
}),
89+
);
6690
}
6791
}
6892
};
69-
70-
if (scrollRef.current && footerRef.current && side) {
93+
if (scrollRef.current && footerRef.current && !isOneCol) {
7194
scrollRef.current?.addEventListener('wheel', handleWheelOnMain);
7295
} else {
7396
scrollRef.current?.removeEventListener('wheel', handleWheelOnMain);
7497
}
7598
return () => scrollRef.current?.removeEventListener('wheel', handleWheelOnMain);
76-
}, [scrollRef.current, footerRef.current, side]);
99+
}, [scrollRef.current, footerRef.current, isOneCol]);
77100

78101
useEffect(() => {
79-
setTwoCol(vw >= BREAKPOINTS.large);
80-
}, [vw]);
102+
setIsOneCol(!side || vw < BREAKPOINTS.large);
103+
}, [vw, side]);
81104

82105
return (
83106
<>
84-
<WrapperStyled twoCol={twoCol && side} id="main-scroll">
85-
<ScrollViewStyled scrollable={mainScrollable} id="scroll-view" ref={scrollRef}>
107+
<WrapperStyled isOneCol={isOneCol} id="main-scroll">
108+
<ScrollViewStyled scrollable={!isOneCol} id="scroll-view" ref={scrollRef}>
86109
{main}
87110
</ScrollViewStyled>
88111
{side && <SideBlockStyled>{side}</SideBlockStyled>}

packages/react-app/src/components/views/quest-list.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export default function QuestList() {
121121
pullDownToRefreshContent={<h3 className="center">&#8595; Pull down to refresh</h3>}
122122
releaseToRefreshContent={<h3 className="center">&#8593; Release to refresh</h3>}
123123
scrollableTarget="scroll-view"
124-
scrollThreshold="50px"
124+
scrollThreshold={0.5}
125125
>
126126
<div>
127127
{quests.map((x: QuestModel) => (

0 commit comments

Comments
 (0)