@onsvisual/svelte-components 0.0.25 → 0.0.27

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,12 +3,12 @@
3
3
  /** @typedef {typeof __propDef.slots} CardSlots */
4
4
  export default class Card extends SvelteComponentTyped<{
5
5
  id?: any;
6
- title?: string;
7
- href?: string;
6
+ title?: any;
7
+ href?: any;
8
8
  hideTitle?: boolean;
9
9
  noBackground?: any;
10
- image?: string;
11
- imageAlt?: string;
10
+ image?: any;
11
+ imageAlt?: any;
12
12
  colspan?: number;
13
13
  grow?: boolean;
14
14
  }, {
@@ -24,12 +24,12 @@ import { SvelteComponentTyped } from "svelte";
24
24
  declare const __propDef: {
25
25
  props: {
26
26
  id?: any;
27
- title?: string;
28
- href?: string;
27
+ title?: any;
28
+ href?: any;
29
29
  hideTitle?: boolean;
30
30
  noBackground?: any;
31
- image?: string;
32
- imageAlt?: string;
31
+ image?: any;
32
+ imageAlt?: any;
33
33
  colspan?: number;
34
34
  grow?: boolean;
35
35
  };
@@ -5,7 +5,7 @@ export default class Grid extends SvelteComponentTyped<{
5
5
  theme?: "light" | "dark" | "lightblue";
6
6
  id?: string;
7
7
  cls?: string;
8
- width?: "narrow" | "medium" | "wide" | "wider" | "full";
8
+ width?: "narrow" | "medium" | "wide" | "full";
9
9
  height?: string | number;
10
10
  marginTop?: boolean;
11
11
  marginBottom?: boolean;
@@ -30,7 +30,7 @@ declare const __propDef: {
30
30
  theme?: "light" | "dark" | "lightblue";
31
31
  id?: string;
32
32
  cls?: string;
33
- width?: "narrow" | "medium" | "wide" | "wider" | "full";
33
+ width?: "narrow" | "medium" | "wide" | "full";
34
34
  height?: number | string;
35
35
  marginTop?: boolean;
36
36
  marginBottom?: boolean;
@@ -2,12 +2,12 @@
2
2
  import { getContext } from "svelte";
3
3
  import { slugify } from "../../js/utils";
4
4
 
5
- export let title = "Card title";
5
+ export let title = null;
6
6
  export let id = slugify(title);
7
7
  export let hideTitle = false;
8
- export let image = "";
9
- export let imageAlt = "";
10
- export let href = "";
8
+ export let image = null;
9
+ export let imageAlt = null;
10
+ export let href = null;
11
11
 
12
12
  export let colspan = 1; // 1, 2 or 3
13
13
  export let noBackground = getContext("noBackground") || false;
@@ -28,8 +28,8 @@
28
28
  style:grid-column-end="{grow ? $cols + 1 : null}"
29
29
  >
30
30
  <div id="{id}" class="ons-card" aria-describedBy="{id}_text">
31
- {#if href && title && !hideTitle}
32
- <a href="{href}" class="ons-card__link ons-u-db">
31
+ {#if href && title}
32
+ <a href="{href}" class="ons-card__link ons-u-db" class:ons-u-vh="{hideTitle}">
33
33
  {#if image}
34
34
  <img
35
35
  class="ons-card__image ons-u-mb-s"
@@ -46,9 +46,10 @@
46
46
  {title}
47
47
  </h3>
48
48
  </a>
49
- {:else if title && !hideTitle}
49
+ {:else if title}
50
50
  <h3
51
51
  class="ons-card__title ons-u-fs-m"
52
+ class:ons-u-vh="{hideTitle}"
52
53
  style:padding="{!noBackground ? "8px 16px 0" : ""}"
53
54
  style:margin-bottom="5px"
54
55
  >
@@ -1,4 +1,6 @@
1
1
  <script>
2
+ import { setContext } from "svelte";
3
+ import { writable } from "svelte/store";
2
4
  import Container from "../../wrappers/Container/Container.svelte";
3
5
 
4
6
  /**
@@ -13,9 +15,9 @@
13
15
  export let cls = null;
14
16
  /**
15
17
  * Sets the width of the section
16
- * @type {"narrow"|"medium"|"wide"|"wider"|"full"}
18
+ * @type {"narrow"|"medium"|"wide"|"full"}
17
19
  */
18
- export let width = "wide";
20
+ export let width = "medium";
19
21
  /**
20
22
  * Sets the title of the section
21
23
  * @type {string}
@@ -70,9 +72,30 @@
70
72
  let gridClass = !colwidth || colwidth === "full" ? "" : `grid-${colwidth}`;
71
73
  let rowHeight = height === "full" ? "100vh" : !Number.isNaN(height) ? height + "px" : height;
72
74
  let gridGap = !Number.isNaN(gap) ? gap + "px" : gap;
75
+
76
+ const defs = {
77
+ narrow: { w: 180, c: 4 },
78
+ medium: { w: 280, c: 3 },
79
+ wide: { w: 400, c: 2 },
80
+ full: { w: "100%", c: 1 },
81
+ };
82
+
83
+ let w;
84
+
85
+ const cols = writable(defs[colwidth].c);
86
+
87
+ $: columns =
88
+ colwidth == "full"
89
+ ? 1
90
+ : w
91
+ ? Math.floor((w + gap) / (defs[colwidth].w + gap))
92
+ : defs[colwidth].c;
93
+ $: cols.set(columns);
94
+
95
+ setContext("cols", cols);
73
96
  </script>
74
97
 
75
- <figure aria-label="{caption}">
98
+ <figure aria-label="{caption}" bind:clientWidth="{w}">
76
99
  <Container
77
100
  id="{id}"
78
101
  cls="{cls}"
@@ -122,10 +145,10 @@
122
145
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)) !important;
123
146
  }
124
147
  .grid-medium {
125
- grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)) !important;
148
+ grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)) !important;
126
149
  }
127
150
  .grid-wide {
128
- grid-template-columns: repeat(auto-fit, minmax(460px, 1fr)) !important;
151
+ grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)) !important;
129
152
  }
130
153
  :global(.grid > div) {
131
154
  min-height: inherit;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onsvisual/svelte-components",
3
- "version": "0.0.25",
3
+ "version": "0.0.27",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "homepage": "https://onsvisual.github.io/svelte-components",