Skip to content

Commit d101d50

Browse files
committedFeb 8, 2021
src/modules: simplify arguments for Header, Menu, MenuItem and Logo
1 parent 0b337ec commit d101d50

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed
 

‎src/modules/Header.mjs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
export const View = (props = {}, children = []) => {
22
CHECK_PROPS(props, propTypes, 'Header')
33

4-
const { logo, menu, logotext, ...state } = props
4+
const { logo, menu, logotext, root, theme, hash, url } = props
5+
56
if (!logo && !menu && !logotext) {
67
return
78
}
89

910
return header({ class: 'Header' }, [
10-
(logo || logotext) && Logo({ root: state.root, theme: state.theme, img: logo, text: logotext }),
11-
menu && Menu({ state, items: menu }),
11+
(logo || logotext) && Logo({ root, theme, logo, logotext }),
12+
menu && Menu({ url, hash, root, items: menu }),
1213
children,
1314
])
1415
}

‎src/modules/Logo.mjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export const View = ({ img, text, ...state }) =>
2-
Link({ to: state.root, class: 'Logo' }, [img && Img(img), text && span(text)])
1+
export const View = ({ logo, logotext, ...state }) =>
2+
Link({ to: state.root, class: 'Logo' }, [logo && Img(logo), logotext && span(logotext)])

‎src/modules/Menu.mjs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
export const View = (props = {}) => {
22
CHECK_PROPS(props, propTypes, 'Menu')
3-
const { class: className = 'Menu', collapse = true, items, state } = props
43

5-
let { url, hash, root } = state
4+
const { class: className = 'Menu', collapse = true, items, state } = props
5+
const { hash, root } = state
6+
let { url } = state
67

78
if (hash && !url.endsWith(hash)) {
89
url += `#${hash}`

‎src/modules/MenuItem.mjs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
export const View = props => {
22
CHECK_PROPS(props, propTypes, 'MenuItem', true)
3+
34
const { text, items = [], url, root, parentTo = undefined, collapse, ...item } = props
45

56
const p = {
67
class: {},
78
}
89

9-
let to = item.to
10+
let { to } = item
1011

1112
if (root && to.startsWith('/')) {
1213
to = to.substr(1)

0 commit comments

Comments
 (0)
Please sign in to comment.