Skip to content

Commit 45ed7e8

Browse files
author
Dobromir Hristov
committed
refactor: make header a link
1 parent 0f31e8d commit 45ed7e8

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

src/components/Navigator.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<NavigatorCard
1414
v-if="!isFetching"
1515
:technology="technology.title"
16+
:technology-path="technology.path || technology.url"
1617
:kind="kind"
1718
:children="flatChildren"
1819
:active-path="activePath"

src/components/Navigator/NavigatorCard.vue

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
<button class="close-card-mobile" @click="$emit('close')">
1515
<InlineCloseIcon class="icon-inline close-icon" />
1616
</button>
17-
<NavigatorLeafIcon :kind="kind" class="card-icon" />
18-
<span class="card-link">
19-
{{ technology }}
20-
</span>
17+
<Reference :url="technologyPath" class="navigator-head">
18+
<NavigatorLeafIcon :kind="kind" with-colors class="card-icon" />
19+
<div class="card-link">
20+
{{ technology }}
21+
</div>
22+
</Reference>
2123
</div>
2224
<div class="card-body">
2325
<RecycleScroller
@@ -84,6 +86,7 @@ import NavigatorCardItem from 'docc-render/components/Navigator/NavigatorCardIte
8486
import InlineCloseIcon from 'theme/components/Icons/InlineCloseIcon.vue';
8587
import FilterIcon from 'theme/components/Icons/FilterIcon.vue';
8688
import ClearRoundedIcon from 'theme/components/Icons/ClearRoundedIcon.vue';
89+
import Reference from 'docc-render/components/ContentNode/Reference.vue';
8790
8891
export const STORAGE_KEYS = {
8992
filter: 'navigator.filter',
@@ -106,6 +109,7 @@ export default {
106109
NavigatorCardItem,
107110
NavigatorLeafIcon,
108111
RecycleScroller,
112+
Reference,
109113
},
110114
props: {
111115
technology: {
@@ -128,6 +132,10 @@ export default {
128132
type: String,
129133
required: true,
130134
},
135+
technologyPath: {
136+
type: String,
137+
default: '',
138+
},
131139
},
132140
data() {
133141
return {
@@ -429,11 +437,18 @@ $navigator-card-vertical-spacing: 18px !default;
429437
flex-direction: column;
430438
431439
.head-wrapper {
440+
position: relative;
441+
}
442+
443+
.navigator-head {
432444
padding: 10px $navigator-card-horizontal-spacing;
433445
border-bottom: 1px solid var(--color-grid);
434446
display: flex;
435447
align-items: baseline;
436-
position: relative;
448+
449+
&.router-link-exact-active {
450+
background: var(--color-fill-gray-quaternary);
451+
}
437452
438453
@include breakpoint(small) {
439454
justify-content: center;
@@ -443,7 +458,6 @@ $navigator-card-vertical-spacing: 18px !default;
443458
.card-icon {
444459
width: 19px;
445460
height: 19px;
446-
color: var(--color-figure-blue);
447461
}
448462
449463
@include breakpoint(small) {
@@ -467,6 +481,7 @@ $navigator-card-vertical-spacing: 18px !default;
467481
position: absolute;
468482
left: 20px;
469483
top: 50%;
484+
z-index: 1;
470485
transform: translateY(-50%);
471486
color: var(--color-link);
472487

tests/unit/components/Navigator/NavigatorCard.spec.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import 'intersection-observer';
1616
import { LEAF_SIZES } from '@/constants/sidebar';
1717
import NavigatorCardItem from '@/components/Navigator/NavigatorCardItem.vue';
1818
import { sessionStorage } from 'docc-render/utils/storage';
19+
import Reference from '@/components/ContentNode/Reference.vue';
1920
import { flushPromises } from '../../../../test-utils';
2021

2122
jest.mock('docc-render/utils/debounce', () => jest.fn(fn => fn));
@@ -102,6 +103,7 @@ const activePath = [root0.path, root0Child0.path];
102103

103104
const defaultProps = {
104105
technology: 'TestKit',
106+
technologyPath: '/path/to/technology',
105107
children,
106108
activePath,
107109
showExtendedInfo: false,
@@ -128,6 +130,7 @@ describe('NavigatorCard', () => {
128130
const wrapper = createWrapper();
129131
expect(wrapper.find('.card-icon').props('kind')).toEqual(defaultProps.kind);
130132
// assert link
133+
expect(wrapper.find(Reference).props('url')).toEqual(defaultProps.technologyPath);
131134
expect(wrapper.find('.card-link').text()).toBe(defaultProps.technology);
132135
// assert scroller
133136
expect(wrapper.find(RecycleScroller).props()).toMatchObject({

0 commit comments

Comments
 (0)