-
Notifications
You must be signed in to change notification settings - Fork 538
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* page placeholder * block info snippet * add actions for calendar buttons * add timer * add redirect when timer runs out * add redirect from not found block page * block countdown index page * link to countdown index page * add link to search suggest * add URL to an event * add link to block countdown on mobile * tests * add countdown text to search result page * update margins * show block countdown when search results are not empty
- Loading branch information
Showing
64 changed files
with
785 additions
and
87 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import type { NextPage } from 'next'; | ||
import dynamic from 'next/dynamic'; | ||
import React from 'react'; | ||
|
||
import type { Props } from 'nextjs/getServerSideProps'; | ||
import PageNextJs from 'nextjs/PageNextJs'; | ||
|
||
const BlockCountdown = dynamic(() => import('ui/pages/BlockCountdown'), { ssr: false }); | ||
|
||
const Page: NextPage<Props> = (props: Props) => { | ||
return ( | ||
<PageNextJs pathname="/block/countdown/[height]" query={ props.query }> | ||
<BlockCountdown/> | ||
</PageNextJs> | ||
); | ||
}; | ||
|
||
export default Page; | ||
|
||
export { base as getServerSideProps } from 'nextjs/getServerSideProps'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import type { NextPage } from 'next'; | ||
import dynamic from 'next/dynamic'; | ||
import React from 'react'; | ||
|
||
import type { Props } from 'nextjs/getServerSideProps'; | ||
import PageNextJs from 'nextjs/PageNextJs'; | ||
|
||
const BlockCountdownIndex = dynamic(() => import('ui/pages/BlockCountdownIndex'), { ssr: false }); | ||
|
||
const Page: NextPage<Props> = (props: Props) => { | ||
return ( | ||
<PageNextJs pathname="/block/countdown" query={ props.query }> | ||
<BlockCountdownIndex/> | ||
</PageNextJs> | ||
); | ||
}; | ||
|
||
export default Page; | ||
|
||
export { base as getServerSideProps } from 'nextjs/getServerSideProps'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import type * as api from 'types/api/search'; | ||
|
||
export interface SearchResultFutureBlock { | ||
type: 'block'; | ||
block_type: 'block'; | ||
block_number: number | string; | ||
block_hash: string; | ||
timestamp: undefined; | ||
url?: string; // not used by the frontend, we build the url ourselves | ||
} | ||
|
||
export type SearchResultBlock = api.SearchResultBlock | SearchResultFutureBlock; | ||
|
||
export type SearchResultItem = api.SearchResultItem | SearchResultBlock; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { HStack, StackDivider, useColorModeValue } from '@chakra-ui/react'; | ||
import React from 'react'; | ||
|
||
import { SECOND } from 'lib/consts'; | ||
|
||
import BlockCountdownTimerItem from './BlockCountdownTimerItem'; | ||
import splitSecondsInPeriods from './splitSecondsInPeriods'; | ||
|
||
interface Props { | ||
value: number; | ||
onFinish: () => void; | ||
} | ||
|
||
const BlockCountdownTimer = ({ value: initialValue, onFinish }: Props) => { | ||
|
||
const [ value, setValue ] = React.useState(initialValue); | ||
|
||
const bgColor = useColorModeValue('gray.50', 'whiteAlpha.100'); | ||
|
||
React.useEffect(() => { | ||
const intervalId = window.setInterval(() => { | ||
setValue((prev) => { | ||
if (prev > 1) { | ||
return prev - 1; | ||
} | ||
|
||
onFinish(); | ||
return 0; | ||
}); | ||
}, SECOND); | ||
|
||
return () => { | ||
window.clearInterval(intervalId); | ||
}; | ||
}, [ initialValue, onFinish ]); | ||
|
||
const periods = splitSecondsInPeriods(value); | ||
|
||
return ( | ||
<HStack | ||
bgColor={ bgColor } | ||
mt={{ base: 6, lg: 8 }} | ||
p={{ base: 3, lg: 4 }} | ||
borderRadius="base" | ||
divider={ <StackDivider borderColor="divider"/> } | ||
> | ||
<BlockCountdownTimerItem label="Days" value={ periods.days }/> | ||
<BlockCountdownTimerItem label="Hours" value={ periods.hours }/> | ||
<BlockCountdownTimerItem label="Minutes" value={ periods.minutes }/> | ||
<BlockCountdownTimerItem label="Seconds" value={ periods.seconds }/> | ||
</HStack> | ||
); | ||
}; | ||
|
||
export default React.memo(BlockCountdownTimer); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Box } from '@chakra-ui/react'; | ||
import React from 'react'; | ||
|
||
import TruncatedValue from 'ui/shared/TruncatedValue'; | ||
|
||
interface Props { | ||
label: string; | ||
value: string; | ||
} | ||
|
||
const BlockCountdownTimerItem = ({ label, value }: Props) => { | ||
return ( | ||
<Box | ||
minW={{ base: '70px', lg: '100px' }} | ||
textAlign="center" | ||
overflow="hidden" | ||
flex="1 1 auto" | ||
> | ||
<TruncatedValue | ||
value={ value } | ||
fontFamily="heading" | ||
fontSize={{ base: '40px', lg: '48px' }} | ||
lineHeight="48px" | ||
fontWeight={ 600 } | ||
w="100%" | ||
/> | ||
<Box fontSize="sm" lineHeight="20px" mt={ 1 } color="text_secondary">{ label }</Box> | ||
</Box> | ||
); | ||
}; | ||
|
||
export default React.memo(BlockCountdownTimerItem); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { route } from 'nextjs-routes'; | ||
|
||
import config from 'configs/app'; | ||
import dayjs from 'lib/date/dayjs'; | ||
interface Params { | ||
timeFromNow: number; | ||
blockHeight: string; | ||
} | ||
|
||
const DATE_FORMAT = 'YYYYMMDDTHHmm'; | ||
|
||
export default function createGoogleCalendarLink({ timeFromNow, blockHeight }: Params): string { | ||
|
||
const date = dayjs().add(timeFromNow, 's'); | ||
const name = `Block #${ blockHeight } reminder | ${ config.chain.name }`; | ||
const description = `#${ blockHeight } block creation time on ${ config.chain.name } blockchain.`; | ||
const startTime = date.format(DATE_FORMAT); | ||
const endTime = date.add(15, 'minutes').format(DATE_FORMAT); | ||
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone; | ||
const blockUrl = config.app.baseUrl + route({ pathname: '/block/[height_or_hash]', query: { height_or_hash: blockHeight } }); | ||
|
||
const url = new URL('calendar/render', 'https://www.google.com/'); | ||
url.searchParams.append('action', 'TEMPLATE'); | ||
url.searchParams.append('text', name); | ||
url.searchParams.append('details', description + '\n' + blockUrl); | ||
url.searchParams.append('dates', `${ startTime }/${ endTime }`); | ||
url.searchParams.append('ctz', timeZone); | ||
|
||
return url.toString(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { route } from 'nextjs-routes'; | ||
|
||
import config from 'configs/app'; | ||
import type dayjs from 'lib/date/dayjs'; | ||
|
||
interface Params { | ||
date: dayjs.Dayjs; | ||
blockHeight: string; | ||
} | ||
|
||
const DATE_FORMAT = 'YYYYMMDDTHHmmss'; | ||
|
||
export default function createIcsFileBlob({ date, blockHeight }: Params): Blob { | ||
const name = `Block #${ blockHeight } reminder | ${ config.chain.name }`; | ||
const description = `#${ blockHeight } block creation time on ${ config.chain.name } blockchain.`; | ||
const startTime = date.format(DATE_FORMAT); | ||
const endTime = date.add(15, 'minutes').format(DATE_FORMAT); | ||
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone; | ||
const blockUrl = config.app.baseUrl + route({ pathname: '/block/[height_or_hash]', query: { height_or_hash: blockHeight } }); | ||
|
||
const icsContent = `BEGIN:VCALENDAR | ||
VERSION:2.0 | ||
BEGIN:VEVENT | ||
SUMMARY:${ name } | ||
DESCRIPTION:${ description } | ||
DTSTART;TZID=${ timeZone }:${ startTime } | ||
DTEND;TZID=${ timeZone }:${ endTime } | ||
URL:${ blockUrl } | ||
END:VEVENT | ||
END:VCALENDAR`; | ||
|
||
const blob = new Blob([ icsContent ], { type: 'text/calendar' }); | ||
|
||
return blob; | ||
} |
Oops, something went wrong.