reuse formatted countdown component
This commit is contained in:
parent
a48cd33db3
commit
9fce2154f6
@ -3,7 +3,7 @@ import * as Yup from 'yup'
|
|||||||
import { gql, useMutation } from '@apollo/client'
|
import { gql, useMutation } from '@apollo/client'
|
||||||
import styles from './reply.module.css'
|
import styles from './reply.module.css'
|
||||||
import TextareaAutosize from 'react-textarea-autosize'
|
import TextareaAutosize from 'react-textarea-autosize'
|
||||||
import Countdown from 'react-countdown'
|
import Countdown from '../components/countdown'
|
||||||
|
|
||||||
export const CommentSchema = Yup.object({
|
export const CommentSchema = Yup.object({
|
||||||
text: Yup.string().required('required').trim()
|
text: Yup.string().required('required').trim()
|
||||||
@ -54,14 +54,7 @@ export default function CommentEdit ({ comment, editThreshold, onSuccess, onCanc
|
|||||||
autoFocus
|
autoFocus
|
||||||
required
|
required
|
||||||
groupClassName='mb-0'
|
groupClassName='mb-0'
|
||||||
hint={
|
hint={<Countdown date={editThreshold} />}
|
||||||
<span className='text-muted font-weight-bold'>
|
|
||||||
<Countdown
|
|
||||||
date={editThreshold}
|
|
||||||
renderer={props => <span> {props.formatted.minutes}:{props.formatted.seconds}</span>}
|
|
||||||
/>
|
|
||||||
</span>
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
<div className='d-flex align-items-center justify-content-between'>
|
<div className='d-flex align-items-center justify-content-between'>
|
||||||
<SubmitButton variant='secondary' className='mt-1'>save</SubmitButton>
|
<SubmitButton variant='secondary' className='mt-1'>save</SubmitButton>
|
||||||
|
@ -11,7 +11,7 @@ import EyeClose from '../svgs/eye-close-line.svg'
|
|||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import { useMe } from './me'
|
import { useMe } from './me'
|
||||||
import CommentEdit from './comment-edit'
|
import CommentEdit from './comment-edit'
|
||||||
import Countdown from 'react-countdown'
|
import Countdown from './countdown'
|
||||||
|
|
||||||
function Parent ({ item }) {
|
function Parent ({ item }) {
|
||||||
const ParentFrag = () => (
|
const ParentFrag = () => (
|
||||||
@ -133,7 +133,7 @@ export default function Comment ({ item, children, replyOpen, includeParent, cac
|
|||||||
edit
|
edit
|
||||||
<Countdown
|
<Countdown
|
||||||
date={editThreshold}
|
date={editThreshold}
|
||||||
renderer={props => <span> {props.formatted.minutes}:{props.formatted.seconds}</span>}
|
className=' '
|
||||||
onComplete={() => {
|
onComplete={() => {
|
||||||
setCanEdit(false)
|
setCanEdit(false)
|
||||||
}}
|
}}
|
||||||
|
13
components/countdown.js
Normal file
13
components/countdown.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import Countdown from 'react-countdown'
|
||||||
|
|
||||||
|
export default function SimpleCountdown ({ className, onComplete, date }) {
|
||||||
|
return (
|
||||||
|
<span className={className || 'text-muted font-weight-bold'}>
|
||||||
|
<Countdown
|
||||||
|
date={date}
|
||||||
|
renderer={props => <span> {props.formatted.minutes}:{props.formatted.seconds}</span>}
|
||||||
|
onComplete={onComplete}
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
)
|
||||||
|
}
|
@ -4,7 +4,7 @@ import * as Yup from 'yup'
|
|||||||
import { gql, useMutation } from '@apollo/client'
|
import { gql, useMutation } from '@apollo/client'
|
||||||
import ActionTooltip from '../components/action-tooltip'
|
import ActionTooltip from '../components/action-tooltip'
|
||||||
import TextareaAutosize from 'react-textarea-autosize'
|
import TextareaAutosize from 'react-textarea-autosize'
|
||||||
import Countdown from 'react-countdown'
|
import Countdown from './countdown'
|
||||||
|
|
||||||
export const DiscussionSchema = Yup.object({
|
export const DiscussionSchema = Yup.object({
|
||||||
title: Yup.string().required('required').trim()
|
title: Yup.string().required('required').trim()
|
||||||
@ -75,14 +75,7 @@ export function DiscussionForm ({ item, editThreshold }) {
|
|||||||
as={TextareaAutosize}
|
as={TextareaAutosize}
|
||||||
minRows={4}
|
minRows={4}
|
||||||
hint={editThreshold
|
hint={editThreshold
|
||||||
? (
|
? <Countdown date={editThreshold} />
|
||||||
<span className='text-muted font-weight-bold'>
|
|
||||||
<Countdown
|
|
||||||
date={editThreshold}
|
|
||||||
renderer={props => <span> {props.formatted.minutes}:{props.formatted.seconds}</span>}
|
|
||||||
/>
|
|
||||||
</span>
|
|
||||||
)
|
|
||||||
: null}
|
: null}
|
||||||
/>
|
/>
|
||||||
<ActionTooltip>
|
<ActionTooltip>
|
||||||
|
@ -4,7 +4,7 @@ import { timeSince } from '../lib/time'
|
|||||||
import UpVote from './upvote'
|
import UpVote from './upvote'
|
||||||
import { useMe } from './me'
|
import { useMe } from './me'
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import Countdown from 'react-countdown'
|
import Countdown from './countdown'
|
||||||
|
|
||||||
export default function Item ({ item, rank, children }) {
|
export default function Item ({ item, rank, children }) {
|
||||||
const me = useMe()
|
const me = useMe()
|
||||||
@ -59,7 +59,7 @@ export default function Item ({ item, rank, children }) {
|
|||||||
edit
|
edit
|
||||||
<Countdown
|
<Countdown
|
||||||
date={editThreshold}
|
date={editThreshold}
|
||||||
renderer={props => <span> {props.formatted.minutes}:{props.formatted.seconds}</span>}
|
className=' '
|
||||||
onComplete={() => {
|
onComplete={() => {
|
||||||
setCanEdit(false)
|
setCanEdit(false)
|
||||||
}}
|
}}
|
||||||
|
@ -4,7 +4,7 @@ import * as Yup from 'yup'
|
|||||||
import { gql, useMutation } from '@apollo/client'
|
import { gql, useMutation } from '@apollo/client'
|
||||||
import { ensureProtocol } from '../lib/url'
|
import { ensureProtocol } from '../lib/url'
|
||||||
import ActionTooltip from '../components/action-tooltip'
|
import ActionTooltip from '../components/action-tooltip'
|
||||||
import Countdown from 'react-countdown'
|
import Countdown from './countdown'
|
||||||
|
|
||||||
export const LinkSchema = Yup.object({
|
export const LinkSchema = Yup.object({
|
||||||
title: Yup.string().required('required').trim(),
|
title: Yup.string().required('required').trim(),
|
||||||
@ -89,14 +89,7 @@ export function LinkForm ({ item, editThreshold }) {
|
|||||||
name='url'
|
name='url'
|
||||||
required
|
required
|
||||||
hint={editThreshold
|
hint={editThreshold
|
||||||
? (
|
? <Countdown date={editThreshold} />
|
||||||
<span className='text-muted font-weight-bold'>
|
|
||||||
<Countdown
|
|
||||||
date={editThreshold}
|
|
||||||
renderer={props => <span> {props.formatted.minutes}:{props.formatted.seconds}</span>}
|
|
||||||
/>
|
|
||||||
</span>
|
|
||||||
)
|
|
||||||
: null}
|
: null}
|
||||||
/>
|
/>
|
||||||
<ActionTooltip>
|
<ActionTooltip>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user