Skip to content

Commit 9e9cf75

Browse files
committed
Brought in updated scrollspy component with more descriptive prop names. Added usage instructions to the component comments.
1 parent 78bb3f6 commit 9e9cf75

File tree

9 files changed

+131
-155
lines changed

9 files changed

+131
-155
lines changed

dash_mp_components/Scrollspy.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,35 @@
55

66
class Scrollspy(Component):
77
"""A Scrollspy component.
8-
8+
Component for building in-page navigation menus with scrollspy functionality
99
1010
Keyword arguments:
11-
- className (string; optional)
12-
- menuGroups (list; optional)
13-
- activeItemClassName (string; optional)
14-
- offset (number; optional)
15-
- menuLabelClassName (string; optional)
16-
- menuContainerClassName (string; optional)
17-
- menuItemClassName (string; optional)"""
11+
- menuGroups (list; optional): An array of MenuGroup items that is used to build the menu and its links.
12+
Each MenuGroup has an optional label and a required 'items' array of MenuItems.
13+
Each MenuItem has a label that is rendered in the menu and a targetId that is the id of the element it should link to.
14+
Do not include '#' in targetId.
15+
example:
16+
[
17+
{label: '...', items: [
18+
{label: '...', targetId: '...'},
19+
{label: '...', targetId: '...', items: [
20+
{label: '...', targetId: '...'}
21+
}]
22+
]}
23+
]
24+
- activeClassName (string; optional): Class name applied to active links in the menu (default: 'is-active')
25+
- menuClassName (string; optional): Class name applied to the <aside> that contains the whole menu (default: 'menu')
26+
- menuGroupLabelClassName (string; optional): Class name applied to all menu group labels (default: 'menu-label')
27+
- menuItemContainerClassName (string; optional): Class name applied to each <ul> of menu items (default: 'menu-list')
28+
- menuItemClassName (string; optional): Class name applied to the <li> of each menu item (default: '')
29+
- offset (number; optional): An integer to determine the scroll offset from an item that will trigger it active (default: -20)"""
1830
@_explicitize_args
19-
def __init__(self, className=Component.UNDEFINED, menuGroups=Component.UNDEFINED, activeItemClassName=Component.UNDEFINED, offset=Component.UNDEFINED, menuLabelClassName=Component.UNDEFINED, menuContainerClassName=Component.UNDEFINED, menuItemClassName=Component.UNDEFINED, **kwargs):
20-
self._prop_names = ['className', 'menuGroups', 'activeItemClassName', 'offset', 'menuLabelClassName', 'menuContainerClassName', 'menuItemClassName']
31+
def __init__(self, menuGroups=Component.UNDEFINED, activeClassName=Component.UNDEFINED, menuClassName=Component.UNDEFINED, menuGroupLabelClassName=Component.UNDEFINED, menuItemContainerClassName=Component.UNDEFINED, menuItemClassName=Component.UNDEFINED, offset=Component.UNDEFINED, **kwargs):
32+
self._prop_names = ['menuGroups', 'activeClassName', 'menuClassName', 'menuGroupLabelClassName', 'menuItemContainerClassName', 'menuItemClassName', 'offset']
2133
self._type = 'Scrollspy'
2234
self._namespace = 'dash_mp_components'
2335
self._valid_wildcard_attributes = []
24-
self.available_properties = ['className', 'menuGroups', 'activeItemClassName', 'offset', 'menuLabelClassName', 'menuContainerClassName', 'menuItemClassName']
36+
self.available_properties = ['menuGroups', 'activeClassName', 'menuClassName', 'menuGroupLabelClassName', 'menuItemContainerClassName', 'menuItemClassName', 'offset']
2537
self.available_wildcard_properties = []
2638

2739
_explicit_args = kwargs.pop('_explicit_args')

dash_mp_components/dash_mp_components.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dash_mp_components/dash_mp_components.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dash_mp_components/metadata.json

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -264,58 +264,58 @@
264264
}
265265
},
266266
"src/lib/components/Scrollspy.react.js": {
267-
"description": "",
267+
"description": "Component for building in-page navigation menus with scrollspy functionality",
268268
"displayName": "Scrollspy",
269269
"methods": [],
270270
"props": {
271-
"className": {
272-
"type": {
273-
"name": "string"
274-
},
275-
"required": false,
276-
"description": ""
277-
},
278271
"menuGroups": {
279272
"type": {
280273
"name": "array"
281274
},
282275
"required": false,
283-
"description": ""
276+
"description": "An array of MenuGroup items that is used to build the menu and its links.\nEach MenuGroup has an optional label and a required 'items' array of MenuItems.\nEach MenuItem has a label that is rendered in the menu and a targetId that is the id of the element it should link to.\nDo not include '#' in targetId.\nexample:\n [\n {label: '...', items: [\n {label: '...', targetId: '...'}, \n {label: '...', targetId: '...', items: [\n {label: '...', targetId: '...'}\n }]\n ]}\n ]"
284277
},
285-
"activeItemClassName": {
278+
"activeClassName": {
286279
"type": {
287280
"name": "string"
288281
},
289282
"required": false,
290-
"description": ""
283+
"description": "Class name applied to active links in the menu (default: 'is-active')"
291284
},
292-
"offset": {
285+
"menuClassName": {
293286
"type": {
294-
"name": "number"
287+
"name": "string"
295288
},
296289
"required": false,
297-
"description": ""
290+
"description": "Class name applied to the <aside> that contains the whole menu (default: 'menu')"
298291
},
299-
"menuLabelClassName": {
292+
"menuGroupLabelClassName": {
300293
"type": {
301294
"name": "string"
302295
},
303296
"required": false,
304-
"description": ""
297+
"description": "Class name applied to all menu group labels (default: 'menu-label')"
305298
},
306-
"menuContainerClassName": {
299+
"menuItemContainerClassName": {
307300
"type": {
308301
"name": "string"
309302
},
310303
"required": false,
311-
"description": ""
304+
"description": "Class name applied to each <ul> of menu items (default: 'menu-list')"
312305
},
313306
"menuItemClassName": {
314307
"type": {
315308
"name": "string"
316309
},
317310
"required": false,
318-
"description": ""
311+
"description": "Class name applied to the <li> of each menu item (default: '')"
312+
},
313+
"offset": {
314+
"type": {
315+
"name": "number"
316+
},
317+
"required": false,
318+
"description": "An integer to determine the scroll offset from an item that will trigger it active (default: -20)"
319319
}
320320
}
321321
},

dash_mp_components/package-info.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"author": "Materials Project Team <[email protected]>",
3434
"license": "BSD",
3535
"dependencies": {
36-
"@materialsproject/mp-react-components": "^0.1.2-SNAPSHOT.1598631728",
36+
"@materialsproject/mp-react-components": "^0.1.2-SNAPSHOT.1599088522",
3737
"file-loader": "^5.1.0",
3838
"prettier": "^1.19.1",
3939
"ramda": "^0.26.1",

0 commit comments

Comments
 (0)