Skip to content

Commit 9713f25

Browse files
committed
docs: update documentation
1 parent b797b85 commit 9713f25

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

src/docs/components/CodeBlock.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ const CodeBlock: FC = ({ children }) => {
77
const language = children.props.className
88
? children.props.className.replace(/language-/, '')
99
: 'jsx'
10-
// const language = 'jsx'
1110

1211
return (
1312
<div className="code mb-4" style={{ maxHeight: '500px', overflow: 'scroll' }}>
14-
<Highlight {...defaultProps} theme={false} code={_children?.trim()} language={language}>
13+
<Highlight {...defaultProps} theme={undefined} code={_children?.trim()} language={language}>
1514
{({ className, style, tokens, getLineProps, getTokenProps }) => (
1615
<pre className={className} style={{ ...style }}>
1716
{tokens.map((line, i) => (

src/docs/components/Header.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ const Header: FC = ({ ...props }) => {
1212
<myContext.Consumer>
1313
{(context) => (
1414
<CHeader className="mb-5">
15-
<CHeaderToggler className="ms-md-3 d-lg-none" onClick={() => context.toggleSidebar()}>
15+
<CHeaderToggler
16+
className="ms-md-3"
17+
onClick={() => context.setSidebarVisible(!context.sidebarVisible)}
18+
>
1619
<CIcon icon={cilMenu} size="lg" />
1720
</CHeaderToggler>
1821
<CHeaderNav className="ms-auto">

src/docs/components/Sidebar.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { SidebarNav } from '.'
77
import { myContext } from './../templates/Docs'
88

99
import items from './../nav'
10+
// @ts-expect-error svg file
1011
import logo from './../assets/coreui-react.svg'
1112

1213
interface SidebarProps {
@@ -20,9 +21,11 @@ const Sidebar: FC<SidebarProps> = ({ ...props }) => {
2021
<CSidebar
2122
className="docs-sidebar border-end ps-xl-4 elevation-0"
2223
position="fixed"
23-
selfHiding="md"
24+
// selfHiding="md"
25+
hideBelow="xl"
2426
size="lg"
2527
visible={context.sidebarVisible}
28+
onVisibleChange={(value) => context.setSidebarVisible(value)}
2629
>
2730
<CSidebarBrand className="justify-content-start ps-3">
2831
<CImage className="d-block mt-4 mb-5" src={logo} height={50} />

src/docs/templates/Docs.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,23 @@ import { CodeBlock, Example, Footer, Header, Seo, Sidebar, Toc } from './../comp
88
import { CCol, CContainer, CRow } from '../../index'
99
import './../styles/styles.scss'
1010

11-
export const myContext = React.createContext()
11+
interface ContextProps {
12+
sidebarVisible: boolean | undefined
13+
setSidebarVisible: React.Dispatch<React.SetStateAction<boolean | undefined>>
14+
}
15+
16+
export const myContext = React.createContext({} as ContextProps)
1217

1318
const components = {
19+
// eslint-disable-next-line react/display-name
1420
pre: (props) => <CodeBlock {...props} />,
1521
// eslint-disable-next-line react/display-name
1622
table: (props) => <table {...props} className="table table-striped" />,
1723
Example,
1824
}
1925

2026
const DocsLayout: FC = ({ data: { mdx } }) => {
21-
const [sidebarVisible, setSidebarVisible] = useState()
27+
const [sidebarVisible, setSidebarVisible] = useState(true)
2228
return (
2329
<>
2430
<Seo title={mdx.frontmatter.title} description={mdx.frontmatter.description} />
@@ -28,7 +34,8 @@ const DocsLayout: FC = ({ data: { mdx } }) => {
2834
<myContext.Provider
2935
value={{
3036
sidebarVisible,
31-
toggleSidebar: () => setSidebarVisible(!sidebarVisible),
37+
setSidebarVisible,
38+
// toggleSidebar: () => setSidebarVisible(!sidebarVisible),
3239
}}
3340
>
3441
<Sidebar currentRoute={mdx.frontmatter.route}/>

0 commit comments

Comments
 (0)