1
- import { h , FunctionComponent } from 'preact'
1
+ import { h , Fragment , FunctionComponent } from 'preact'
2
2
import { useEffect , useState } from 'preact/hooks'
3
3
import type { DateFnsDocs } from '@date-fns/docs/types'
4
4
import { Content } from './Content'
5
5
import { DocHeaderAnchor } from '~/ui/components/DocHeaderAnchor'
6
6
import * as styles from './styles.css'
7
7
import classNames from 'classnames'
8
+ import { SectionHeader } from '../SectionHeader'
8
9
9
10
const LOCALSTORAGE_KEY = 'usageSource'
10
11
const DEFAULT_SOURCE = 'commonjs'
11
12
12
13
interface Props {
13
14
usage : DateFnsDocs . FnUsage
14
15
usageTabs : string [ ]
16
+ scope ?: string
17
+ header ?: 'h2' | 'h3'
15
18
}
16
19
17
- type FIXME = any
18
-
19
- export const DocUsage : FunctionComponent < Props > = ( { usageTabs, usage } ) => {
20
+ export const DocUsage : FunctionComponent < Props > = ( {
21
+ usageTabs,
22
+ usage,
23
+ scope,
24
+ header,
25
+ } ) => {
20
26
const [ source , setSource ] = useState ( DEFAULT_SOURCE )
21
27
22
28
useEffect ( ( ) => {
@@ -34,10 +40,7 @@ export const DocUsage: FunctionComponent<Props> = ({ usageTabs, usage }) => {
34
40
35
41
return (
36
42
< section >
37
- < h2 id = "usage" >
38
- Usage
39
- < DocHeaderAnchor anchor = "usage" />
40
- </ h2 >
43
+ < SectionHeader header = "Usage" scope = { scope } tag = { header } />
41
44
42
45
< ul class = { styles . options } >
43
46
{ usageTabs . map ( ( usageTab ) => {
@@ -55,7 +58,7 @@ export const DocUsage: FunctionComponent<Props> = ({ usageTabs, usage }) => {
55
58
selectedTab === usageTab && styles . optionLinkIsCurrent
56
59
) }
57
60
href = "#"
58
- onClick = { ( e : FIXME ) => {
61
+ onClick = { ( e ) => {
59
62
// FIXME:
60
63
// trackAction('Changed Usage Source', { source })
61
64
e . preventDefault ( )
0 commit comments