stacker.news/components/more-footer.js

37 lines
868 B
JavaScript
Raw Normal View History

2021-09-30 15:46:58 +00:00
import { Button } from 'react-bootstrap'
import { useState } from 'react'
2022-01-27 20:31:16 +00:00
export default function MoreFooter ({ cursor, fetchMore, Skeleton, noMoreText }) {
2021-09-30 15:46:58 +00:00
const [loading, setLoading] = useState(false)
if (loading) {
return <div><Skeleton /></div>
}
let Footer
if (cursor) {
Footer = () => (
<Button
variant='primary'
size='md'
onClick={async () => {
setLoading(true)
await fetchMore({
variables: {
cursor
}
})
setLoading(false)
}}
>more
</Button>
)
} else {
Footer = () => (
2022-01-27 20:31:16 +00:00
<div className='text-muted' style={{ fontFamily: 'lightning', fontSize: '2rem', opacity: '0.6' }}>{noMoreText || 'GENISIS'}</div>
2021-09-30 15:46:58 +00:00
)
}
2021-11-12 22:39:52 +00:00
return <div className='d-flex justify-content-center mt-3 mb-1'><Footer /></div>
2021-09-30 15:46:58 +00:00
}