-
Notifications
You must be signed in to change notification settings - Fork 96
Expand file tree
/
Copy pathNcAppSidebar.vue
More file actions
1810 lines (1612 loc) Ā· 43.1 KB
/
NcAppSidebar.vue
File metadata and controls
1810 lines (1612 loc) Ā· 43.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!--
- SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
- SPDX-License-Identifier: AGPL-3.0-or-later
-->
<docs>
### Exposed CSS Variables
| Variable | Description |
|-------------------------|-------------------------------------------------------------------------------------------------------------------------------------------|
| `--app-sidebar-padding` | The padding between the toggle button and the page border. |
| `--app-sidebar-offset` | The minimal offset width required to be reserved for the toggle button. <br /> Automatically changes to 0 when there is no toggle button. |
### General description
This component provides a way to include the standardised sidebar.
The standard properties like name, subname, starred, etc. allow to automatically
include a standard-header like it's used by the files app.
To conditionally show the sidebar either use `v-if` on the sidebar component,
or use the `open` property of the component to control the state.
Using `v-show` directly will result in usability issues due to internal focus trap handling.
### Standard usage
```vue
<template>
<div class="content-styleguidist">
<main id="content-styleguidist-1" />
<NcAppSidebar
v-model:open="open"
:starred="starred"
name="cat-picture.jpg"
subname="last edited 3 weeks ago"
background="https://nextcloud.com/wp-content/uploads/2022/08/nextcloud-logo-icon.svg"
@figure-click="figureClick">
<NcAppSidebarTab name="Search" id="search-tab">
<template #icon>
<IconMagnify :size="20" />
</template>
Search tab content
</NcAppSidebarTab>
<NcAppSidebarTab name="Settings" id="settings-tab">
<template #icon>
<IconCogOutline :size="20" />
</template>
Settings tab content
</NcAppSidebarTab>
<NcAppSidebarTab name="Sharing" id="share-tab">
<template #icon>
<IconShareVariantOutline :size="20" />
</template>
Sharing tab content
</NcAppSidebarTab>
</NcAppSidebar>
</div>
</template>
<script>
import IconMagnify from 'vue-material-design-icons/Magnify.vue'
import IconCogOutline from 'vue-material-design-icons/CogOutline.vue'
import IconShareVariantOutline from 'vue-material-design-icons/ShareVariantOutline.vue'
export default {
components: {
IconMagnify,
IconCogOutline,
IconShareVariantOutline,
},
provide() {
return {
'NcContent:selector': '#content-styleguidist-1',
}
},
data() {
return {
open: true,
starred: false,
}
},
methods: {
figureClick() {
alert('figure clicked')
},
},
}
</script>
<style scoped>
/* This styles just mock NcContent and NcAppContent */
.content-styleguidist {
--app-sidebar-padding: 8px;
--app-sidebar-offset: calc(var(--app-sidebar-padding) + var(--default-clickable-area));
display: flex;
position: relative !important;
/* Just to prevent jumping when the sidebar is hidden */
min-height: 360px;
overflow: hidden;
main {
width: 100%;
}
}
/* Fix styles on this style guide page */
@media only screen and (max-width: 512px) {
:deep(aside) {
width: calc(100vw - 64px) !important;
}
}
</style>
```
### Dynamic tabs
Sidebar tabs and their content can be changed dynamically.
Single tab is rendered without navigation, but it is possible to force it.
```vue
<template>
<div class="content-styleguidist">
<main id="content-styleguidist-2">
<NcCheckboxRadioSwitch v-model="forceTabs">Force tab navigation</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch v-model="showTabs[0]">Show search tab</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch v-model="showTabs[1]">Show settings tab</NcCheckboxRadioSwitch>
<NcCheckboxRadioSwitch v-model="showTabs[2]">Show sharing tab</NcCheckboxRadioSwitch>
</main>
<NcAppSidebar
v-model:open="open"
:force-tabs="forceTabs"
name="cat-picture.jpg"
subname="last edited 3 weeks ago">
<NcAppSidebarTab v-if="showTabs[0]" name="Search" id="search-tab">
<template #icon>
<IconMagnify :size="20" />
</template>
Search tab content
</NcAppSidebarTab>
<NcAppSidebarTab v-if="showTabs[1]" name="Settings" id="settings-tab">
<template #icon>
<IconCogOutline :size="20" />
</template>
Settings
</NcAppSidebarTab>
<NcAppSidebarTab v-if="showTabs[2]" name="Sharing" id="share-tab">
<template #icon>
<IconShareVariantOutline :size="20" />
</template>
Sharing tab content
</NcAppSidebarTab>
</NcAppSidebar>
</div>
</template>
<script>
import IconMagnify from 'vue-material-design-icons/Magnify.vue'
import IconCogOutline from 'vue-material-design-icons/CogOutline.vue'
import IconShareVariantOutline from 'vue-material-design-icons/ShareVariantOutline.vue'
export default {
components: {
IconMagnify,
IconCogOutline,
IconShareVariantOutline,
},
provide() {
return {
'NcContent:selector': '#content-styleguidist-2',
}
},
data() {
return {
open: true,
forceTabs: false,
showTabs: [true, true, false],
}
},
}
</script>
<style scoped>
/* This styles just mock NcContent and NcAppContent */
.content-styleguidist {
--app-sidebar-padding: 8px;
--app-sidebar-offset: calc(var(--app-sidebar-padding) + var(--default-clickable-area));
display: flex;
position: relative !important;
/* Just to prevent jumping when the sidebar is hidden */
min-height: 360px;
overflow: hidden;
main {
width: 100%;
}
}
/* Fix styles on this style guide page */
@media only screen and (max-width: 512px) {
:deep(aside) {
width: calc(100vw - 64px) !important;
}
}
</style>
```
### Tabs order and programmatic activation
To customize the order of tabs, ``order`` prop can be used on child components.
``active`` prop on NcAppSidebar can be modified to show required tab as active
```vue
<template>
<div class="content-styleguidist">
<main id="content-styleguidist-3">
<NcSelect v-model="active" :options="['search-tab', 'settings-tab', 'share-tab']"/>
</main>
<NcAppSidebar
name="cat-picture.jpg"
subname="last edited 3 weeks ago"
v-model:open="open"
v-model:active="active">
<NcAppSidebarTab name="Search" id="search-tab" :order="3">
<template #icon>
<IconMagnify :size="20" />
</template>
Search tab content
</NcAppSidebarTab>
<NcAppSidebarTab name="Settings" id="settings-tab" :order="2">
<template #icon>
<IconCogOutline :size="20" />
</template>
Settings
</NcAppSidebarTab>
<NcAppSidebarTab name="Sharing" id="share-tab" :order="1">
<template #icon>
<IconShareVariantOutline :size="20" />
</template>
Sharing tab content
</NcAppSidebarTab>
</NcAppSidebar>
</div>
</template>
<script>
import IconMagnify from 'vue-material-design-icons/Magnify.vue'
import IconCogOutline from 'vue-material-design-icons/CogOutline.vue'
import IconShareVariantOutline from 'vue-material-design-icons/ShareVariantOutline.vue'
export default {
components: {
IconMagnify,
IconCogOutline,
IconShareVariantOutline,
},
provide() {
return {
'NcContent:selector': '#content-styleguidist-3',
}
},
data() {
return {
open: true,
active: 'search-tab',
}
},
}
</script>
<style scoped>
/* This styles just mock NcContent and NcAppContent */
.content-styleguidist {
--app-sidebar-padding: 8px;
--app-sidebar-offset: calc(var(--app-sidebar-padding) + var(--default-clickable-area));
display: flex;
position: relative !important;
/* Just to prevent jumping when the sidebar is hidden */
min-height: 360px;
overflow: hidden;
main {
width: 100%;
}
}
/* Fix styles on this style guide page */
@media only screen and (max-width: 512px) {
:deep(aside) {
width: calc(100vw - 64px) !important;
}
}
</style>
```
### Editable name
```vue
<template>
<div class="content-styleguidist">
<main id="content-styleguidist-4" />
<NcAppSidebar
v-model:open="open"
v-model:name="name"
:name-editable="true"
name-placeholder="Filename"
subname="last edited 3 weeks ago">
<!-- Insert your slots and tabs here -->
</NcAppSidebar>
</div>
</template>
<script>
export default {
provide() {
return {
'NcContent:selector': '#content-styleguidist-4',
}
},
data() {
return {
open: true,
name: 'cat-picture.jpg',
}
},
}
</script>
<style scoped>
/* This styles just mock NcContent and NcAppContent */
.content-styleguidist {
--app-sidebar-padding: 8px;
--app-sidebar-offset: calc(var(--app-sidebar-padding) + var(--default-clickable-area));
display: flex;
position: relative !important;
/* Just to prevent jumping when the sidebar is hidden */
min-height: 360px;
overflow: hidden;
main {
width: 100%;
}
}
/* Fix styles on this style guide page */
@media only screen and (max-width: 512px) {
:deep(aside) {
width: calc(100vw - 64px) !important;
}
}
</style>
```
### Editable name after click with custom tertiary action
```vue
<template>
<div class="content-styleguidist">
<main id="content-styleguidist-5" />
<NcAppSidebar
:name="name"
v-model:open="open"
v-model:name-editable="nameEditable"
:name-placeholder="namePlaceholder"
:subname="subname"
@update:name="nameUpdate">
<template #tertiary-actions>
<form>
<input type="checkbox" @click="toggledCheckbox"/>
</form>
</template>
</NcAppSidebar>
</div>
</template>
<script>
export default {
provide() {
return {
'NcContent:selector': '#content-styleguidist-5',
}
},
data() {
return {
open: true,
name: 'cat-picture.jpg',
namePlaceholder: 'Filename',
subname: 'last edited 3 weeks ago',
nameEditable: false
}
},
methods: {
nameUpdate(e) {
this.name = e
},
toggledCheckbox() {
alert('toggle')
}
}
}
</script>
<style scoped>
/* This styles just mock NcContent and NcAppContent */
.content-styleguidist {
--app-sidebar-padding: 8px;
--app-sidebar-offset: calc(var(--app-sidebar-padding) + var(--default-clickable-area));
display: flex;
position: relative !important;
/* Just to prevent jumping when the sidebar is hidden */
min-height: 360px;
overflow: hidden;
main {
width: 100%;
}
}
/* Fix styles on this style guide page */
@media only screen and (max-width: 512px) {
:deep(aside) {
width: calc(100vw - 64px) !important;
}
}
</style>
```
### Custom subname
Instead of using the `subname` prop you can use the same called slot. This is handy if you need to add accessible information.
Like in the following example where the goal is to show a star icon to mark the file a favorite.
Simply adding `ā
` would not work as screen readers might not or wrongly announce the icon meaning this information is lost.
A working alternative would be using an icon together with an `aria-label`:
```vue
<template>
<div class="content-styleguidist">
<main id="content-styleguidist-6" />
<NcAppSidebar
v-model:open="open"
name="cat-picture.jpg">
<template #subname>
<NcIconSvgWrapper inline :path="mdiStar" name="Favorite" />
123 KiB, a month ago
</template>
</NcAppSidebar>
</div>
</template>
<script>
import { mdiStar } from '@mdi/js'
export default {
setup() {
return {
mdiStar,
}
},
provide() {
return {
'NcContent:selector': '#content-styleguidist-6',
}
},
data() {
return {
open: true,
}
},
}
</script>
<style scoped>
/* This styles just mock NcContent and NcAppContent */
.content-styleguidist {
--app-sidebar-padding: 8px;
--app-sidebar-offset: calc(var(--app-sidebar-padding) + var(--default-clickable-area));
display: flex;
position: relative !important;
/* Just to prevent jumping when the sidebar is hidden */
min-height: 360px;
overflow: hidden;
main {
width: 100%;
}
}
/* Fix styles on this style guide page */
@media only screen and (max-width: 512px) {
:deep(aside) {
width: calc(100vw - 64px) !important;
}
}
</style>
```
### Empty sidebar for e.g. empty content component.
```vue
<template>
<div class="content-styleguidist">
<main id="content-styleguidist-7" />
<NcAppSidebar
v-model:open="open"
name="cat-picture.jpg"
:empty="true">
<NcEmptyContent name="Content not found.">
<template #icon>
<Magnify :size="20" />
</template>
</NcEmptyContent>
</NcAppSidebar>
</div>
</template>
<script>
import Magnify from 'vue-material-design-icons/Magnify.vue'
export default {
components: {
Magnify,
},
provide() {
return {
'NcContent:selector': '#content-styleguidist-7',
}
},
data() {
return {
open: true,
}
},
}
</script>
<style scoped>
/* This styles just mock NcContent and NcAppContent */
.content-styleguidist {
--app-sidebar-padding: 8px;
--app-sidebar-offset: calc(var(--app-sidebar-padding) + var(--default-clickable-area));
display: flex;
position: relative !important;
/* Just to prevent jumping when the sidebar is hidden */
min-height: 360px;
overflow: hidden;
main {
width: 100%;
}
}
/* Fix styles on this style guide page */
@media only screen and (max-width: 512px) {
:deep(aside) {
width: calc(100vw - 64px) !important;
}
}
</style>
```
### Conditionally show the sidebar with `open`
If the sidebar should be shown conditionally, you can use `open` prop to define sidebar visibility.
It automatically shows a toggle button to open the sidebar if it is closed.
You can also use `--app-sidebar-offset` CSS variable to preserve space
for the toggle button, for example, in top bar of `NcAppContent`.
The built-in toggle button can be removed with `no-toggle` prop.
Note: the built-in toggle button is only available then NcAppSidebar is used in NcContent.
```vue
<template>
<div class="content-styleguidist">
<main id="content-styleguidist-8">
<div class="top-bar">
<NcButton variant="primary">Start a call</NcButton>
</div>
</main>
<NcAppSidebar
v-model:open="open"
name="cat-picture.jpg"
subname="last edited 3 weeks ago">
<NcAppSidebarTab name="Settings" id="settings-tab">
<template #icon>
<Cog :size="20" />
</template>
Single tab content
</NcAppSidebarTab>
</NcAppSidebar>
</div>
</template>
<script>
import Cog from 'vue-material-design-icons/Cog'
export default {
components: {
Cog,
},
provide() {
return {
'NcContent:selector': '#content-styleguidist-8',
}
},
data() {
return {
open: true,
}
},
}
</script>
<style scoped>
/* This styles just mock NcContent and NcAppContent */
.content-styleguidist {
--app-sidebar-padding: 8px;
--app-sidebar-offset: calc(var(--app-sidebar-padding) + var(--default-clickable-area));
display: flex;
position: relative !important;
/* Just to prevent jumping when the sidebar is hidden */
min-height: 360px;
overflow: hidden;
main {
width: 100%;
}
}
/* Fix styles on this style guide page */
@media only screen and (max-width: 512px) {
:deep(aside) {
width: calc(100vw - 64px) !important;
}
}
.top-bar {
display: flex;
justify-content: flex-end;
/* preserve space for toggle button */
padding-inline-end: var(--app-sidebar-offset);
/* same as on toggle button, but doesn't have to be the same */
margin: var(--app-sidebar-padding);
}
</style>
```
### Conditionally show the sidebar programmatically with `v-if`
If the sidebar should be shown conditionally without any explicit toggle button, you can use `v-if`.
**Note about performance**: using `v-if` might result in bad performance and loosing sidebar content state.
**Note about `v-show`**: using `v-show` to hide sidebar will result in usability issues due to active focus trap on mobile.
```vue
<template>
<div class="content-styleguidist">
<main id="content-styleguidist-9">
<div class="top-bar">
<NcButton @click.prevent="open = !open">
Toggle sidebar
</NcButton>
</div>
</main>
<!-- The sidebar -->
<NcAppSidebar
v-if="open"
name="cat-picture.jpg"
subname="last edited 3 weeks ago"
@close="open = false">
<NcAppSidebarTab name="Settings" id="settings-tab">
<template #icon>
<Cog :size="20" />
</template>
Single tab content
</NcAppSidebarTab>
</NcAppSidebar>
</div>
</template>
<script>
import Cog from 'vue-material-design-icons/Cog'
export default {
components: {
Cog,
},
provide() {
return {
'NcContent:selector': '#content-styleguidist-9',
}
},
data() {
return {
open: true,
}
},
}
</script>
<style scoped>
/* This styles just mock NcContent and NcAppContent */
.content-styleguidist {
--app-sidebar-padding: 8px;
--app-sidebar-offset: calc(var(--app-sidebar-padding) + var(--default-clickable-area));
display: flex;
position: relative !important;
/* Just to prevent jumping when the sidebar is hidden */
min-height: 360px;
overflow: hidden;
main {
width: 100%;
}
}
/* Fix styles on this style guide page */
@media only screen and (max-width: 512px) {
:deep(aside) {
width: calc(100vw - 64px) !important;
}
}
.top-bar {
display: flex;
justify-content: flex-end;
/* preserve space for toggle button */
padding-inline-end: var(--app-sidebar-offset);
/* same as on toggle button, but doesn't have to be the same */
margin: var(--app-sidebar-padding);
}
</style>
```
</docs>
<template>
<transition
appear
name="slide-right"
@afterEnter="onAfterEnter"
@afterLeave="onAfterLeave">
<aside
v-show="open"
id="app-sidebar-vue"
ref="sidebar"
class="app-sidebar"
:aria-labelledby="`app-sidebar-vue-${uid}__header`"
@keydown.esc="onKeydownEsc">
<!--
We cannot render toggle button inside sidebar (aside#app-sidebar-vue), because it is hidden then the toggle is needed.
But we also need transition with the sidebar to be the root of this component to use it as a single UI element, allowing to use `v-show`.
So we cannot render the toggle button directly in this component.
As a simple solution - render it in the content to keep correct position.
-->
<Teleport v-if="ncContentSelector && !open && !noToggle" :to="ncContentSelector">
<NcButton
ref="toggle"
:aria-label="t('Open sidebar')"
class="app-sidebar__toggle"
:class="toggleClasses"
variant="tertiary"
v-bind="toggleAttrs"
@click="$emit('update:open', true)">
<template #icon>
<!-- @slot Custom icon for the toggle button, defaults to the dock-right icon from MDI -->
<slot name="toggle-icon">
<IconDockRight :size="20" />
</slot>
</template>
</NcButton>
</Teleport>
<header
class="app-sidebar-header"
:class="{
'app-sidebar-header--with-figure': isSlotPopulated($slots.header?.()) || background,
'app-sidebar-header--compact': compact,
}">
<!-- @slot Alternative to the default header info: use for bare NcAppSidebar with tabs.
NcAppSidebarHeader would be required to use for accessibility reasons.
This will be overridden by `empty` prop.
-->
<slot v-if="!empty" name="info">
<!-- container for figure and description, allows easy switching to compact mode -->
<div class="app-sidebar-header__info">
<!-- sidebar header illustration/figure -->
<div
v-if="(isSlotPopulated($slots.header?.()) || background)"
class="app-sidebar-header__figure"
:class="{
'app-sidebar-header__figure--with-action': hasFigureClickListener,
}"
:style="{
backgroundImage: `url(${background})`,
}"
tabindex="0"
@click="onFigureClick"
@keydown.enter="onFigureClick">
<slot class="app-sidebar-header__background" name="header" />
</div>
<!-- sidebar details -->
<div
class="app-sidebar-header__desc"
:class="{
'app-sidebar-header__desc--with-tertiary-action': canStar || isSlotPopulated($slots['tertiary-actions']?.()),
'app-sidebar-header__desc--editable': nameEditable && !subname,
'app-sidebar-header__desc--with-subname--editable': nameEditable && subname,
'app-sidebar-header__desc--without-actions': !isSlotPopulated($slots['secondary-actions']?.()),
}">
<!-- favourite icon -->
<div v-if="canStar || isSlotPopulated($slots['tertiary-actions']?.())" class="app-sidebar-header__tertiary-actions">
<slot name="tertiary-actions">
<NcButton
v-if="canStar"
:aria-label="favoriteTranslated"
:pressed="isStarred"
class="app-sidebar-header__star"
variant="secondary"
@click.prevent="toggleStarred">
<template #icon>
<NcLoadingIcon v-if="starLoading" />
<IconStar v-else-if="isStarred" :size="20" />
<IconStarOutline v-else :size="20" />
</template>
</NcButton>
</slot>
</div>
<!-- name -->
<div class="app-sidebar-header__name-container">
<div class="app-sidebar-header__mainname-container">
<!-- main name -->
<NcAppSidebarHeader
v-show="!nameEditable"
class="app-sidebar-header__mainname"
:name
:linkify="linkifyName"
:title
:tabindex="nameEditable ? 0 : -1"
@click.self="editName" />
<template v-if="nameEditable">
<form
v-click-outside="() => onSubmitName()"
class="app-sidebar-header__mainname-form"
@submit.prevent="onSubmitName">
<input
ref="nameInput"
v-focus
class="app-sidebar-header__mainname-input"
type="text"
:placeholder="namePlaceholder"
:value="name"
@keydown.esc.stop="onDismissEditing"
@input="onNameInput">
<NcButton
:aria-label="changeNameTranslated"
type="submit"
variant="tertiary-no-background">
<template #icon>
<IconArrowRight :size="20" />
</template>
</NcButton>
</form>
</template>
<!-- header main menu -->
<NcActions
v-if="isSlotPopulated($slots['secondary-actions']?.())"
class="app-sidebar-header__menu"
:forceMenu="forceMenu">
<slot name="secondary-actions" />
</NcActions>
</div>
<!-- secondary name -->
<p
v-if="subname.trim() !== '' || $slots['subname']"
:title="subtitle || undefined"
class="app-sidebar-header__subname">
<!-- @slot Alternative to the `subname` prop can be used for more complex content. It will be rendered within a `p` tag. -->
<slot name="subname">
{{ subname }}
</slot>
</p>
</div>
</div>
</div>
</slot>
<!-- a11y fallback for empty content -->
<NcAppSidebarHeader
v-else
class="app-sidebar-header__mainname--hidden"
:name
tabindex="-1" />
<NcButton
ref="closeButton"
:aria-label="closeTranslated"
:title="closeTranslated"
class="app-sidebar__close"
variant="tertiary"
@click.prevent="closeSidebar">
<template #icon>
<IconClose :size="20" />
</template>
</NcButton>
<div v-if="isSlotPopulated($slots.description?.()) && !empty" class="app-sidebar-header__description">
<slot name="description" />
</div>
</header>
<NcAppSidebarTabs
v-show="!loading"
ref="tabs"
:active="active"
:forceTabs="forceTabs"
@update:active="onUpdateActive">
<slot />
</NcAppSidebarTabs>
<NcEmptyContent v-if="loading">
<template #icon>
<NcLoadingIcon :size="64" />
</template>
</NcEmptyContent>
</aside>
</transition>
</template>
<script>
import { vOnClickOutside as ClickOutside } from '@vueuse/components'
import { createFocusTrap } from 'focus-trap'
import { provide, ref, warn } from 'vue'
import IconArrowRight from 'vue-material-design-icons/ArrowRight.vue'
import IconClose from 'vue-material-design-icons/Close.vue'
import IconDockRight from 'vue-material-design-icons/DockRight.vue'
import IconStar from 'vue-material-design-icons/Star.vue'
import IconStarOutline from 'vue-material-design-icons/StarOutline.vue'
import NcAppSidebarTabs from './NcAppSidebarTabs.vue'
import { useIsSmallMobile } from '../../composables/useIsMobile/index.js'
import Focus from '../../directives/Focus/index.ts'
import { t } from '../../l10n.ts'
import { createElementId } from '../../utils/createElementId.ts'
import { getTrapStack } from '../../utils/focusTrap.ts'
import { isSlotPopulated } from '../../utils/isSlotPopulated.ts'
import { logger } from '../../utils/logger.ts'
import NcActions from '../NcActions/index.js'
import NcAppSidebarHeader from '../NcAppSidebarHeader/index.ts'
import NcButton from '../NcButton/index.ts'
import { CONTENT_SELECTOR_KEY } from '../NcContent/constants.ts'
import NcEmptyContent from '../NcEmptyContent/index.ts'
import NcLoadingIcon from '../NcLoadingIcon/index.ts'
export default {
name: 'NcAppSidebar',
components: {
NcActions,
NcAppSidebarHeader,
NcAppSidebarTabs,
NcButton,
NcLoadingIcon,
NcEmptyContent,
IconArrowRight,
IconClose,
IconDockRight,
IconStar,
IconStarOutline,
},
directives: {
Focus,
/** @type {import('vue').ObjectDirective} */
ClickOutside,
},
inject: {
ncContentSelector: {
from: CONTENT_SELECTOR_KEY,
default: undefined,
},
},
props: {
/**
* The active tab
*/
active: {
type: String,
default: '',
},
/**
* Main text of the sidebar
*/
name: {
type: String,
required: true,