|
| 1 | +<script lang="ts"> |
| 2 | + import { page } from "$app/stores" |
| 3 | +</script> |
| 4 | + |
| 5 | +<div> |
| 6 | + <header> |
| 7 | + <div class="signedInStatus"> |
| 8 | + <p class="nojs-show loaded"> |
| 9 | + {#if $page.data.session} |
| 10 | + {#if $page.data.session.user?.image} |
| 11 | + <span |
| 12 | + style="background-image: url('{$page.data.session.user.image}')" |
| 13 | + class="avatar" |
| 14 | + /> |
| 15 | + {/if} |
| 16 | + <span class="signedInText"> |
| 17 | + <small>Signed in as</small><br /> |
| 18 | + <strong |
| 19 | + >{$page.data.session.user?.email ?? |
| 20 | + $page.data.session.user?.name}</strong |
| 21 | + > |
| 22 | + </span> |
| 23 | + <a href="/auth/signout" class="button">Sign out</a> |
| 24 | + {:else} |
| 25 | + <span class="notSignedInText">You are not signed in</span> |
| 26 | + <a href="/auth/signin" class="buttonPrimary">Sign in</a> |
| 27 | + {/if} |
| 28 | + </p> |
| 29 | + </div> |
| 30 | + <nav> |
| 31 | + <ul class="navItems"> |
| 32 | + <li class="navItem"><a href="/">Home</a></li> |
| 33 | + <li class="navItem"><a href="/protected">Protected</a></li> |
| 34 | + </ul> |
| 35 | + </nav> |
| 36 | + </header> |
| 37 | + <slot /> |
| 38 | +</div> |
| 39 | + |
| 40 | +<style> |
| 41 | + :global(body) { |
| 42 | + font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, |
| 43 | + "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, |
| 44 | + "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", |
| 45 | + "Noto Color Emoji"; |
| 46 | + padding: 0 1rem 1rem 1rem; |
| 47 | + max-width: 680px; |
| 48 | + margin: 0 auto; |
| 49 | + background: #fff; |
| 50 | + color: #333; |
| 51 | + } |
| 52 | + :global(li), |
| 53 | + :global(p) { |
| 54 | + line-height: 1.5rem; |
| 55 | + } |
| 56 | + :global(a) { |
| 57 | + font-weight: 500; |
| 58 | + } |
| 59 | + :global(hr) { |
| 60 | + border: 1px solid #ddd; |
| 61 | + } |
| 62 | + :global(iframe) { |
| 63 | + background: #ccc; |
| 64 | + border: 1px solid #ccc; |
| 65 | + height: 10rem; |
| 66 | + width: 100%; |
| 67 | + border-radius: 0.5rem; |
| 68 | + filter: invert(1); |
| 69 | + } |
| 70 | +
|
| 71 | + .nojs-show { |
| 72 | + opacity: 1; |
| 73 | + top: 0; |
| 74 | + } |
| 75 | + .signedInStatus { |
| 76 | + display: block; |
| 77 | + min-height: 4rem; |
| 78 | + width: 100%; |
| 79 | + } |
| 80 | + .loaded { |
| 81 | + position: relative; |
| 82 | + top: 0; |
| 83 | + opacity: 1; |
| 84 | + overflow: hidden; |
| 85 | + border-radius: 0 0 0.6rem 0.6rem; |
| 86 | + padding: 0.6rem 1rem; |
| 87 | + margin: 0; |
| 88 | + background-color: rgba(0, 0, 0, 0.05); |
| 89 | + transition: all 0.2s ease-in; |
| 90 | + } |
| 91 | + .signedInText, |
| 92 | + .notSignedInText { |
| 93 | + position: absolute; |
| 94 | + padding-top: 0.8rem; |
| 95 | + left: 1rem; |
| 96 | + right: 6.5rem; |
| 97 | + white-space: nowrap; |
| 98 | + text-overflow: ellipsis; |
| 99 | + overflow: hidden; |
| 100 | + display: inherit; |
| 101 | + z-index: 1; |
| 102 | + line-height: 1.3rem; |
| 103 | + } |
| 104 | + .signedInText { |
| 105 | + padding-top: 0rem; |
| 106 | + left: 4.6rem; |
| 107 | + } |
| 108 | + .avatar { |
| 109 | + border-radius: 2rem; |
| 110 | + float: left; |
| 111 | + height: 2.8rem; |
| 112 | + width: 2.8rem; |
| 113 | + background-color: white; |
| 114 | + background-size: cover; |
| 115 | + background-repeat: no-repeat; |
| 116 | + } |
| 117 | + .button, |
| 118 | + .buttonPrimary { |
| 119 | + float: right; |
| 120 | + margin-right: -0.4rem; |
| 121 | + font-weight: 500; |
| 122 | + border-radius: 0.3rem; |
| 123 | + cursor: pointer; |
| 124 | + font-size: 1rem; |
| 125 | + line-height: 1.4rem; |
| 126 | + padding: 0.7rem 0.8rem; |
| 127 | + position: relative; |
| 128 | + z-index: 10; |
| 129 | + background-color: transparent; |
| 130 | + color: #555; |
| 131 | + } |
| 132 | + .buttonPrimary { |
| 133 | + background-color: #346df1; |
| 134 | + border-color: #346df1; |
| 135 | + color: #fff; |
| 136 | + text-decoration: none; |
| 137 | + padding: 0.7rem 1.4rem; |
| 138 | + } |
| 139 | + .buttonPrimary:hover { |
| 140 | + box-shadow: inset 0 0 5rem rgba(0, 0, 0, 0.2); |
| 141 | + } |
| 142 | + .navItems { |
| 143 | + margin-bottom: 2rem; |
| 144 | + padding: 0; |
| 145 | + list-style: none; |
| 146 | + } |
| 147 | + .navItem { |
| 148 | + display: inline-block; |
| 149 | + margin-right: 1rem; |
| 150 | + } |
| 151 | +</style> |
0 commit comments