Skip to content

Commit 5b56b66

Browse files
committed
feat: add missing header components, refactor CSidebarBrand
1 parent fc6303a commit 5b56b66

File tree

7 files changed

+137
-26
lines changed

7 files changed

+137
-26
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<template>
2+
<CLink v-if="wrappedInLink" v-bind="linkProps">
3+
<img
4+
class="c-header-brand"
5+
v-bind="$attrs"
6+
/>
7+
</CLink>
8+
<img
9+
v-else
10+
class="c-header-brand"
11+
v-bind="$attrs"
12+
/>
13+
</template>
14+
15+
<script>
16+
import CLink from '../link/CLink'
17+
export default {
18+
name: 'CHeaderBrand',
19+
inheritAttrs: false,
20+
components: {
21+
CLink
22+
},
23+
props: {
24+
wrappedInLink: [String, Object]
25+
},
26+
computed : {
27+
linkProps () {
28+
return this.getObject(this.wrappedInLink, 'href')
29+
}
30+
},
31+
methods: {
32+
getObject (prop, key) {
33+
return typeof prop === 'object' ? prop : { [`${key}`]: prop }
34+
}
35+
}
36+
}
37+
</script>

src/components/header/CHeaderNavItem.vue

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
<template>
2-
<li class="c-header-nav-item">
2+
<li v-if="!onlyLink" class="c-header-nav-item">
33
<CLink
44
class="c-header-nav-link"
55
v-bind="$props"
66
>
77
<slot></slot>
88
</CLink>
99
</li>
10+
<CLink
11+
v-else
12+
class="c-header-nav-link"
13+
v-bind="Object.assign({}, $props, { onlyLink: null })"
14+
>
15+
<slot></slot>
16+
</CLink>
1017
</template>
1118

1219
<script>
13-
import CLink, { props } from '../link/CLink'
20+
import CLink, { props as linkProps } from '../link/CLink'
21+
const props = Object.assign({ onlyLink: Boolean }, linkProps)
1422
export default {
1523
name: 'CHeaderNavItem',
1624
components: {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<template>
2+
<CLink
3+
class="c-header-nav-link"
4+
v-bind="$props"
5+
>
6+
<slot></slot>
7+
</CLink>
8+
</template>
9+
10+
<script>
11+
import CLink, { props } from '../link/CLink'
12+
export default {
13+
name: 'CHeaderNavLink',
14+
components: {
15+
CLink
16+
},
17+
props
18+
}
19+
</script>

src/components/header/CSubheader.vue

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<template>
2+
<component :is="tag" class="c-subheader">
3+
<slot></slot>
4+
</component>
5+
</template>
6+
7+
<script>
8+
export default {
9+
name: 'CSubheader',
10+
props: {
11+
tag: {
12+
type: String,
13+
default: 'div'
14+
}
15+
}
16+
}
17+
</script>

src/components/header/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
import CHeader from './CHeader'
2+
import CHeaderBrand from './CHeaderBrand'
23
import CHeaderNav from './CHeaderNav'
34
import CHeaderNavItem from './CHeaderNavItem'
5+
// import CHeaderNavLink from './CHeaderNavLink'
6+
import CSubheader from './CSubheader'
47

58
export {
69
CHeader,
10+
CHeaderBrand,
711
CHeaderNav,
8-
CHeaderNavItem
12+
CHeaderNavItem,
13+
// CHeaderNavLink,
14+
CSubheader
915
}

src/components/index.d.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,21 @@ export declare class CHeader extends Vue {
297297
withSubheader: boolean
298298
}
299299

300+
export declare class CHeaderBrand extends Vue {
301+
wrappedInLink: [object, string]
302+
}
303+
300304
export declare class CHeaderNav extends Vue {}
301305

302-
export declare class CHeaderNavItem extends CLink {}
306+
export declare class CHeaderNavItem extends CLink {
307+
onlyLink: boolean
308+
}
309+
310+
export declare class CHeaderNavLink extends CLink { }
311+
312+
export declare class CSubheader extends CLink {
313+
tag: string
314+
}
303315

304316
export declare class CImg extends Vue {
305317
src: string
@@ -467,6 +479,14 @@ export declare class CSidebar extends Vue {
467479
overlaid: boolean
468480
}
469481

482+
export declare class CSidebarBrand extends Vue {
483+
img: [object, string]
484+
imgMinimized: [object, string]
485+
imgFull: [object, string]
486+
wrappedInLink: [object, string]
487+
}
488+
489+
470490
export declare class CSidebarClose extends Vue { }
471491

472492
export declare class CSidebarFooter extends Vue {}
Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,24 @@
11
<template>
22
<div class="c-sidebar-brand">
33
<slot>
4-
<CLink v-if="wrappedInLink" v-bind="wrappedInLink">
4+
<CLink v-if="wrappedInLink" v-bind="linkProps">
55
<img
66
class="c-sidebar-brand-full"
7-
:src="fullSrc || src"
8-
width="118"
9-
height="46"
10-
alt="Logo"
7+
v-bind="fullAttributes"
118
>
129
<img
1310
class="c-sidebar-brand-minimized"
14-
:src="minimizedSrc || src"
15-
width="118"
16-
height="46"
17-
alt="Logo"
11+
v-bind="minimizedAttributes"
1812
>
1913
</CLink>
2014
<template v-else>
2115
<img
22-
class="c-sidebar-brand-full"
23-
:src="fullSrc || src"
24-
width="118"
25-
height="46"
26-
alt="Logo"
16+
class="c-sidebar-brand-full"
17+
v-bind="fullAttributes"
2718
>
2819
<img
2920
class="c-sidebar-brand-minimized"
30-
:src="minimizedSrc || src"
31-
width="118"
32-
height="46"
33-
alt="Logo"
21+
v-bind="minimizedAttributes"
3422
>
3523
</template>
3624
</slot>
@@ -45,10 +33,26 @@ export default {
4533
CLink
4634
},
4735
props: {
48-
src: String,
49-
fullSrc: String,
50-
minimizedSrc: String,
51-
wrappedInLink: Object
36+
img: [String, Object],
37+
imgFull: [String, Object],
38+
imgMinimized: [String, Object],
39+
wrappedInLink: [String, Object]
40+
},
41+
computed: {
42+
linkProps () {
43+
return this.getObject(this.wrappedInLink, 'href')
44+
},
45+
minimizedAttributes () {
46+
return this.getObject(this.imgMinimized || this.img, 'src')
47+
},
48+
fullAttributes () {
49+
return this.getObject(this.imgFull || this.img, 'src')
50+
}
51+
},
52+
methods: {
53+
getObject (prop, key) {
54+
return typeof prop === 'object' ? prop : { [`${key}`]: prop }
55+
}
5256
}
5357
}
5458
</script>

0 commit comments

Comments
 (0)