-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3217 from thematters/develop
chore(release): v4.17.0
- Loading branch information
Showing
24 changed files
with
302 additions
and
50 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "matters-web", | ||
"version": "4.16.0", | ||
"version": "4.17.0", | ||
"description": "codebase of Matters' website", | ||
"sideEffects": false, | ||
"author": "Matters <[email protected]>", | ||
|
@@ -92,6 +92,7 @@ | |
"nprogress": "^0.2.0", | ||
"number-precision": "^1.6.0", | ||
"path-to-regexp": "^6.2.1", | ||
"pulltorefreshjs": "^0.1.22", | ||
"react": "^17.0.2", | ||
"react-beautiful-dnd": "^13.1.1", | ||
"react-copy-to-clipboard": "^5.1.0", | ||
|
@@ -134,6 +135,7 @@ | |
"@types/jump.js": "^1.0.4", | ||
"@types/lodash": "^4.14.191", | ||
"@types/nprogress": "0.2.0", | ||
"@types/pulltorefreshjs": "^0.1.5", | ||
"@types/react": "^18.0.26", | ||
"@types/react-beautiful-dnd": "^13.1.3", | ||
"@types/react-copy-to-clipboard": "^5.0.4", | ||
|
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,48 @@ | ||
/* @styled-jsx=global */ | ||
|
||
/* https://github.com/BoxFactura/pulltorefresh.js/blob/master/src/lib/styles.js */ | ||
|
||
.ptr--ptr { | ||
top: 0; | ||
display: flex; | ||
align-content: stretch; | ||
align-items: flex-end; | ||
width: 100%; | ||
height: 0; | ||
overflow: hidden; | ||
text-align: center; | ||
pointer-events: none; | ||
transition: height 0.3s, min-height 0.3s; | ||
} | ||
|
||
.ptr--box { | ||
flex-basis: 100%; | ||
padding: var(--spacing-base); | ||
} | ||
|
||
.ptr--pull { | ||
transition: none; | ||
} | ||
|
||
.ptr--text { | ||
font-size: 0; | ||
visibility: hidden; | ||
} | ||
|
||
.ptr--icon { | ||
font-size: 0; | ||
color: var(--color-grey-light); | ||
transition: transform 0.3s; | ||
} | ||
|
||
/* | ||
When at the top of the page, disable vertical overscroll so passive touch | ||
listeners can take over. | ||
*/ | ||
.ptr--top { | ||
touch-action: pan-x pan-down pinch-zoom; | ||
} | ||
|
||
.ptr--release .ptr--icon { | ||
transform: rotate(180deg); | ||
} |
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,95 @@ | ||
import { useEffect } from 'react' | ||
import ReactDOMServer from 'react-dom/server' | ||
|
||
import { ReactComponent as IconPullToRefresh } from '@/public/static/icons/24px/pull-to-refresh.svg' | ||
import { analytics, sleep } from '~/common/utils' | ||
import { IconSpinner16, withIcon } from '~/components' | ||
|
||
import { useEventListener } from './useEventListener' | ||
|
||
/** | ||
* Core of Pull to Refresh | ||
* | ||
* Usage: | ||
* | ||
* ```tsx | ||
* usePullToRefresh.Register() | ||
* usePullToRefresh.Handler(refetch) | ||
* ``` | ||
* | ||
*/ | ||
|
||
const PTR_START = 'startPullToRefresh' | ||
const PTR_END = 'endPullToRefresh' | ||
const PTR_TIMEOUT = 3000 | ||
|
||
/** | ||
* React Hook to register Pull To Refresh | ||
*/ | ||
const Register = (selector = 'body', timeout = PTR_TIMEOUT) => { | ||
let PTR: any | ||
|
||
const initPTR = (ptr: any) => { | ||
PTR = ptr | ||
|
||
PTR.init({ | ||
mainElement: selector, | ||
triggerElement: selector, | ||
distReload: 56, | ||
onRefresh: (cb: () => void) => { | ||
// start refresh | ||
window.dispatchEvent(new CustomEvent(PTR_START, {})) | ||
analytics.trackEvent('pull_to_refresh') | ||
|
||
// end refresh | ||
let polling = true | ||
|
||
const onEnd = () => { | ||
if (polling) { | ||
cb() | ||
polling = false | ||
} | ||
window.removeEventListener(PTR_END, onEnd) | ||
} | ||
|
||
window.addEventListener(PTR_END, onEnd) | ||
sleep(timeout).then(onEnd) | ||
}, | ||
getStyles: () => ``, // remove default styles | ||
iconArrow: ReactDOMServer.renderToString( | ||
withIcon(IconPullToRefresh)({ size: 'md' }) | ||
), | ||
iconRefreshing: ReactDOMServer.renderToString( | ||
<IconSpinner16 size="md" /> | ||
), | ||
}) | ||
} | ||
|
||
useEffect(() => { | ||
import('pulltorefreshjs').then(initPTR) | ||
|
||
return () => { | ||
if (PTR) { | ||
PTR.destroyAll() | ||
} | ||
} | ||
}, []) | ||
} | ||
|
||
/** | ||
* React Hook to handle `PTR_START` event from `usePullToRefresh.Register` | ||
*/ | ||
const Handler = (onPull: () => any) => { | ||
useEventListener(PTR_START, async () => { | ||
if (onPull) { | ||
await onPull() | ||
} | ||
|
||
window.dispatchEvent(new CustomEvent(PTR_END, {})) | ||
}) | ||
} | ||
|
||
export const usePullToRefresh = { | ||
Register, | ||
Handler, | ||
} |
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
Oops, something went wrong.