@onsvisual/svelte-components 0.1.33 → 0.1.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,6 +5,7 @@ export default class NavSection extends SvelteComponentTyped<{
5
5
  id?: string;
6
6
  title?: string;
7
7
  hideTitle?: boolean;
8
+ subsection?: boolean;
8
9
  }, {
9
10
  [evt: string]: CustomEvent<any>;
10
11
  }, {
@@ -20,6 +21,7 @@ declare const __propDef: {
20
21
  id?: string;
21
22
  title?: string;
22
23
  hideTitle?: boolean;
24
+ subsection?: boolean;
23
25
  };
24
26
  events: {
25
27
  [evt: string]: CustomEvent<any>;
@@ -18,6 +18,11 @@
18
18
  * @type {boolean}
19
19
  */
20
20
  export let hideTitle = false;
21
+ /**
22
+ * Treat a section as sub-section. It will have an h3 title, and will be indented in the contents table
23
+ * @type {boolean}
24
+ */
25
+ export let subsection = false;
21
26
 
22
27
  const sections = getContext("sections");
23
28
  const observer = getContext("observer");
@@ -27,7 +32,7 @@
27
32
 
28
33
  onMount(() => {
29
34
  if (sections && observer) {
30
- $sections = [...$sections, { title, id }];
35
+ $sections = [...$sections, { title, id, subsection }];
31
36
  $observer.observe(section);
32
37
  }
33
38
  });
@@ -42,7 +47,13 @@
42
47
 
43
48
  <section id="{id}" aria-label="{title}" bind:this="{section}">
44
49
  {#if title}
45
- <h2 class="ons-u-mt-xl ons-u-pb-no ons-u-pt-no" class:ons-u-vh="{hideTitle}">{title}</h2>
50
+ {#if subsection}
51
+ <h3 class="subsection-title ons-u-fs-m" class:ons-u-vh="{hideTitle}">{title}</h3>
52
+ {:else}
53
+ <h2 class="section-title ons-u-mt-l ons-u-pb-no ons-u-pt-no" class:ons-u-vh="{hideTitle}">
54
+ {title}
55
+ </h2>
56
+ {/if}
46
57
  {/if}
47
58
  <slot />
48
59
  {#if tocId}
@@ -114,7 +114,7 @@
114
114
  {/if}
115
115
  <ol class="ons-list ons-u-mb-m ons-list--dashed">
116
116
  {#each $sections as section}
117
- <li class="ons-list__item">
117
+ <li class="ons-list__item" class:ons-list__item-indented="{section.subsection}">
118
118
  <a
119
119
  href="#{section.id}"
120
120
  class="ons-list__link"
@@ -130,7 +130,7 @@
130
130
  </nav>
131
131
  </aside>
132
132
  </div>
133
- <div class="ons-grid__col ons-col-8@m ons-u-pl-no">
133
+ <div class="ons-nav-sections ons-grid__col ons-col-8@m ons-u-pl-no">
134
134
  <slot name="before" />
135
135
  {#if $observer}
136
136
  <slot />
@@ -151,4 +151,10 @@
151
151
  max-width: calc(100% - 280px);
152
152
  width: calc(100% - 280px);
153
153
  }
154
+ }
155
+ .ons-list__item-indented {
156
+ margin-left: 50px !important;
157
+ }
158
+ .ons-nav-sections :global(section:first-of-type h2) {
159
+ margin-top: 27px !important;
154
160
  }</style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onsvisual/svelte-components",
3
- "version": "0.1.33",
3
+ "version": "0.1.34",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "homepage": "https://onsvisual.github.io/svelte-components",