Skip to content

Commit d397522

Browse files
fix: Share button relocation + snackbar z-index fixes (#1138)
## Summary ### Share button - **Relocate share button** to top-right of content area (was floating in an awkward position mid-page) - **Fix visibility** — show on all content pages (previously only showed on TOC-matched pages) ### Snackbar - **Fix z-index** — raise `#snackbar` from `z-index: 1` to `z-index: 10001` so the "Copied!" toast appears above the cookie consent banner (`z-index: 10000`) ### Nullable - **Enable nullable globally** via `_ViewImports.cshtml` with `#nullable enable` (instead of per-file directives that were causing Razor compilation errors) ## Testing - Share button visually confirmed via Playwright screenshot on a live Aspire-hosted dev instance - Snackbar z-index verified via browser CSS inspection (`z-index: 10001` active in page) - Cookie consent banner forced with `?testConsent=true` — snackbar confirmed visible above banner
1 parent a8757c4 commit d397522

6 files changed

Lines changed: 82 additions & 11 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ EssentialCSharp.Web/wwwroot/Chapters
3939
EssentialCSharp.Web/wwwroot/sitemap.xml
4040
EssentialCSharp.Web/Chapters/
4141
EssentialCSharp.Web/ListingSourceCode
42+
EssentialCSharp.Web/wwwroot/js/chapter-listings.json
4243
Utilities/EssentialCSharp.Web/Chapters/
4344
Utilities/EssentialCSharp.Web/wwwroot/sitemap.xml
4445
Utilities/EssentialCSharp.Web/wwwroot/Chapters/

EssentialCSharp.Web/Views/Shared/_Layout.cshtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@
158158
<main id="site-layout" class="layout">
159159
<div id="sidebarContainer" class="background-grey-lighten-2"></div>
160160
<div class="container my-5 pb-5">
161+
<div id="page-share-host"></div>
161162
<div id="page-nav-host"></div>
162163
@RenderBody()
163164
</div>

EssentialCSharp.Web/src/App.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { onMounted, onUnmounted, provide, reactive, watch } from "vue";
33
import HeaderStatus from "./components/HeaderStatus.vue";
44
import SidebarPanel from "./components/SidebarPanel.vue";
55
import PageNavigation from "./components/PageNavigation.vue";
6+
import PageShareAction from "./components/PageShareAction.vue";
67
import SnackbarMessage from "./components/SnackbarMessage.vue";
78
import ChatWidget from "./components/ChatWidget.vue";
89
import CodeRunnerModal from "./components/CodeRunnerModal.vue";
@@ -74,6 +75,10 @@ watch(() => shell.smallScreen, updateLayoutClasses);
7475
<PageNavigation />
7576
</Teleport>
7677
78+
<Teleport to="#page-share-host">
79+
<PageShareAction />
80+
</Teleport>
81+
7782
<Teleport to="#snackbar-host">
7883
<SnackbarMessage />
7984
</Teleport>

EssentialCSharp.Web/src/components/PageNavigation.vue

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,6 @@ const shell = inject("shell");
1616
( or use the <i class="fa-solid fa-square-caret-left" /> key)
1717
</span>
1818
</div>
19-
<div v-if="shell.isContentPage" class="turn-page-tooltip">
20-
<button id="share-btn" type="button" class="arrow-btn" aria-label="Share this page" @click="shell.shareCurrentPage()">
21-
<i class="fa-solid fa-share-from-square arrow-icon" />
22-
</button>
23-
<span class="turn-page-tooltip-text tooltip-center">
24-
<b>Share Page</b>
25-
<br />
26-
Copies a link to this page
27-
</span>
28-
</div>
2919
<div class="turn-page-tooltip">
3020
<a v-if="shell.nextPageUrl" id="next-btn" :href="shell.nextPageUrl" class="arrow-btn">
3121
<i class="fa fa-solid fa-arrow-right icon-light arrow-icon" />
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<script setup>
2+
import { inject } from "vue";
3+
4+
const shell = inject("shell");
5+
</script>
6+
7+
<template>
8+
<div v-if="shell.isContentPage" class="page-share-action">
9+
<div class="turn-page-tooltip">
10+
<button
11+
id="share-btn"
12+
type="button"
13+
class="arrow-btn page-share-btn"
14+
aria-label="Share this page"
15+
@click="shell.shareCurrentPage()"
16+
>
17+
<i class="fa-solid fa-share-from-square arrow-icon" />
18+
</button>
19+
<span class="turn-page-tooltip-text page-share-tooltip">
20+
<b>Share Page</b>
21+
<br />
22+
Copies a link to this page
23+
</span>
24+
</div>
25+
</div>
26+
</template>

EssentialCSharp.Web/wwwroot/css/styles.css

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,54 @@ a:hover {
479479
padding: 0;
480480
}
481481

482+
#page-share-host {
483+
display: flex;
484+
justify-content: flex-end;
485+
}
486+
487+
.page-share-action {
488+
margin-bottom: 1rem;
489+
}
490+
491+
.page-share-action .turn-page-tooltip {
492+
display: inline-block;
493+
}
494+
495+
.page-share-action .page-share-btn {
496+
display: block;
497+
border: none;
498+
padding: 0;
499+
border-radius: 3rem;
500+
background-color: var(--primary-color);
501+
background: var(--primary-color);
502+
width: 2.5rem;
503+
height: 2.5rem;
504+
font-size: 1.5rem;
505+
cursor: pointer;
506+
text-align: center;
507+
position: relative;
508+
}
509+
510+
.page-share-action .arrow-icon {
511+
position: absolute;
512+
top: 50%;
513+
left: 50%;
514+
transform: translate(-50%, -50%);
515+
color: white;
516+
}
517+
518+
.page-share-action .page-share-tooltip {
519+
right: 0;
520+
left: auto;
521+
top: calc(100% + 0.5rem);
522+
}
523+
524+
@media only screen and (max-width: 768px) {
525+
.page-share-action {
526+
margin-bottom: 0.75rem;
527+
}
528+
}
529+
482530
/* Chapter Navigation Sidebar Styles */
483531

484532
.sidebar {
@@ -863,7 +911,7 @@ details > summary::-webkit-details-marker {
863911
border-radius: 2px; /* Rounded borders */
864912
padding: 16px; /* Padding */
865913
position: fixed; /* Sit on top of the screen */
866-
z-index: 1; /* Add a z-index if needed */
914+
z-index: 10001; /* Above cookie consent banner (z-index: 10000) */
867915
left: 50%; /* Center the snackbar */
868916
bottom: 30px; /* 30px from the bottom */
869917
}

0 commit comments

Comments
 (0)