|
1 | 1 | <script lang="ts" context="module"> |
2 | | - export type TocItem = { |
3 | | - title: string; |
4 | | - href: string; |
5 | | - step?: number; |
6 | | - selected?: boolean; |
7 | | - children?: Array<{ |
8 | | - title: string; |
9 | | - href: string; |
10 | | - selected: boolean; |
11 | | - }>; |
12 | | - }; |
| 2 | + export type TocItem = { |
| 3 | + title: string; |
| 4 | + href: string; |
| 5 | + step?: number; |
| 6 | + selected?: boolean; |
| 7 | + children?: Array<{ |
| 8 | + title: string; |
| 9 | + href: string; |
| 10 | + selected: boolean; |
| 11 | + }>; |
| 12 | + }; |
13 | 13 | </script> |
14 | 14 |
|
15 | 15 | <script lang="ts"> |
16 | | - import { Feedback } from '$lib/components'; |
| 16 | + import { scrollToTop } from '$lib/actions/scrollToTop'; |
17 | 17 |
|
18 | | - export let title: string; |
19 | | - export let toc: Array<TocItem>; |
20 | | - export let back: string | undefined = undefined; |
21 | | - export let date: string; |
| 18 | + import { Feedback } from '$lib/components'; |
| 19 | +
|
| 20 | + export let title: string; |
| 21 | + export let toc: Array<TocItem>; |
| 22 | + export let back: string | undefined = undefined; |
| 23 | + export let date: string; |
22 | 24 | </script> |
23 | 25 |
|
24 | 26 | <main class="u-contents"> |
25 | | - <article class="aw-article u-contents"> |
26 | | - <header class="aw-article-header"> |
27 | | - <div class="aw-article-header-start u-flex-vertical aw-u-cross-start"> |
28 | | - {#if back} |
29 | | - <a |
30 | | - href={back} |
31 | | - class=" |
| 27 | + <article class="aw-article u-contents"> |
| 28 | + <header class="aw-article-header"> |
| 29 | + <div class="aw-article-header-start u-flex-vertical aw-u-cross-start"> |
| 30 | + {#if back} |
| 31 | + <a |
| 32 | + href={back} |
| 33 | + class=" |
32 | 34 | aw-button is-text aw-is-only-mobile |
33 | 35 | aw-u-padding-block-0 aw-u-padding-inline-start-0 aw-u-padding-inline-end-12" |
34 | | - aria-label="previous page" |
35 | | - > |
36 | | - <span class="icon-cheveron-left" aria-hidden="true" /> |
37 | | - </a> |
38 | | - {/if} |
39 | | - <ul class="aw-metadata aw-caption-400"> |
40 | | - <slot name="metadata" /> |
41 | | - </ul> |
42 | | - <div class="u-position-relative u-flex u-cross-center"> |
43 | | - {#if back} |
44 | | - <a |
45 | | - href={back} |
46 | | - class=" |
| 36 | + aria-label="previous page" |
| 37 | + > |
| 38 | + <span class="icon-cheveron-left" aria-hidden="true" /> |
| 39 | + </a> |
| 40 | + {/if} |
| 41 | + <ul class="aw-metadata aw-caption-400"> |
| 42 | + <slot name="metadata" /> |
| 43 | + </ul> |
| 44 | + <div class="u-position-relative u-flex u-cross-center"> |
| 45 | + {#if back} |
| 46 | + <a |
| 47 | + href={back} |
| 48 | + class=" |
47 | 49 | aw-button is-text is-icon aw-u-cross-center aw-u-size-40 |
48 | 50 | u-position-absolute u-inset-inline-start-0 aw-u-translate-x-negative" |
49 | | - aria-label="previous page" |
50 | | - > |
51 | | - <span |
52 | | - class="icon-cheveron-left aw-u-font-size-24 aw-u-color-text-primary aw-is-not-mobile" |
53 | | - aria-hidden="true" |
54 | | - /> |
55 | | - </a> |
56 | | - {/if} |
57 | | - <h1 class="aw-title">{title}</h1> |
58 | | - </div> |
59 | | - </div> |
60 | | - <div class="aw-article-header-end" /> |
61 | | - </header> |
62 | | - <div class="aw-article-content"> |
63 | | - <slot /> |
64 | | - <Feedback {date} /> |
65 | | - </div> |
66 | | - <aside class="aw-references-menu aw-u-padding-inline-start-24"> |
67 | | - <div class="aw-references-menu-content"> |
68 | | - {#if toc && toc.length > 0} |
69 | | - <div class="u-flex u-main-space-between u-cross-center u-gap-16"> |
70 | | - <h5 class="aw-references-menu-title aw-eyebrow">On This Page</h5> |
71 | | - </div> |
72 | | - <ol class="aw-references-menu-list"> |
73 | | - {#each toc as parent (parent.href)} |
74 | | - <li class="aw-references-menu-item" class:article-scroll-indicator={parent.selected}> |
75 | | - <a |
76 | | - href={parent.href} |
77 | | - class="aw-references-menu-link" |
78 | | - class:is-selected={parent.selected} |
79 | | - > |
80 | | - {#if parent?.step} |
81 | | - <span class="aw-numeric-badge">{parent.step}</span> |
82 | | - {/if} |
83 | | - <span class="aw-caption-400">{parent.title}</span> |
84 | | - </a> |
85 | | - {#if parent.children} |
86 | | - <ol |
87 | | - class="aw-references-menu-list u-margin-block-start-16 u-margin-inline-start-32" |
88 | | - > |
89 | | - {#each parent.children as child} |
90 | | - <li class="aw-references-menu-item"> |
91 | | - <a href={child.href} class="aw-references-menu-link"> |
92 | | - <span class="aw-caption-400">{child.title}</span> |
93 | | - </a> |
94 | | - </li> |
95 | | - {/each} |
96 | | - </ol> |
97 | | - {/if} |
98 | | - </li> |
99 | | - {/each} |
100 | | - </ol> |
101 | | - <div class="u-sep-block-start u-padding-block-start-20"> |
102 | | - <a class="aw-link u-inline-flex u-cross-center u-gap-8" href="#top"> |
103 | | - <span class="aw-icon-arrow-up" aria-hidden="true" /> |
104 | | - <span class="aw-sub-body-500">Back to top</span> |
105 | | - </a> |
106 | | - </div> |
107 | | - {/if} |
108 | | - </div> |
109 | | - </aside> |
110 | | - </article> |
| 51 | + aria-label="previous page" |
| 52 | + > |
| 53 | + <span |
| 54 | + class="icon-cheveron-left aw-u-font-size-24 aw-u-color-text-primary aw-is-not-mobile" |
| 55 | + aria-hidden="true" |
| 56 | + /> |
| 57 | + </a> |
| 58 | + {/if} |
| 59 | + <h1 class="aw-title">{title}</h1> |
| 60 | + </div> |
| 61 | + </div> |
| 62 | + <div class="aw-article-header-end" /> |
| 63 | + </header> |
| 64 | + <div class="aw-article-content"> |
| 65 | + <slot /> |
| 66 | + <Feedback {date} /> |
| 67 | + </div> |
| 68 | + <aside class="aw-references-menu aw-u-padding-inline-start-24"> |
| 69 | + <div class="aw-references-menu-content"> |
| 70 | + {#if toc && toc.length > 0} |
| 71 | + <div class="u-flex u-main-space-between u-cross-center u-gap-16"> |
| 72 | + <h5 class="aw-references-menu-title aw-eyebrow">On This Page</h5> |
| 73 | + </div> |
| 74 | + <ol class="aw-references-menu-list"> |
| 75 | + {#each toc as parent (parent.href)} |
| 76 | + <li |
| 77 | + class="aw-references-menu-item" |
| 78 | + class:article-scroll-indicator={parent.selected} |
| 79 | + > |
| 80 | + <a |
| 81 | + href={parent.href} |
| 82 | + class="aw-references-menu-link" |
| 83 | + class:is-selected={parent.selected} |
| 84 | + > |
| 85 | + {#if parent?.step} |
| 86 | + <span class="aw-numeric-badge">{parent.step}</span> |
| 87 | + {/if} |
| 88 | + <span class="aw-caption-400">{parent.title}</span> |
| 89 | + </a> |
| 90 | + {#if parent.children} |
| 91 | + <ol |
| 92 | + class="aw-references-menu-list u-margin-block-start-16 u-margin-inline-start-32" |
| 93 | + > |
| 94 | + {#each parent.children as child} |
| 95 | + <li class="aw-references-menu-item"> |
| 96 | + <a |
| 97 | + href={child.href} |
| 98 | + class="aw-references-menu-link" |
| 99 | + > |
| 100 | + <span class="aw-caption-400">{child.title}</span |
| 101 | + > |
| 102 | + </a> |
| 103 | + </li> |
| 104 | + {/each} |
| 105 | + </ol> |
| 106 | + {/if} |
| 107 | + </li> |
| 108 | + {/each} |
| 109 | + </ol> |
| 110 | + <div class="u-sep-block-start u-padding-block-start-20"> |
| 111 | + <button |
| 112 | + class="aw-link u-inline-flex u-cross-center u-gap-8" |
| 113 | + use:scrollToTop |
| 114 | + > |
| 115 | + <span class="aw-icon-arrow-up" aria-hidden="true" /> |
| 116 | + <span class="aw-sub-body-500">Back to top</span> |
| 117 | + </button> |
| 118 | + </div> |
| 119 | + {/if} |
| 120 | + </div> |
| 121 | + </aside> |
| 122 | + </article> |
111 | 123 | </main> |
112 | 124 |
|
113 | 125 | <style lang="scss"> |
114 | | - .article-scroll-indicator { |
115 | | - position: relative; |
116 | | - &::before { |
117 | | - position: absolute; |
118 | | - content: ''; |
119 | | - top: 0; |
120 | | - left: -1.5rem; |
121 | | - height: 100%; |
122 | | - width: 2px; |
123 | | - background-color: hsl(var(--p-references-menu-link-color-text)); |
124 | | - } |
125 | | - } |
| 126 | + .article-scroll-indicator { |
| 127 | + position: relative; |
| 128 | + &::before { |
| 129 | + position: absolute; |
| 130 | + content: ''; |
| 131 | + top: 0; |
| 132 | + left: -1.5rem; |
| 133 | + height: 100%; |
| 134 | + width: 2px; |
| 135 | + background-color: hsl(var(--p-references-menu-link-color-text)); |
| 136 | + } |
| 137 | + } |
126 | 138 | </style> |
0 commit comments