Skip to content

Commit

Permalink
Merge branch '19-add-snippet-name-to-shortcode' of https://github.com…
Browse files Browse the repository at this point in the history
…/codesnippetspro/code-snippets into 19-add-snippet-name-to-shortcode
  • Loading branch information
lightbulbman committed Jan 23, 2025
2 parents f442399 + db98650 commit 2ad4e43
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/js/components/SnippetForm/page/Notices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,22 @@ import classnames from 'classnames'
import React, { useEffect } from 'react'
import { __, sprintf } from '@wordpress/i18n'
import { useSnippetForm } from '../../../hooks/useSnippetForm'
import type { MouseEventHandler, ReactNode} from 'react'
import type { ReactNode } from 'react'

interface DismissibleNoticeProps {
classNames?: classnames.Argument
onRemove: MouseEventHandler<HTMLButtonElement>
onRemove: VoidFunction
children?: ReactNode
autoHide?: boolean
}

const DismissibleNotice: React.FC<DismissibleNoticeProps> = ({ classNames, onRemove, children, autoHide = true }) => {
useEffect(() => {
if (autoHide) {
const timer = setTimeout(() => {
onRemove({} as React.MouseEvent<HTMLButtonElement>)
}, 5000)

const timer = setTimeout(onRemove, 5000)
return () => clearTimeout(timer)
}
return () => {} // eslint-disable-line
return undefined
}, [autoHide, onRemove])

return (
Expand All @@ -29,7 +26,7 @@ const DismissibleNotice: React.FC<DismissibleNoticeProps> = ({ classNames, onRem

<button type="button" className="notice-dismiss" onClick={event => {
event.preventDefault()
onRemove(event)
onRemove()
}}>
<span className="screen-reader-text">{__('Dismiss notice.', 'code-snippets')}</span>
</button>
Expand Down

0 comments on commit 2ad4e43

Please sign in to comment.