Skip to content

Commit f71e95b

Browse files
author
Dobromir Hristov
committed
refactor: styling changes to the Sidenav
1 parent a492305 commit f71e95b

File tree

9 files changed

+165
-43
lines changed

9 files changed

+165
-43
lines changed

src/components/AdjustableSidebarWidth.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,10 @@ export default {
166166
width: 0 !important;
167167
min-width: 0;
168168
max-width: 100%;
169-
position: absolute;
170-
z-index: 1;
169+
position: fixed;
170+
top: 0;
171+
bottom: 0;
172+
z-index: 9999;
171173
transform: translateX(-100px);
172174
transition: width 0.15s linear, transform 0.15s ease-in;
173175

src/components/DocumentationTopic.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
:parent-topic-identifiers="navigatorParentTopicIdentifiers"
4545
:technology="technology"
4646
:is_fetching="isFetching"
47+
@close="isSideNavOpen = false"
4748
/>
4849
</template>
4950
</NavigatorDataProvider>
@@ -470,10 +471,7 @@ export default {
470471
height: 100%;
471472
box-sizing: border-box;
472473
@include breakpoint(small) {
473-
position: absolute;
474-
width: 100%;
475474
background: var(--color-fill);
476-
z-index: 1;
477475
}
478476
}
479477

src/components/DocumentationTopic/DocumentationNav.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
aria-label="API Reference"
2121
>
2222
<template slot="pre-title">
23-
<button @click.prevent="$emit('toggle-sidenav')">Open</button>
23+
<button @click.prevent="$emit('toggle-sidenav')">
24+
<SidenavIcon class="icon-inline sidenav-icon" />
25+
</button>
2426
</template>
2527
<template slot="default">
2628
<slot
@@ -56,11 +58,13 @@
5658
<script>
5759
import NavBase from 'docc-render/components/NavBase.vue';
5860
import { BreakpointName } from 'docc-render/utils/breakpoints';
61+
import SidenavIcon from 'theme/components/Icons/SidenavIcon.vue';
5962
import Hierarchy from './DocumentationNav/Hierarchy.vue';
6063
6164
export default {
6265
name: 'DocumentationNav',
6366
components: {
67+
SidenavIcon,
6468
NavBase,
6569
Hierarchy,
6670
},
@@ -169,4 +173,9 @@ export default {
169173
}
170174
}
171175
}
176+
177+
.sidenav-icon {
178+
width: 15px;
179+
height: 15px;
180+
}
172181
</style>

src/components/Icons/CollectionIcon.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<template>
1212
<SVGIcon viewBox="0 0 16 16" class="collection-icon">
1313
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
14-
<g transform="translate(2.100000, 2.800000)" fill="#509CA3" fill-rule="nonzero">
14+
<g transform="translate(2.100000, 2.800000)" fill="currentColor" fill-rule="nonzero">
1515
<path
1616
d="M1.00195312,6.21367188 C1.55273438,6.21367188 2.00390625,5.7625 2.00390625,5.21171875 C2.00390625,4.6609375 1.55273438,4.20976563 1.00195312,4.20976563 C0.451171875,4.20976563 0,4.6609375 0,5.21171875 C0,5.7625 0.451171875,6.21367188 1.00195312,6.21367188 Z M10.9238281,5.93828125 C11.328125,5.93828125 11.6503906,5.621875 11.6503906,5.21171875 C11.6503906,4.80742188 11.3339844,4.48515625 10.9238281,4.48515625 L4.0546875,4.48515625 C3.65039063,4.48515625 3.328125,4.8015625 3.328125,5.21171875 C3.328125,5.61601563 3.64453125,5.93828125 4.0546875,5.93828125 L10.9238281,5.93828125 Z"></path>
1717
<path

src/components/Icons/FilterIcon.vue

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,13 @@
1111
<template>
1212
<SVGIcon
1313
class="filter-icon"
14-
height="21"
15-
width="21"
16-
viewBox="0 0 41 41"
14+
height="14"
15+
width="14"
16+
viewBox="0 0 14 14"
1717
fill="currentColor"
1818
>
19-
<path d="M20.8.3a20,20,0,0,1,0,40,20.1,20.1,0,0,1-20-20A20.2,20.2,0,0,1,20.8.3Zm0,2.6a17.4,17.4,0,0,0,0,34.8A17.2,17.2,0,0,0,38.2,20.3,17.3,17.3,0,0,0,20.8,2.9Z"/>
20-
<path d="M31.9,16a1.1,1.1,0,0,0,1.2-1.1,1.1,1.1,0,0,0-1.2-1.1H9.8a1.1,1.1,0,0,0-1.2,1.1A1.1,1.1,0,0,0,9.8,16Z"/>
21-
<path d="M29,22.6a1,1,0,0,0,1.1-1.1A1.1,1.1,0,0,0,29,20.4H12.7a1.1,1.1,0,0,0-1.2,1.1,1.1,1.1,0,0,0,1.2,1.1Z"/>
22-
<path d="M25.9,29.2a1.1,1.1,0,0,0,1.2-1.1A1.1,1.1,0,0,0,25.9,27H15.8a1.1,1.1,0,0,0-1.2,1.1,1.1,1.1,0,0,0,1.2,1.1Z"/>
19+
<path
20+
d="M13.399 4.062c0.169 0 0.311-0.059 0.427-0.177s0.174-0.26 0.174-0.428c0-0.169-0.058-0.312-0.173-0.43s-0.258-0.176-0.427-0.176h-12.798c-0.169 0-0.311 0.059-0.427 0.176s-0.174 0.261-0.174 0.429c0 0.167 0.058 0.31 0.175 0.428s0.259 0.177 0.427 0.177h12.798zM11.999 7.605c0.169 0 0.311-0.059 0.427-0.177s0.174-0.26 0.174-0.428c0-0.169-0.058-0.312-0.173-0.429s-0.258-0.176-0.427-0.176h-9.964c-0.169 0-0.311 0.059-0.427 0.176s-0.174 0.26-0.174 0.429c0 0.167 0.058 0.31 0.174 0.428s0.258 0.177 0.427 0.177h9.964zM10.598 11.148c0.169 0 0.311-0.059 0.427-0.176s0.174-0.26 0.174-0.428c0-0.169-0.058-0.312-0.174-0.429s-0.258-0.176-0.427-0.176h-7.157c-0.169 0-0.312 0.059-0.43 0.176s-0.177 0.26-0.177 0.428c0 0.167 0.059 0.31 0.177 0.428s0.262 0.177 0.43 0.177h7.157z"></path>
2321
</SVGIcon>
2422
</template>
2523

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!--
2+
This source file is part of the Swift.org open source project
3+
4+
Copyright (c) 2021 Apple Inc. and the Swift project authors
5+
Licensed under Apache License v2.0 with Runtime Library Exception
6+
7+
See https://swift.org/LICENSE.txt for license information
8+
See https://swift.org/CONTRIBUTORS.txt for Swift project authors
9+
-->
10+
11+
<template>
12+
<SVGIcon viewBox="0 0 14 14" height="14" class="sidenav-icon">
13+
<path d="M11.632 11.991c0.577 0 1.010-0.143 1.299-0.43 0.287-0.286 0.432-0.713 0.432-1.278v-6.562c0-0.565-0.145-0.991-0.433-1.28s-0.721-0.433-1.298-0.433h-9.264c-0.569 0-1 0.144-1.292 0.43s-0.439 0.714-0.439 1.283v6.562c0 0.569 0.147 0.996 0.439 1.28s0.723 0.427 1.292 0.427h9.264zM4.837 11.030h-2.43c-0.258 0-0.455-0.068-0.591-0.205s-0.206-0.34-0.206-0.609v-6.425c0-0.269 0.068-0.472 0.205-0.609s0.335-0.205 0.592-0.205h2.43v8.053zM11.593 11.030h-5.828v-8.053h5.827c0.258 0 0.458 0.068 0.598 0.205s0.211 0.34 0.211 0.609v6.425c0 0.27-0.070 0.473-0.211 0.609s-0.339 0.205-0.597 0.205zM3.791 4.963c0.091 0 0.168-0.033 0.233-0.1 0.060-0.057 0.097-0.138 0.097-0.228s-0.037-0.17-0.097-0.228l-0-0c-0.058-0.058-0.139-0.094-0.228-0.094-0.002 0-0.004 0-0.005 0h-1.132c-0.001-0-0.002-0-0.003-0-0.088 0-0.168 0.036-0.225 0.094l-0 0c-0.060 0.057-0.097 0.138-0.097 0.228s0.037 0.17 0.097 0.228l0 0c0.064 0.067 0.14 0.1 0.227 0.1h1.132zM3.791 6.379c0.091 0 0.168-0.032 0.233-0.097 0.060-0.057 0.098-0.137 0.098-0.226s-0.037-0.17-0.098-0.226l-0-0c-0.058-0.058-0.139-0.094-0.228-0.094-0.002 0-0.004 0-0.005 0h-1.132c-0.001-0-0.002-0-0.003-0-0.088 0-0.168 0.036-0.225 0.094l-0 0c-0.060 0.057-0.097 0.137-0.097 0.226s0.037 0.169 0.097 0.226l0 0c0.057 0.060 0.137 0.097 0.226 0.097 0 0 0.001 0 0.001 0h1.132zM3.791 7.796c0.091 0 0.168-0.032 0.233-0.097 0.059-0.056 0.096-0.135 0.097-0.222v-0c0-0.002 0-0.004 0-0.007 0-0.088-0.037-0.168-0.096-0.224l-0-0c-0.058-0.058-0.139-0.094-0.228-0.094-0.002 0-0.004 0-0.005 0h-1.132c-0.001-0-0.002-0-0.003-0-0.088 0-0.168 0.036-0.225 0.094l-0 0c-0.060 0.056-0.097 0.136-0.097 0.224 0 0.002 0 0.005 0 0.007l-0-0c0 0.083 0.032 0.158 0.097 0.222 0.057 0.060 0.137 0.097 0.225 0.097 0.001 0 0.001 0 0.002-0h1.132z"></path>
14+
</SVGIcon>
15+
</template>
16+
17+
<script>
18+
import SVGIcon from 'docc-render/components/SVGIcon.vue';
19+
20+
export default {
21+
name: 'SidenavIcon',
22+
components: { SVGIcon },
23+
};
24+
</script>

src/components/Navigator.vue

Lines changed: 64 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,29 @@
88
:active-path="activePath"
99
:show-extended-info="showExtraInfo"
1010
:filter-pattern="filterPattern"
11-
/>
11+
@close="$emit('close')"
12+
>
13+
<div class="navigator-filter">
14+
<div class="input-wrapper">
15+
<FilterIcon class="icon-inline filter-icon" :class="{ colored: filter }" />
16+
<input
17+
type="text"
18+
:value="filter"
19+
:placeholder="`Filter in ${technology.title}`"
20+
@input="debounceInput">
21+
<button
22+
class="clear-button"
23+
:class="{ hide: !filter }"
24+
@click.prevent="filter = ''"
25+
>
26+
<ClearRoundedIcon class="icon-inline clear-icon" />
27+
</button>
28+
</div>
29+
</div>
30+
</NavigatorCard>
1231
<div v-else>
1332
Fetching...
1433
</div>
15-
<div class="navigator-filter">
16-
<div class="input-wrapper">
17-
<FilterIcon class="icon-inline filter-icon" />
18-
<input
19-
type="text"
20-
:value="filter"
21-
:placeholder="`Filter in ${technology.title}`"
22-
@input="debounceInput">
23-
</div>
24-
</div>
2534
</div>
2635
</template>
2736

@@ -33,6 +42,7 @@ import FilterIcon from 'docc-render/components/Icons/FilterIcon.vue';
3342
import throttle from 'docc-render/utils/throttle';
3443
import { INDEX_ROOT_KEY } from 'docc-render/constants/sidebar';
3544
import { baseNavStickyAnchorId } from 'docc-render/constants/nav';
45+
import ClearRoundedIcon from 'theme/components/Icons/ClearRoundedIcon.vue';
3646
3747
/**
3848
* @typedef NavigatorFlatItem
@@ -53,6 +63,7 @@ import { baseNavStickyAnchorId } from 'docc-render/constants/nav';
5363
export default {
5464
name: 'Navigator',
5565
components: {
66+
ClearRoundedIcon,
5667
FilterIcon,
5768
NavigatorCard,
5869
},
@@ -183,42 +194,72 @@ export default {
183194
top: $nav-height;
184195
max-height: calc(100vh - #{$nav-height} - var(--sticky-top-offset));
185196
height: 100%;
186-
padding-bottom: 50px;
187197
box-sizing: border-box;
188198
transition: max-height 0.3s linear;
189199
border-left: 1px solid var(--color-grid);
200+
201+
@include breakpoint(small) {
202+
position: static;
203+
max-height: 100%;
204+
border-left: none;
205+
}
190206
}
191207
192208
.navigator-filter {
193-
position: absolute;
194-
width: 100%;
195209
box-sizing: border-box;
196-
bottom: 0;
197-
z-index: 1;
198-
padding: 8px 20px;
199-
background: var(--color-fill-secondary);
210+
padding: 14px 30px;
200211
border-top: 1px solid var(--color-grid);
201212
213+
@include breakpoint(small) {
214+
border: none;
215+
padding: 10px 20px;
216+
}
217+
202218
.input-wrapper {
203219
position: relative;
204220
}
205221
206222
.filter-icon {
207223
width: 1em;
208224
position: absolute;
209-
left: 0;
225+
left: 14px;
226+
top: 50%;
227+
transform: translate(0%, -50%);
228+
color: var(--color-figure-gray-secondary);
229+
230+
&.colored {
231+
color: var(--color-link);
232+
}
233+
}
234+
235+
.clear-button {
236+
position: absolute;
237+
right: 10px;
210238
top: 50%;
211-
transform: translate(50%, -50%);
212-
color: var(--color-link);
239+
transform: translateY(-50%);
240+
display: flex;
241+
border-radius: 100%;
242+
243+
&:focus {
244+
@include focus-shadow;
245+
}
246+
247+
&.hide {
248+
display: none;
249+
}
250+
}
251+
252+
.clear-icon {
253+
width: 0.8em;
254+
color: var(--color-figure-gray-secondary);
213255
}
214256
215257
input {
216258
border: 1px solid var(--color-grid);
217-
padding: 10px;
259+
padding: 10px 25px 10px 40px;
218260
width: 100%;
219261
box-sizing: border-box;
220262
border-radius: $tiny-border-radius;
221-
padding-left: 35px;
222263
223264
&:focus {
224265
outline: none;

src/components/Navigator/NavigatorCard.vue

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<template>
22
<div class="navigator-card">
33
<div class="head-wrapper" :class="{ 'extra-info': showExtendedInfo }">
4+
<button class="close-card-mobile" @click="$emit('close')">
5+
<InlineCloseIcon class="icon-inline close-icon" />
6+
</button>
47
<NavigatorLeafIcon :kind="kind" class="card-icon" />
58
<span class="card-link">
69
{{ technology }}
@@ -34,6 +37,9 @@
3437
</template>
3538
</div>
3639
</div>
40+
<div class="card-slot">
41+
<slot />
42+
</div>
3743
</div>
3844
</template>
3945

@@ -44,6 +50,7 @@ import { INDEX_ROOT_KEY, LEAF_SIZES } from 'docc-render/constants/sidebar';
4450
import NavigatorLeafIcon from 'docc-render/components/Navigator/NavigatorLeafIcon.vue';
4551
import NavigatorCardItem from 'docc-render/components/Navigator/NavigatorCardItem.vue';
4652
import { RecycleScroller } from 'vue-virtual-scroller';
53+
import InlineCloseIcon from 'theme/components/Icons/InlineCloseIcon.vue';
4754
4855
/**
4956
* Renders the card for a technology and it's child symbols, in the navigator.
@@ -53,6 +60,7 @@ import { RecycleScroller } from 'vue-virtual-scroller';
5360
export default {
5461
name: 'NavigatorCard',
5562
components: {
63+
InlineCloseIcon,
5664
NavigatorCardItem,
5765
NavigatorLeafIcon,
5866
RecycleScroller,
@@ -307,33 +315,71 @@ export default {
307315
flex-direction: column;
308316
309317
.head-wrapper {
310-
padding: 10px 20px;
318+
padding: 10px 36px;
311319
border-bottom: 1px solid var(--color-grid);
312320
display: flex;
313-
align-items: center;
321+
align-items: baseline;
322+
position: relative;
323+
324+
@include breakpoint(small) {
325+
justify-content: center;
326+
}
314327
}
315328
316329
.card-icon {
330+
width: 19px;
331+
height: 19px;
317332
color: var(--color-figure-blue);
318333
}
334+
335+
@include breakpoint(small) {
336+
.card-slot {
337+
order: 2;
338+
}
339+
.card-body {
340+
order: 3;
341+
}
342+
}
319343
}
320344
321345
.no-items-wrapper {
322346
color: var(--color-figure-gray-tertiary);
323347
@include font-styles(body-reduced);
324348
}
325349
350+
.close-card-mobile {
351+
display: none;
352+
position: absolute;
353+
left: 20px;
354+
top: 50%;
355+
transform: translateY(-50%);
356+
color: var(--color-link);
357+
358+
@include breakpoint(small) {
359+
display: flex;
360+
}
361+
362+
.close-icon {
363+
width: 1em;
364+
}
365+
}
366+
326367
.card-body {
327-
padding: 10px 20px;
368+
--card-horizontal-spacing: 32px;
369+
padding: 18px var(--card-horizontal-spacing);
328370
// right padding is added by the items, so visually the scroller is stuck to the side
329371
padding-right: 0;
330372
flex: 1 1 auto;
331373
min-height: 0;
374+
@include breakpoint(small) {
375+
--card-horizontal-spacing: 20px;
376+
padding-top: 0;
377+
}
332378
}
333379
334380
.card-link {
335381
color: var(--color-text);
336-
@include font-styles(body-tight);
382+
@include font-styles(body-reduced);
337383
font-weight: $font-weight-semibold;
338384
}
339385

0 commit comments

Comments
 (0)