@sierra-95/svelte-scaffold 1.2.11 → 1.2.13

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.
@@ -12,9 +12,6 @@
12
12
  #sierra-button:hover{
13
13
  opacity: 0.8;
14
14
  }
15
- #sierra-button i{
16
- font-size: 0.9rem;
17
- }
18
15
  /*********Button Variants*************************/
19
16
  /* .sierra-button-contained {
20
17
 
@@ -18,6 +18,7 @@
18
18
  html2canvas_ignore = 'false',
19
19
  startIcon = '',
20
20
  endIcon = '',
21
+ iconSize = '0.9rem',
21
22
  style = '',
22
23
  children = null,
23
24
  ...rest
@@ -53,9 +54,6 @@
53
54
  #sierra-button:hover{
54
55
  opacity: 0.8;
55
56
  }
56
- #sierra-button i{
57
- font-size: 0.9rem;
58
- }
59
57
  /*********Button Variants*************************/
60
58
  /* .sierra-button-contained {
61
59
 
@@ -118,11 +116,11 @@
118
116
  }}
119
117
  >
120
118
  {#if startIcon}
121
- <i class="fa {startIcon}"></i>
119
+ <i class="fa {startIcon}" style={`font-size: ${iconSize};`}></i>
122
120
  {/if}
123
121
  {@render children?.()}
124
122
  {#if endIcon}
125
- <i class="fa {endIcon}"></i>
123
+ <i class="fa {endIcon}" style={`font-size: ${iconSize};`}></i>
126
124
  {/if}
127
125
  {#if isLoading}
128
126
  <CircularProgress size={spinner} thickness={thickness} />
@@ -11,6 +11,7 @@ declare const Button: import("svelte").Component<{
11
11
  html2canvas_ignore?: string;
12
12
  startIcon?: string;
13
13
  endIcon?: string;
14
+ iconSize?: string;
14
15
  style?: string;
15
16
  children?: any;
16
17
  } & Record<string, any>, {}, "">;
@@ -0,0 +1,56 @@
1
+ <script lang="ts">
2
+ import { Button, addToast } from "../../../../index.js";
3
+ const {
4
+ shareURL,
5
+ shareTitle = '',
6
+ shareText = '',
7
+ limitShareText = 30,
8
+ label = "Share on WhatsApp",
9
+ } = $props();
10
+
11
+ let copyLink = $state(false);
12
+
13
+ const limitWords = (text:string, maxWords:number) => {
14
+ const words = text.split(/\s+/);
15
+ const trimmed = words.slice(0, maxWords).join(' ');
16
+ return words.length > maxWords ? trimmed + ' ...' : trimmed;
17
+ };
18
+
19
+ const handleShare = async () => {
20
+ if (navigator.share) {
21
+ try {
22
+ await navigator.share({
23
+ title: shareTitle,
24
+ text: limitWords(shareText, limitShareText),
25
+ url: shareURL,
26
+ });
27
+ } catch (err) {
28
+ console.error('Error sharing:', err);
29
+ }
30
+ } else {
31
+ const isMobile = /Android|iPhone|iPad|iPod/i.test(navigator.userAgent);
32
+ const message = `${limitWords(shareText, limitShareText)}\n\n${shareURL}`;
33
+ const encoded = encodeURIComponent(message);
34
+
35
+ const url = isMobile
36
+ ? `https://wa.me/?text=${encoded}`
37
+ : `https://web.whatsapp.com/send?text=${encoded}`;
38
+
39
+ window.open(url, "_blank");
40
+ copyLink = true;
41
+ }
42
+ };
43
+ const copyToClipboard = () => {
44
+ navigator.clipboard.writeText(shareURL);
45
+ copyLink = false;
46
+ addToast({
47
+ status: 'success',
48
+ message: 'Link copied to clipboard!'
49
+ })
50
+ };
51
+ </script>
52
+ {#if copyLink}
53
+ <Button variant="outlined" startIcon="fa-solid fa-copy" onclick={copyToClipboard}>Copy Link</Button>
54
+ {:else}
55
+ <Button onclick={handleShare} variant="outlined" startIcon="fa-brands fa-whatsapp" iconSize="1.2rem" color="none" style="text-[#25D366]">{label}</Button>
56
+ {/if}
@@ -0,0 +1,9 @@
1
+ declare const Whatsapp: import("svelte").Component<{
2
+ shareURL: any;
3
+ shareTitle?: string;
4
+ shareText?: string;
5
+ limitShareText?: number;
6
+ label?: string;
7
+ }, {}, "">;
8
+ type Whatsapp = ReturnType<typeof Whatsapp>;
9
+ export default Whatsapp;
package/dist/index.d.ts CHANGED
@@ -41,6 +41,7 @@ export { default as Form } from './Core/components/Form/Form/form.svelte';
41
41
  export { default as Carousel } from './Core/components/others/Carousel/carousel.svelte';
42
42
  export { default as Avatar } from './Core/components/others/Avatar/avatar.svelte';
43
43
  export { default as ColorPicker } from './Core/components/others/ColorPicker/main.svelte';
44
+ export { default as WhatsappShare } from './Core/components/others/WhatsappShare/whatsapp.svelte';
44
45
  export { default as GlobalSearch } from './Core/features/GlobalSearch/main.svelte';
45
46
  export { default as ToastManager } from './Core/features/ToastManager/toastManager.svelte';
46
47
  export { default as Editor } from './Modules/Editor/main.svelte';
package/dist/index.js CHANGED
@@ -48,6 +48,7 @@ export { default as Form } from './Core/components/Form/Form/form.svelte';
48
48
  export { default as Carousel } from './Core/components/others/Carousel/carousel.svelte';
49
49
  export { default as Avatar } from './Core/components/others/Avatar/avatar.svelte';
50
50
  export { default as ColorPicker } from './Core/components/others/ColorPicker/main.svelte';
51
+ export { default as WhatsappShare } from './Core/components/others/WhatsappShare/whatsapp.svelte';
51
52
  //####################Features##################################
52
53
  export { default as GlobalSearch } from './Core/features/GlobalSearch/main.svelte';
53
54
  export { default as ToastManager } from './Core/features/ToastManager/toastManager.svelte';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sierra-95/svelte-scaffold",
3
- "version": "1.2.11",
3
+ "version": "1.2.13",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run prepack",