Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.

Commit 5020186

Browse files
authored
Fix code viewer title and buttons disappearing (#1258)
1 parent 47f0752 commit 5020186

File tree

1 file changed

+61
-63
lines changed

1 file changed

+61
-63
lines changed

src/app/shared/example-viewer/example-viewer.html

Lines changed: 61 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,65 @@
11
<div class="docs-example-viewer-wrapper">
2-
@switch (view) {
3-
@case ('full') {
2+
@if (view === 'snippet') {
3+
<div class="docs-example-viewer-source-compact">
4+
<div class="button-bar">
5+
<button mat-icon-button type="button" (click)="copySource(snippet)"
6+
class="docs-example-source-copy docs-example-button" matTooltip="Copy snippet"
7+
title="Copy example source" aria-label="Copy example source to clipboard">
8+
<mat-icon>content_copy</mat-icon>
9+
</button>
10+
<button mat-icon-button type="button" (click)="toggleCompactView()"
11+
class="docs-example-compact-toggle docs-example-button" matTooltip="View full example"
12+
aria-label="View less">
13+
<mat-icon>
14+
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" focusable="false">
15+
<polygon points="13,3 13,5 17.59,5 5,17.59 5,13 3,13 3,21 11,21 11,19 6.41,19 19,6.41 19,11 21,11 21,3"/>
16+
</svg>
17+
</mat-icon>
18+
</button>
19+
</div>
20+
21+
@if (fileUrl) {
22+
<code-snippet [source]="fileUrl"/>
23+
}
24+
</div>
25+
}
26+
27+
@else {
28+
<div class="docs-example-viewer-title">
29+
<div class="docs-example-viewer-title-spacer">{{exampleData?.title}}</div>
30+
31+
<button
32+
mat-icon-button
33+
type="button"
34+
[attr.aria-label]="'Copy link to ' + exampleData?.title + ' example to the clipboard'"
35+
matTooltip="Copy link to example"
36+
(click)="_copyLink()">
37+
<mat-icon>link</mat-icon>
38+
</button>
39+
40+
@if (showCompactToggle) {
41+
<button mat-icon-button
42+
(click)="toggleCompactView()"
43+
matTooltip="View snippet only"
44+
aria-label="View less">
45+
<mat-icon>
46+
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" focusable="false">
47+
<path
48+
d="M15.41,10H20v2h-8V4h2v4.59L20.59,2L22,3.41L15.41,10z M4,12v2h4.59L2,20.59L3.41,22L10,15.41V20h2v-8H4z"/>
49+
</svg>
50+
</mat-icon>
51+
</button>
52+
}
53+
54+
<button mat-icon-button type="button" (click)="toggleSourceView()"
55+
[matTooltip]="view === 'demo' ? 'View code' : 'Hide code'" aria-label="View source">
56+
<mat-icon>code</mat-icon>
57+
</button>
58+
59+
<stack-blitz-button [example]="example"></stack-blitz-button>
60+
</div>
61+
62+
@if (view === 'full') {
463
<div class="docs-example-viewer-source">
564
<mat-tab-group animationDuration="0ms" [(selectedIndex)]="selectedTab" mat-stretch-tabs="false">
665
@for (tabName of _getExampleTabNames(); track tabName) {
@@ -18,67 +77,6 @@
1877
</mat-tab-group>
1978
</div>
2079
}
21-
22-
@case ('snippet') {
23-
<div class="docs-example-viewer-source-compact">
24-
<div class="button-bar">
25-
<button mat-icon-button type="button" (click)="copySource(snippet)"
26-
class="docs-example-source-copy docs-example-button" matTooltip="Copy snippet"
27-
title="Copy example source" aria-label="Copy example source to clipboard">
28-
<mat-icon>content_copy</mat-icon>
29-
</button>
30-
<button mat-icon-button type="button" (click)="toggleCompactView()"
31-
class="docs-example-compact-toggle docs-example-button" matTooltip="View full example"
32-
aria-label="View less">
33-
<mat-icon>
34-
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" focusable="false">
35-
<polygon points="13,3 13,5 17.59,5 5,17.59 5,13 3,13 3,21 11,21 11,19 6.41,19 19,6.41 19,11 21,11 21,3"/>
36-
</svg>
37-
</mat-icon>
38-
</button>
39-
</div>
40-
41-
@if (fileUrl) {
42-
<code-snippet [source]="fileUrl"/>
43-
}
44-
</div>
45-
}
46-
47-
@default {
48-
<div class="docs-example-viewer-title">
49-
<div class="docs-example-viewer-title-spacer">{{exampleData?.title}}</div>
50-
51-
<button
52-
mat-icon-button
53-
type="button"
54-
[attr.aria-label]="'Copy link to ' + exampleData?.title + ' example to the clipboard'"
55-
matTooltip="Copy link to example"
56-
(click)="_copyLink()">
57-
<mat-icon>link</mat-icon>
58-
</button>
59-
60-
@if (showCompactToggle) {
61-
<button mat-icon-button
62-
(click)="toggleCompactView()"
63-
matTooltip="View snippet only"
64-
aria-label="View less">
65-
<mat-icon>
66-
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" focusable="false">
67-
<path
68-
d="M15.41,10H20v2h-8V4h2v4.59L20.59,2L22,3.41L15.41,10z M4,12v2h4.59L2,20.59L3.41,22L10,15.41V20h2v-8H4z"/>
69-
</svg>
70-
</mat-icon>
71-
</button>
72-
}
73-
74-
<button mat-icon-button type="button" (click)="toggleSourceView()"
75-
[matTooltip]="view === 'demo' ? 'View code' : 'Hide code'" aria-label="View source">
76-
<mat-icon>code</mat-icon>
77-
</button>
78-
79-
<stack-blitz-button [example]="example"></stack-blitz-button>
80-
</div>
81-
}
8280
}
8381

8482
@if (view !== 'snippet') {

0 commit comments

Comments
 (0)