forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNotice.tsx
More file actions
51 lines (47 loc) · 1.46 KB
/
Notice.tsx
File metadata and controls
51 lines (47 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { useRouter } from 'next/router'
import { Link } from 'components/Link'
import { useTranslation } from 'src/languages/components/useTranslation'
import type { GraphqlT } from './types'
type Props = {
item: GraphqlT
variant: 'preview' | 'deprecation'
}
export function Notice({ item, variant = 'preview' }: Props) {
const { locale } = useRouter()
const { t } = useTranslation('products')
const previewTitle =
variant === 'preview'
? t('graphql.reference.preview_notice')
: t('graphql.reference.deprecation_notice')
const noticeStyle =
variant === 'preview'
? 'ghd-spotlight-note color-border-accent-emphasis color-bg-accent'
: 'ghd-spotlight-warning color-border-danger-emphasis color-bg-danger'
return (
<div className={`ghd-spotlight ${noticeStyle} border rounded-1 my-3 p-3 f5`}>
<p>
<b>{previewTitle}</b>
</p>
{variant === 'preview' && item.preview ? (
<p>
<code>{item.name}</code> is available under the{' '}
<Link href={item.preview.href} locale={locale}>
{item.preview.title}
</Link>
. {t('graphql.reference.preview_period')}
</p>
) : item.deprecationReason ? (
<div>
<p>
<code>{item.name}</code> is deprecated.
</p>
<div
dangerouslySetInnerHTML={{
__html: item.deprecationReason,
}}
/>
</div>
) : null}
</div>
)
}