Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
1bcc0b06
Unverified
Commit
1bcc0b06
authored
Jul 17, 2020
by
Kyle Keating
Committed by
GitHub
Jul 17, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve typecheck for MenuSection (#2349)
parent
ef82cf66
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
9 deletions
+11
-9
menu-section.js
src/sidebar/components/menu-section.js
+11
-8
tsconfig.json
src/tsconfig.json
+0
-1
No files found.
src/sidebar/components/menu-section.js
View file @
1bcc0b06
import
{
Fragment
,
createElement
,
toChildArray
}
from
'preact'
;
import
propTypes
from
'prop-types'
;
/** @typedef {import("preact").JSX.Element} JSXElement */
/**
* @typedef MenuSectionProps
* @prop {string} [heading] - Heading displayed at the top of the menu.
* @prop {Object} children - Menu items to display in this section.
*/
/**
* Group a set of menu items together visually, with an optional header.
*
...
...
@@ -15,6 +23,8 @@ import propTypes from 'prop-types';
* <MenuItem .../>
* </MenuSection>
* </Menu>
*
* @param {MenuSectionProps} props
*/
export
default
function
MenuSection
({
heading
,
children
})
{
return
(
...
...
@@ -22,7 +32,7 @@ export default function MenuSection({ heading, children }) {
{
heading
&&
<
h2
className
=
"menu-section__heading"
>
{
heading
}
<
/h2>
}
<
ul
className
=
"menu-section__content"
>
{
toChildArray
(
children
).
map
(
child
=>
(
<
li
key
=
{
child
.
key
}
>
{
child
}
<
/li
>
<
li
key
=
{
/** @type {JSXElement} **/
(
child
)
.
key
}
>
{
child
}
<
/li
>
))}
<
/ul
>
<
/Fragment
>
...
...
@@ -30,13 +40,6 @@ export default function MenuSection({ heading, children }) {
}
MenuSection
.
propTypes
=
{
/**
* Heading displayed at the top of the menu.
*/
heading
:
propTypes
.
string
,
/**
* Menu items to display in this section.
*/
children
:
propTypes
.
any
.
isRequired
,
};
src/tsconfig.json
View file @
1bcc0b06
...
...
@@ -58,7 +58,6 @@
"sidebar/components/markdown-editor.js"
,
"sidebar/components/menu-item.js"
,
"sidebar/components/menu-keyboard-navigation.js"
,
"sidebar/components/menu-section.js"
,
"sidebar/components/menu.js"
,
"sidebar/components/moderation-banner.js"
,
"sidebar/components/new-note-btn.js"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment