@reshape-biotech/design-system 0.0.40 → 0.0.42

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.
@@ -19,6 +19,12 @@
19
19
  <Story name="Base">
20
20
  <Input bind:value autofocus />
21
21
  </Story>
22
+ <Story name="XSmall">
23
+ <Input bind:value autofocus size="xs" />
24
+ </Story>
25
+ <Story name="Small">
26
+ <Input bind:value autofocus size="sm" />
27
+ </Story>
22
28
 
23
29
  <Story name="Login">
24
30
  <div class="flex flex-col gap-2">
@@ -17,6 +17,7 @@
17
17
  error?: Snippet;
18
18
  input?: HTMLInputElement | HTMLTextAreaElement;
19
19
  maxlength?: number | null;
20
+ size?: 'xs' | 'sm' | 'md';
20
21
  }
21
22
 
22
23
  let {
@@ -36,7 +37,8 @@
36
37
  suffix,
37
38
  error,
38
39
  input = $bindable(),
39
- maxlength = null
40
+ maxlength = null,
41
+ size = 'md'
40
42
  }: Props = $props();
41
43
 
42
44
  let valid = $state(true);
@@ -67,7 +69,7 @@
67
69
  <label for={id ?? inputId} class="block px-1 py-2 text-sm text-secondary">{label}</label>
68
70
  {/if}
69
71
  <div
70
- class="flex w-full items-center gap-1 rounded-lg border border-input bg-surface p-3 shadow-input"
72
+ class="flex w-full items-center gap-1 rounded-lg border border-input bg-surface shadow-input size-{size}"
71
73
  class:!border-error={!valid}
72
74
  >
73
75
  {#if type === 'textarea'}
@@ -144,4 +146,37 @@
144
146
 
145
147
  border-color: rgb(87 80 238 / var(--tw-border-opacity, 1))
146
148
  }
149
+
150
+ .size-xs {
151
+
152
+ padding: 0.5rem;
153
+
154
+ font-size: 0.75rem;
155
+
156
+ line-height: 1rem
157
+ }
158
+
159
+ .size-sm {
160
+
161
+ padding-left: 0.75rem;
162
+
163
+ padding-right: 0.75rem;
164
+
165
+ padding-top: 0.5rem;
166
+
167
+ padding-bottom: 0.5rem;
168
+
169
+ font-size: 0.875rem;
170
+
171
+ line-height: 1.25rem
172
+ }
173
+
174
+ .size-md {
175
+
176
+ padding: 0.75rem;
177
+
178
+ font-size: 1rem;
179
+
180
+ line-height: 1.5rem
181
+ }
147
182
  </style>
@@ -15,6 +15,7 @@ declare const Input: import("svelte").Component<{
15
15
  error?: Snippet;
16
16
  input?: HTMLInputElement | HTMLTextAreaElement;
17
17
  maxlength?: number | null;
18
+ size?: "xs" | "sm" | "md";
18
19
  }, {}, "input" | "value">;
19
20
  type Input = ReturnType<typeof Input>;
20
21
  export default Input;
@@ -1,13 +1,15 @@
1
1
  <script module lang="ts">
2
2
  import Button from '../button/Button.svelte';
3
3
  import Modal from '../modal/Modal.svelte';
4
- import ContactSupportModal from './ContactSupportModal.svelte';
5
4
  import { defineMeta } from '@storybook/addon-svelte-csf';
5
+
6
6
  const { Story } = defineMeta({
7
7
  component: Modal,
8
8
  title: 'Design System/Modal',
9
9
  tags: ['autodocs']
10
10
  });
11
+
12
+ let defaultOpen = $state(true);
11
13
  </script>
12
14
 
13
15
  <Story name="Default">
@@ -24,7 +26,7 @@
24
26
  </Story>
25
27
 
26
28
  <Story name="Default open">
27
- <Modal defaultOpen>
29
+ <Modal {defaultOpen} onclose={() => (defaultOpen = false)}>
28
30
  {#snippet Trigger({ openModal })}
29
31
  <Button onClick={openModal}>Open Modal</Button>
30
32
  {/snippet}
@@ -35,7 +37,3 @@
35
37
  {/snippet}
36
38
  </Modal>
37
39
  </Story>
38
-
39
- <Story name="Contact support">
40
- <ContactSupportModal />
41
- </Story>
@@ -7,6 +7,7 @@
7
7
  type ModalProps = {
8
8
  Trigger?: Snippet<[{ openModal: () => void; closeModal: () => void }]>;
9
9
  Content: Snippet;
10
+ onclose?: () => void;
10
11
  defaultOpen?: boolean;
11
12
  id?: string;
12
13
  withClose?: boolean;
@@ -16,6 +17,7 @@
16
17
  let {
17
18
  Trigger,
18
19
  Content,
20
+ onclose,
19
21
  defaultOpen = false,
20
22
  id = 'modal-' + uuidv4(),
21
23
  withClose = true,
@@ -23,6 +25,7 @@
23
25
  class: modalClass
24
26
  }: ModalProps = $props();
25
27
 
28
+ const modalOpen = $state(defaultOpen);
26
29
  const openModal = () => {
27
30
  const dialog = document.getElementById(id) as HTMLDialogElement | null;
28
31
  dialog?.showModal();
@@ -31,13 +34,14 @@
31
34
  const closeModal = () => {
32
35
  const dialog = document.getElementById(id) as HTMLDialogElement | null;
33
36
  dialog?.close();
37
+ onclose?.();
34
38
  };
35
39
  </script>
36
40
 
37
41
  {#if Trigger}
38
42
  {@render Trigger({ openModal, closeModal })}
39
43
  {/if}
40
- <dialog {id} class="modal {modalClass}" class:modal-open={defaultOpen}>
44
+ <dialog {id} class="modal {modalClass}" class:modal-open={modalOpen}>
41
45
  <div class="modal-box relative w-fit max-w-full rounded-xl bg-base p-6">
42
46
  {#if withClose}
43
47
  <div class="absolute right-0 top-0 p-6">
@@ -50,7 +54,7 @@
50
54
  </div>
51
55
  {#if closeOnClickOutside}
52
56
  <form method="dialog" class="modal-backdrop">
53
- <button>close</button>
57
+ <button onclick={closeModal}>close</button>
54
58
  </form>
55
59
  {/if}
56
60
  </dialog>
@@ -5,6 +5,7 @@ type ModalProps = {
5
5
  closeModal: () => void;
6
6
  }]>;
7
7
  Content: Snippet;
8
+ onclose?: () => void;
8
9
  defaultOpen?: boolean;
9
10
  id?: string;
10
11
  withClose?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reshape-biotech/design-system",
3
- "version": "0.0.40",
3
+ "version": "0.0.42",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build",