11/* eslint-disable jsx-a11y/anchor-has-content */
22/* eslint-disable jsx-a11y/heading-has-content */
3- import PropTypes from 'prop-types'
3+
44import React , { useEffect , useState } from 'react'
55import Markdown from 'react-markdown'
66import { Link } from 'react-router-dom'
@@ -14,7 +14,7 @@ import { LoadingFrame } from '../Utils/LoadingFrame'
1414
1515const ERROR_NOT_FOUND = 'not_found'
1616
17- const HelpPageContent = ( { page, onLinkClick } ) => {
17+ const HelpPageContent = ( { page, onLinkClick } : { page : string ; onLinkClick : ( ) => void } ) => {
1818 const { locale } = useUserPreferences ( )
1919 const [ markdownContent , setMarkdownContent ] = useState ( '' )
2020 const [ isLoading , setIsLoading ] = useState ( false )
@@ -28,11 +28,11 @@ const HelpPageContent = ({ page, onLinkClick }) => {
2828 try {
2929 const response = await fetch ( `/assets/help/${ locale } /${ page } .md` )
3030 const contentType = response . headers . get ( 'Content-Type' )
31-
31+
3232 if ( contentType && ! contentType . includes ( 'markdown' ) ) {
3333 throw ERROR_NOT_FOUND
3434 }
35-
35+
3636 if ( response . status === 200 || response . status === 304 ) {
3737 const text = await response . text ( )
3838 setMarkdownContent ( text )
@@ -55,11 +55,11 @@ const HelpPageContent = ({ page, onLinkClick }) => {
5555 if ( isLoading ) {
5656 return < LoadingFrame />
5757 }
58-
58+
5959 if ( error ) {
6060 return < ErrorView canGoBack = { false } error = { error } />
6161 }
62-
62+
6363 return (
6464 < Markdown
6565 className = "content"
@@ -110,25 +110,36 @@ const HelpPageContent = ({ page, onLinkClick }) => {
110110 // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
111111 li : ( { node, ...props } ) => < li className = "leading-relaxed mb-2" { ...props } /> ,
112112 // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
113- blockquote : ( { node, ...props } ) => (
114- < blockquote
115- className = "border-l-4 border-blue-400 dark:border-blue-500 bg-blue-50 dark:bg-blue-950/30 text-gray-600 dark:text-foreground px-6 py-1 mb-6 rounded-r italic leading-relaxed"
116- { ...props }
117- />
118- ) ,
113+ blockquote : ( { node, ...props } ) => {
114+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
115+ const { ref : _ref , ...restProps } =
116+ props as React . ComponentPropsWithoutRef < 'blockquote' > & { ref ?: React . Ref < HTMLElement > }
117+ return (
118+ < blockquote
119+ className = "border-l-4 border-blue-400 dark:border-blue-500 bg-blue-50 dark:bg-blue-950/30 text-gray-600 dark:text-foreground px-6 py-1 mb-6 rounded-r italic leading-relaxed"
120+ { ...restProps }
121+ />
122+ )
123+ } ,
119124 // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
120125 code : ( { node, className, children, ...props } ) => {
121- return typeof children === 'string' && children . length < 30 ? (
122- < code
123- className = "bg-gray-100 dark:bg-accent text-pink-600 dark:text-pink-400 px-2 py-0.5 rounded font-mono text-sm"
124- { ...props }
125- >
126- { children }
127- </ code >
128- ) : (
126+ if ( typeof children === 'string' && children . length < 30 ) {
127+ return (
128+ < code
129+ className = "bg-gray-100 dark:bg-accent text-pink-600 dark:text-pink-400 px-2 py-0.5 rounded font-mono text-sm"
130+ { ...props }
131+ >
132+ { children }
133+ </ code >
134+ )
135+ }
136+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
137+ const { ref : _ref , ...restProps } =
138+ props as React . ComponentPropsWithoutRef < 'blockquote' > & { ref ?: React . Ref < HTMLElement > }
139+ return (
129140 < blockquote
130141 className = "border-l-4 border-blue-400 dark:border-blue-500 bg-blue-50 dark:bg-blue-950/30 text-gray-600 dark:text-foreground px-6 py-3 mb-6 rounded-r italic leading-relaxed"
131- { ...props }
142+ { ...restProps }
132143 >
133144 { children }
134145 </ blockquote >
@@ -166,10 +177,7 @@ const HelpPageContent = ({ page, onLinkClick }) => {
166177 ) ,
167178 // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
168179 th : ( { node, ...props } ) => (
169- < th
170- className = "p-3 font-medium text-left text-gray-700 dark:text-foreground"
171- { ...props }
172- />
180+ < th className = "p-3 font-medium text-left text-gray-700 dark:text-foreground" { ...props } />
173181 ) ,
174182 // eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
175183 td : ( { node, ...props } ) => (
@@ -182,10 +190,4 @@ const HelpPageContent = ({ page, onLinkClick }) => {
182190 )
183191}
184192
185- HelpPageContent . propTypes = {
186- page : PropTypes . string . isRequired ,
187- onLinkClick : PropTypes . func ,
188- locale : PropTypes . string . isRequired ,
189- }
190-
191- export default HelpPageContent
193+ export default HelpPageContent
0 commit comments