@onsvisual/svelte-components 0.1.39 → 0.1.41

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.
@@ -3,6 +3,7 @@
3
3
  /** @typedef {typeof __propDef.slots} TabsSlots */
4
4
  export default class Tabs extends SvelteComponentTyped<{
5
5
  compact?: boolean;
6
+ selected?: string;
6
7
  border?: boolean;
7
8
  }, {
8
9
  [evt: string]: CustomEvent<any>;
@@ -17,6 +18,7 @@ import { SvelteComponentTyped } from "svelte";
17
18
  declare const __propDef: {
18
19
  props: {
19
20
  compact?: boolean;
21
+ selected?: string;
20
22
  border?: boolean;
21
23
  };
22
24
  events: {
@@ -20,7 +20,6 @@
20
20
 
21
21
  const sections = getContext("sections");
22
22
  const selected = getContext("selected");
23
- const border = getContext("border");
24
23
 
25
24
  let el;
26
25
 
@@ -43,17 +42,7 @@
43
42
  class="ons-tabs__panel"
44
43
  bind:this="{el}"
45
44
  class:ons-tabs__panel--hidden="{$selected !== id}"
46
- class:tab-border="{$border}"
47
45
  >
48
46
  <h2 id="{id}-content-title" class="ons-u-vh" class:ons-u-vh="{hideTitle}">{title}</h2>
49
47
  <slot />
50
48
  </section>
51
-
52
- <style>
53
- section.tab-border {
54
- border: 1px solid var(--ons-color-borders);
55
- border-radius: 4px;
56
- border-top-left-radius: 0;
57
- padding-left: 12px;
58
- padding-right: 12px;
59
- }</style>
@@ -11,18 +11,20 @@
11
11
  * @type {boolean}
12
12
  */
13
13
  export let border = false;
14
+ /**
15
+ * The ID of selected tab (for binding)
16
+ * @type {string}
17
+ */
18
+ export let selected = "";
14
19
 
15
20
  const sections = writable([]);
16
21
  setContext("sections", sections);
17
22
 
18
- const selected = writable(null);
19
- setContext("selected", selected);
20
-
21
- const _border = writable(border);
22
- setContext("border", _border);
23
+ const _selected = writable(selected);
24
+ setContext("selected", _selected);
23
25
 
24
26
  function showSection(id) {
25
- $selected = id;
27
+ $_selected = selected = id;
26
28
  [...$sections].forEach(
27
29
  (s) =>
28
30
  (s.el.className =
@@ -31,9 +33,9 @@
31
33
  }
32
34
  </script>
33
35
 
34
- <section class="ons-tabs">
36
+ <section class="ons-tabs" class:ons-tabs__border="{border}">
35
37
  <h2 class="ons-tabs__title ons-u-fs-r--b ons-u-mt-no ons-u-vh">Contents</h2>
36
- <div class="ons-tabs__container" class:tabs-no-border="{border}">
38
+ <div class="ons-tabs__container">
37
39
  <ul class="ons-tabs__list ons-tabs__list--row" role="tablist">
38
40
  {#each $sections as section}
39
41
  <li
@@ -91,6 +93,13 @@
91
93
  .ons-tab[aria-selected="true"]:not(:focus) {
92
94
  background-color: var(--background, white);
93
95
  }
94
- .tabs-no-border {
96
+ .ons-tabs__border > .ons-tabs__container {
95
97
  border: none;
98
+ }
99
+ .ons-tabs__border :global(.ons-tabs__panel) {
100
+ border: 1px solid var(--ons-color-borders);
101
+ border-radius: 4px;
102
+ border-top-left-radius: 0;
103
+ padding-left: 12px;
104
+ padding-right: 12px;
96
105
  }</style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onsvisual/svelte-components",
3
- "version": "0.1.39",
3
+ "version": "0.1.41",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "homepage": "https://onsvisual.github.io/svelte-components",