Skip to content

Commit

Permalink
Fix/date range picker history (#1088)
Browse files Browse the repository at this point in the history
* add react date picker modal

* add date time range picker

* added new date picker

* adjust date picker style and functionality

* added test for date picker

* resolving remaining merge conflicts

* change:
 - removed breaking code in getCoinImage
 - added png files for boba icons
 - loaded the icons for network and coin wherever required.
 - fix console crash for gasSwitcher
 - fix hover issue on history page
 - fix classNames for avaxIcons.

* commented out the date picker as needs some more time

* add date picker back

* updated snapshot and breaking change

* navgation links for stake & dao only for ETH network

* boba logo update across app

---------

Co-authored-by: Sahil Kashetwar <sahil@enya.ai>
  • Loading branch information
jemeza and sk-enya authored Aug 9, 2023
1 parent 6adeb89 commit 0a4f4e5
Show file tree
Hide file tree
Showing 27 changed files with 519 additions and 159 deletions.
4 changes: 4 additions & 0 deletions packages/boba/gateway/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@
"axios": "^0.21.1",
"bignumber.js": "^9.0.1",
"bn.js": "^5.1.3",
"bootstrap-daterangepicker": "^3.1.0",
"browserify-fs": "^1.0.0",
"browserify-zlib": "^0.2.0",
"buffer": "^6.0.3",
"date-fns": "^2.30.0",
"dayjs": "^1.11.7",
"dotenv": "^8.2.0",
"eslint-config-react-app": "^7.0.0",
Expand All @@ -60,8 +62,10 @@
"postcss-normalize": "^10.0.1",
"process": "^0.11.10",
"react": "^17.0.2",
"react-bootstrap-daterangepicker": "^8.0.0",
"react-card-flip": "^1.1.5",
"react-datepicker": "^4.6.0",
"react-day-picker": "^8.8.0",
"react-dom": "^17.0.2",
"react-ga4": "^1.4.1",
"react-multi-carousel": "^2.6.5",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Svg } from 'components/global/svg'
import { TableRow } from './styles'
import { sdesktop } from 'themes/screens'
export const TransactionsTableHeader = styled(TableHeader)`
padding: 8px 24px 4px 24px;
padding: 10px 24px 10px 24px;
background: none;
position: sticky;
top: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ function BobaAvaxIcon({ selected = false }) {
.st3{fill:#5D6E3C;}
.st4{fill-rule:evenodd;clip-rule:evenodd;fill:#E64142;}`}
</style>
<circle class="st0" cx="540" cy="540" r="540" />
<circle className="st0" cx="540" cy="540" r="540" />
<g>
<g>
<g>
<path class="st1" d="M653.700012,651.799988H347.600006V204.5h306.100006
<path className="st1" d="M653.700012,651.799988H347.600006V204.5h306.100006
c105.099976,0,190.200012,85.200012,190.200012,190.200012V461.5
C843.900024,566.599976,758.799988,651.799988,653.700012,651.799988"/>
<path class="st2" d="M732.599976,875.5h-385V651.799988c0-123.5,100.100006-223.600006,223.599976-223.600006h161.400024
<path className="st2" d="M732.599976,875.5h-385V651.799988c0-123.5,100.100006-223.600006,223.599976-223.600006h161.400024
c123.5,0,223.599976,100.100006,223.599976,223.600006C956.200012,775.299988,856.099976,875.5,732.599976,875.5"/>
<path class="st3" d="M843.900024,457.899994v3.700012c0,105.100006-85.099976,190.199982-190.299988,190.199982H347.600006
<path className="st3" d="M843.900024,457.899994v3.700012c0,105.100006-85.099976,190.199982-190.299988,190.199982H347.600006
c0-61.700012,25.100006-117.599976,65.5-158.100006c40.5-40.5,96.399994-65.5,158.199982-65.5h161.299988
C773.200012,428.200012,811.200012,439,843.900024,457.899994"/>
</g>
Expand All @@ -29,13 +29,13 @@ function BobaAvaxIcon({ selected = false }) {
<circle cx="348.200012" cy="540" r="224.5" />
</g>
<g>
<path class="st4" d="M497,634.900024c-0.200012,4-2.299988,7.799988-5.799988,10C488,647,482.700012,647,472.100006,647
<path className="st4" d="M497,634.900024c-0.200012,4-2.299988,7.799988-5.799988,10C488,647,482.700012,647,472.100006,647
h-71.699982c-10.600006,0-15.899994,0-19-2c-3.399994-2.200012-5.5-6-5.799988-10
c-0.200012-3.700012,2.399994-8.200012,7.700012-17.299988L383.400055,617.5l35.799988-61.400024
c5.299988-9.099976,7.899994-13.5,11.200012-15.299988c3.600006-1.799988,7.899994-1.799988,11.5,0
c3.299988,1.700012,5.799988,6,10.899994,14.5L453.200043,556l35.899994,61.400024
c0.200012,0.299988,0.299988,0.599976,0.5,0.900024C494.600006,626.900024,497.100006,631.299988,497,634.900024z"/>
<path class="st4" d="M400,482.299988c-1.299988,5.299988-4.100006,10.399994-9.899994,20.399994l-64.899994,114.699982
<path className="st4" d="M400,482.299988c-1.299988,5.299988-4.100006,10.399994-9.899994,20.399994l-64.899994,114.699982
L325,617.699951c-5.700012,10-8.600006,15.099976-12.600006,18.900024C308,640.799988,302.799988,643.799988,297,645.5
c-5.299988,1.5-11.100006,1.5-22.899994,1.5h-50c-10.5,0-15.699997,0-18.899994-2
c-3.399994-2.200012-5.5-5.900024-5.800003-9.900024c-0.199997-3.700012,2.399994-8.299988,7.600006-17.400024L330.600006,400
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@ function BobaBnbIcon({ selected = false }) {
.st3{fill:#5D6E3C;}
.st4{fill:#F1B82F;}`}
</style>
<circle class="st0" cx="540" cy="540" r="540" />
<circle className="st0" cx="540" cy="540" r="540" />
<g>
<g>
<g>
<path class="st1" d="M653.700012,651.799988H347.600006V204.5h306.100006
<path className="st1" d="M653.700012,651.799988H347.600006V204.5h306.100006
c105.099976,0,190.200012,85.200012,190.200012,190.200012V461.5
C843.900024,566.599976,758.799988,651.799988,653.700012,651.799988"/>
<path class="st2" d="M732.599976,875.5h-385V651.799988c0-123.5,100.100006-223.600006,223.599976-223.600006h161.400024
<path className="st2" d="M732.599976,875.5h-385V651.799988c0-123.5,100.100006-223.600006,223.599976-223.600006h161.400024
c123.5,0,223.599976,100.100006,223.599976,223.600006C956.200012,775.299988,856.099976,875.5,732.599976,875.5"/>
<path class="st3" d="M843.900024,457.899994v3.700012c0,105.100006-85.099976,190.199982-190.299988,190.199982H347.600006
<path className="st3" d="M843.900024,457.899994v3.700012c0,105.100006-85.099976,190.199982-190.299988,190.199982H347.600006
c0-61.700012,25.100006-117.599976,65.5-158.100006c40.5-40.5,96.399994-65.5,158.199982-65.5h161.299988
C773.200012,428.200012,811.200012,439,843.900024,457.899994"/>
</g>
<g>
<g>
<circle cx="348.200012" cy="540" r="224.5" />
</g>
<path id="binancedex_00000039833116453617585150000002441395151561646981_" class="st4" d="M384.100006,662.799988V704.5
<path id="binancedex_00000039833116453617585150000002441395151561646981_" className="st4" d="M384.100006,662.799988V704.5
l-36.299988,21.400024L312.500031,704.5v-41.700012l35.299988,21.400024L384.100006,662.799988z M189.600006,518.599976
L224.900009,540v71.5l60.800003,36.299988V689.5l-96.100006-56.700012V518.599976z M505.799988,518.599976V633
l-97.100006,56.700012V648l60.799988-36.299988v-71.5L505.799988,518.599976z M408.5,462l36.299988,21.399994l0,0V525
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ const GasWatcher: FC = () => {
</GasListItem>
<GasListItem>
<GasListItemLabel>Savings</GasListItemLabel>
<GasListItemValue>{savings.toFixed(0)}x</GasListItemValue>
<GasListItemValue>{savings?.toFixed(0)}x</GasListItemValue>
</GasListItem>
<GasListItem>
<GasListItemLabel>L1</GasListItemLabel>
<GasListItemValue>{gas.blockL1}</GasListItemValue>
<GasListItemValue>{gas?.blockL1}</GasListItemValue>
</GasListItem>
<GasListItem>
<GasListItemLabel>L2</GasListItemLabel>
<GasListItemValue>{gas.blockL2}</GasListItemValue>
<GasListItemValue>{gas?.blockL2}</GasListItemValue>
</GasListItem>
<GasListItem>
<GasListItemLabel>Last Verified Block</GasListItemLabel>
<GasListItemValue>
{Number(verifierStatus?.matchedBlock)}
{Number(verifierStatus?.matchedBlock || 0)}
</GasListItemValue>
</GasListItem>
</GasListContainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from '../styles'
import networkService from 'services/networkService'
import { getCoinImage } from 'util/coinImage'
import BobaLogo from 'assets/images/boba-logo.png'
import BobaLogo from 'assets/images/Boba_Logo_White_Circle.png'
import useFeeSwitcher from 'hooks/useFeeSwitcher'

interface Props {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ import {
} from 'selectors'
import AccountDrawer from './AccountDrawer'
import FeeSwitcherDrawer from './FeeSwitcherDrawer'
import bobaLogoPng from 'assets/images/boba-logo.png'

import BobaLogoPng from 'assets/images/Boba_Logo_White_Circle.png'

interface Props {
onClose: () => void
Expand Down Expand Up @@ -82,7 +83,7 @@ const NavDrawer: FC<Props> = ({ onClose, open }) => {
<ActionItem>
<ThemeIcon>
<img
src={feeUseBoba ? bobaLogoPng : getCoinImage('ETH')}
src={feeUseBoba ? BobaLogoPng : getCoinImage('ETH')}
alt="use token"
/>
</ThemeIcon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import React, { FC } from 'react'
import { StyledNav, NavLinkItem } from './style'
import { MENU_LIST } from './constant'
import { MenuProps } from './types'
import { useSelector } from 'react-redux'
import { selectActiveNetwork } from 'selectors'
import { NETWORK } from 'util/network/network.util'

/**
*
Expand All @@ -24,9 +27,18 @@ import { MenuProps } from './types'
*/

const Navigation: FC<MenuProps> = ({ isOpen }) => {
const activeNetwork = useSelector(selectActiveNetwork())

return (
<StyledNav>
{MENU_LIST.map((menu) => {
if (
activeNetwork !== NETWORK.ETHEREUM &&
['Stake', 'Dao'].includes(menu.label)
) {
return null
}

return (
<NavLinkItem
key={menu.label}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ import networkService from 'services/networkService.js'
import useFeeSwitcher from 'hooks/useFeeSwitcher'
import { getCoinImage } from 'util/coinImage'
import { FeeSwitcherIcon, FeeSwitcherLabel, FeeSwitcherWrapper } from './styles'
import BobaLogo from 'assets/images/boba-logo.png'

import BobaLogo from 'assets/images/Boba_Logo_White_Circle.png'

const OptionBoba = () => ({
value: 'BOBA',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ export const StakeItemDetails = styled.div`
box-sizing: border-box;
padding: 20px 35px;
border-radius: 8px;
${sdesktop(css`
width: 1024px;
`)}
> div {
display: flex;
margin: 0px auto;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
TokenSymbol,
} from './styles'
import { SectionLabel } from '../chain/styles'
import bobaLogo from 'assets/images/Boba_Logo_White_Circle.png'

type Props = {}

Expand Down Expand Up @@ -52,7 +53,11 @@ const BridgeInput: FC<Props> = (props) => {
{token && (
<TokenSymbol>
<img
src={getCoinImage(token.symbol)}
src={
token.symbol === 'BOBA'
? bobaLogo
: getCoinImage(token.symbol)
}
alt={`ETH logo`}
width="32px"
height="32px"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export const BridgeTabItem = styled.div<{
font-style: normal;
font-weight: 700;
line-height: normal;
border-radius: 8px;
font-size: ${(props) => props.theme.text.body1};
cursor: pointer;
background: transparent;
Expand All @@ -40,4 +39,11 @@ export const BridgeTabItem = styled.div<{
: props.theme.colors.gray[600]};
background: ${props.theme.colors.green[300]};
`};
&:nth-child(odd) {
border-radius: 8px 0 0 8px;
}
&:nth-child(even) {
border-radius: 0 8px 8px 0;
}
`
119 changes: 119 additions & 0 deletions packages/boba/gateway/src/containers/history/DatePicker.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import React, { FC, useRef, useState, useEffect, useCallback } from 'react'
import { subMonths } from 'date-fns'
import {
DatePickerDropdown,
DatePickerHeader,
DatePickerContainer,
} from './styles'
import { formatDate } from 'util/dates'
import { DayPicker, DateRange } from 'react-day-picker'
import 'react-day-picker/dist/style.css'

export interface IDatePickerProps {
selected: Date
timeFormat?: string
onChange: Function
range?: boolean
onChangeFrom?: Function
onChangeTo?: Function
}

const DatePicker = (props: IDatePickerProps) => {
const dropdownRef = useRef<HTMLDivElement>(null)
useEffect(() => {
const handleClickOutside = (e: Event) => {
if (
dropdownRef.current &&
!dropdownRef.current.contains(e.target as Node)
) {
setIsOpen(false)
}
}
// Bind the event listener
document.addEventListener('mousedown', handleClickOutside)
return () => {
// Unbind the event listener on clean up
document.removeEventListener('mousedown', handleClickOutside)
}
}, [dropdownRef])

const [selectedDate, setSelectedDate] = useState<Date>(props.selected)
const [isOpen, setIsOpen] = useState(false)
const today = new Date()
const defaultSelectedRange: DateRange = {
from: subMonths(today, 6),
to: today,
}
const [selectedRange, setSelectedRange] = useState<DateRange | undefined>(
defaultSelectedRange
)

const handleClick = useCallback(() => {
setIsOpen(!isOpen)
}, [isOpen])

const handleDateChange = (date: Date | undefined) => {
if (date && selectedDate !== date) {
setSelectedDate(date)
props.onChange(date)
}
}
const handleRangeChange = (range: DateRange | undefined) => {
if (range && range !== selectedRange) {
setSelectedRange(range)
props.onChangeFrom && props.onChangeFrom(range.from)
props.onChangeTo && props.onChangeTo(range.to)
}
}

if (props.range) {
const dateRangeString = `${
selectedRange?.from
? formatDate(selectedRange?.from?.getTime() / 1000, props.timeFormat)
: 'From'
} - ${
selectedRange?.to
? formatDate(selectedRange?.to?.getTime() / 1000, props.timeFormat)
: 'To'
}`

return (
<DatePickerContainer ref={dropdownRef}>
<DatePickerHeader onClick={handleClick}>
{dateRangeString}
</DatePickerHeader>
{isOpen && (
<DatePickerDropdown>
<DayPicker
id="rangeDatePicker"
mode="range"
defaultMonth={selectedRange?.from}
selected={selectedRange}
onSelect={(range) => handleRangeChange(range)}
/>
</DatePickerDropdown>
)}
</DatePickerContainer>
)
}

return (
<DatePickerContainer ref={dropdownRef}>
<DatePickerHeader onClick={handleClick}>
{formatDate(selectedDate.getTime() / 1000, props.timeFormat)}
</DatePickerHeader>
{isOpen && (
<DatePickerDropdown>
<DayPicker
mode="single"
defaultMonth={selectedDate}
selected={selectedDate}
onSelect={(date) => handleDateChange(date)}
/>
</DatePickerDropdown>
)}
</DatePickerContainer>
)
}

export default DatePicker
Loading

0 comments on commit 0a4f4e5

Please sign in to comment.