@djcali570/component-lib 0.1.0 → 0.1.2

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.
package/README.md CHANGED
@@ -46,9 +46,12 @@ let acs: Accordion5ColorScheme = {
46
46
  }
47
47
  ```
48
48
 
49
- #### Features
50
- - Use of snippets to customize all text
51
- - Change size of chevron icon
49
+ #### Props
50
+
51
+ - title (Snippet) - Snippet for title content
52
+ - panel (Snippet) - Snippet for accordion content
53
+ - iconWidth (string) - Width of icon eg. "1rem"
54
+ - iconHeight (string) - Height of icon eg. "1rem"
52
55
 
53
56
  ### Use of the Accordion component
54
57
 
@@ -79,6 +82,13 @@ let ccs: Chart5ColorScheme = {
79
82
  }
80
83
  ```
81
84
 
85
+ #### Props
86
+ - title (Snippet) - Use for title of chart
87
+ - maxWidth (string) - Sets the max width of chart eg. "400px"
88
+ - height (string) - Sets the height of the chart eg. "400px"
89
+ - labels (string[]) - Array of strings for the labels
90
+ - values (number[]) - Array of numbers for the values
91
+
82
92
  ### Use of the Chart component
83
93
 
84
94
  ```
@@ -136,8 +146,93 @@ let apcs: AdminPanel5ColorScheme = {
136
146
  </AdminPanel5>
137
147
  ```
138
148
 
149
+ ## Bottom Sheet
150
+
151
+ Use the default or customize the color scheme
152
+
153
+ ```bash
154
+ import { BottomSheet5 } from '@djcali570/component-lib';
155
+ import type { BottomSheet5ColorScheme } from '@djcali570/component-lib';
156
+
157
+ let bscs: BottomSheet5ColorScheme = {
158
+ bgColor: '#121212',
159
+ }
160
+ ```
161
+ #### Props
162
+ - modalStatus (boolean) - bindable to close/open modal outside component
163
+ - content (Snippet) - Snippet for sheet content
164
+ - rounded (boolean) - Set rounded corners to top
165
+ - top (string) - Set height of bottom sheet. eg. "50%", "1rem"
166
+
167
+ ### Use of the component
168
+
169
+ ```
170
+ let modalStatus = $state(false);
171
+
172
+ <BottomSheet5 bind:modalStatus top="50%">
173
+ {#snippet content()}
174
+ <div>Place bottom sheet content here</div>
175
+ {/snippet}
176
+ </BottomSheet5>
177
+ ```
178
+
179
+ ## Dialog
180
+
181
+ Use the default or customize the color scheme
182
+
183
+ ```bash
184
+ import { Dialog5 } from '@djcali570/component-lib';
185
+ import type { Dialog5ColorScheme } from '@djcali570/component-lib';
186
+
187
+ let d5cs: Dialog5ColorScheme = {
188
+ bgColor: '#121212',
189
+ titleBgColor: '#181818',
190
+ textColor: '#fcfcfc',
191
+ confirmTextColor: '#fb2c36',
192
+ borderColor: '#262626',
193
+ okButtonBgColor: '#181818',
194
+ confirmButtonBgColor: '#181818'
195
+ }
196
+ ```
197
+ #### Props
198
+ - modalStatus (boolean) - bindable to close/open modal outside component
199
+ - minWidth / minHeight (string) - set height or width of the dialog. eg '320px'
200
+ - dialogType ('confirm-cancel' | 'ok') - use ok for a simple message or use confirm/cancel to use the onUpdate callback.
201
+ - title (Snippet) - use for title section of the dialog
202
+ - content (Snippet) - use for the content or message of the dialog
203
+ - confirmButtonText / cancelButtonText / okButtonText (string) - Change default button text
204
+ - onUpdate ((value: boolean) => void)) - Callback for the cancel/confirm button.
205
+
206
+ ### Use of the component
207
+
208
+ ```
209
+ let modalStatus = $state(false);
210
+
211
+ function dialogUpdated(v: boolean) {
212
+ console.log(v);
213
+ }
214
+
215
+ <Dialog5
216
+ bind:modalStatus
217
+ dialogType="confirm-cancel"
218
+ onUpdate={(v) => dialogUpdated(v)}
219
+ >
220
+ {#snippet title()}
221
+ <div style="width: 100%; display: flex; justify-content: center; padding: 1rem;">
222
+ Dialog Title
223
+ </div>
224
+ {/snippet}
225
+ {#snippet content()}
226
+ <div>Place dialog content here</div>
227
+ {/snippet}
228
+ </Dialog5>
229
+ ```
230
+
231
+
139
232
  # Updates
140
- #### 0.1.00 - Updated Accordion component to use snippets for title.
233
+ #### 0.1.2 - Fixed some minor styling issues with Dialog component.
234
+ #### 0.1.1 - Added Bottom Sheet component & Dialog component.
235
+ #### 0.1.0 - Updated Accordion component to use snippets for title.
141
236
  #### 0.0.14 - Fixed Input5 textarea height was not being applied. Removed Tailwind dependencies.
142
237
  #### 0.0.13 - Added Admin Panel 5 Component.
143
238
  #### 0.0.12 - Made all components colorScheme properties optional.
@@ -0,0 +1,84 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+ import { fly } from 'svelte/transition';
4
+ import type { BottomSheet5ColorScheme } from './types.js';
5
+
6
+ let {
7
+ colorScheme: partialColorScheme = {},
8
+ modalStatus = $bindable(),
9
+ content,
10
+ rounded = true,
11
+ top = '1rem'
12
+ }: {
13
+ colorScheme?: Partial<BottomSheet5ColorScheme>;
14
+ modalStatus: boolean;
15
+ content?: Snippet;
16
+ position?: 'centered' | 'fixed bottom';
17
+ rounded?: boolean;
18
+ top?: string;
19
+ } = $props();
20
+
21
+ // Default colorScheme
22
+ const defaultColorScheme: BottomSheet5ColorScheme = {
23
+ bgColor: '#121212'
24
+ };
25
+
26
+ // Merge partial colorScheme with defaults
27
+ const colorScheme = { ...defaultColorScheme, ...partialColorScheme };
28
+ </script>
29
+
30
+ {#if modalStatus}
31
+ <div class="dialog__bg" style="--m5-bgColor: {colorScheme.bgColor}; --m5-top: {top};">
32
+ <div
33
+ class="dialog__container"
34
+ role="dialog"
35
+ aria-modal="true"
36
+ aria-label="Bottom Sheet Dialog"
37
+ transition:fly={{ y: 400, duration: 200 }}
38
+ class:m5__rounded={rounded}
39
+ >
40
+ {#if content}
41
+ {@render content()}
42
+ {:else}
43
+ <div class="m5__default__content">
44
+ <button onclick={() => (modalStatus = false)}>Close</button>
45
+ </div>
46
+ {/if}
47
+ </div>
48
+ </div>
49
+ {/if}
50
+
51
+ <style>
52
+ .dialog__bg {
53
+ position: fixed;
54
+ top: var(--m5-top);
55
+ left: 0;
56
+ width: 100%;
57
+ height: 100%;
58
+ z-index: 50;
59
+ }
60
+ .dialog__container {
61
+ display: flex;
62
+ width: 100%;
63
+ height: 100%;
64
+ overflow-y: hidden;
65
+ background-color: var(--m5-bgColor);
66
+ }
67
+ .m5__rounded {
68
+ border-top-left-radius: 1rem;
69
+ border-top-right-radius: 1rem;
70
+ }
71
+ .m5__default__content {
72
+ display: flex;
73
+ justify-content: flex-end;
74
+ width: 100%;
75
+ height: 50px;
76
+ background-color: #181818;
77
+ }
78
+ .m5__default__content button {
79
+ color: white;
80
+ background-color: transparent;
81
+ border: none;
82
+ cursor: pointer;
83
+ }
84
+ </style>
@@ -0,0 +1,13 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { BottomSheet5ColorScheme } from './types.js';
3
+ type $$ComponentProps = {
4
+ colorScheme?: Partial<BottomSheet5ColorScheme>;
5
+ modalStatus: boolean;
6
+ content?: Snippet;
7
+ position?: 'centered' | 'fixed bottom';
8
+ rounded?: boolean;
9
+ top?: string;
10
+ };
11
+ declare const BottomSheet5: import("svelte").Component<$$ComponentProps, {}, "modalStatus">;
12
+ type BottomSheet5 = ReturnType<typeof BottomSheet5>;
13
+ export default BottomSheet5;
@@ -0,0 +1,219 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+ import type { Dialog5ColorScheme } from './types.js';
4
+ import { fly } from 'svelte/transition';
5
+
6
+ let {
7
+ colorScheme: partialColorScheme = {},
8
+ modalStatus = $bindable(),
9
+ minWidth = '360px',
10
+ minHeight = '250px',
11
+ dialogType = 'ok',
12
+ title,
13
+ content,
14
+ confirmButtonText = 'Confirm',
15
+ cancelButtonText = 'Cancel',
16
+ okButtonText = 'OK',
17
+ onUpdate = (value) => {}
18
+ }: {
19
+ colorScheme?: Partial<Dialog5ColorScheme>;
20
+ modalStatus: boolean;
21
+ minWidth?: string;
22
+ minHeight?: string;
23
+ dialogType?: 'confirm-cancel' | 'ok';
24
+ title?: Snippet;
25
+ message?: string;
26
+ content?: Snippet;
27
+ confirmButtonText?: string;
28
+ cancelButtonText?: string;
29
+ okButtonText?: string;
30
+ onUpdate?: (value: boolean) => void;
31
+ } = $props();
32
+
33
+ // Default colorScheme
34
+ const defaultColorScheme: Dialog5ColorScheme = {
35
+ bgColor: '#121212',
36
+ titleBgColor: '#181818',
37
+ textColor: '#fcfcfc',
38
+ confirmTextColor: '#fb2c36',
39
+ borderColor: '#262626',
40
+ okButtonBgColor: '#181818',
41
+ confirmButtonBgColor: '#181818'
42
+ };
43
+
44
+ // Merge partial colorScheme with defaults
45
+ const colorScheme = { ...defaultColorScheme, ...partialColorScheme };
46
+
47
+ let confirmed: boolean = $state(false);
48
+ const menuId = `dialog5-${generateRandomString()}`;
49
+ const contentId = `dialog5-content-${generateRandomString()}`;
50
+
51
+ function canceled() {
52
+ confirmed = false;
53
+ modalStatus = false;
54
+ onUpdate(false);
55
+ }
56
+
57
+ function confirm() {
58
+ confirmed = true;
59
+ modalStatus = false;
60
+ onUpdate(true);
61
+ }
62
+
63
+ /**
64
+ * Generate a random 6 digit string to differentiate
65
+ * the menus
66
+ */
67
+ function generateRandomString() {
68
+ const length = 6;
69
+ const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
70
+
71
+ let result = '';
72
+ for (let i = 0; i < length; i++) {
73
+ const randomIndex = Math.floor(Math.random() * characters.length);
74
+ result += characters.charAt(randomIndex);
75
+ }
76
+
77
+ return result;
78
+ }
79
+ </script>
80
+
81
+ {#if modalStatus}
82
+ <div id={menuId} class="d5__container">
83
+ <div
84
+ id={contentId}
85
+ class="d5__content__container"
86
+ style="color: {colorScheme.textColor};"
87
+ transition:fly={{ y: 100 }}
88
+ >
89
+ <div
90
+ class="d5__dialog"
91
+ style="--d5-bgColor: {colorScheme.bgColor};
92
+ --d5-titleBgColor: {colorScheme.titleBgColor};
93
+ --d5-textColor: {colorScheme.textColor};
94
+ --d5-confirmTextColor: {colorScheme.confirmTextColor};
95
+ --d5-borderColor: {colorScheme.borderColor};
96
+ --d5-width: {minWidth};
97
+ --d5-height: {minHeight};
98
+ --d5-okButtonBgColor: {colorScheme.okButtonBgColor};
99
+ --d5-confirmButtonBgColor: {colorScheme.confirmButtonBgColor};"
100
+ >
101
+ {#if title}
102
+ <div class="d5__title__container">{@render title()}</div>
103
+ {/if}
104
+
105
+ {#if content}
106
+ {@render content()}
107
+ {:else}
108
+ <div
109
+ style="display:flex; justify-content:center; align-items:center; height:100%; font-size:1rem; color:gray;"
110
+ >
111
+ [Add Content Snippet]
112
+ </div>
113
+ {/if}
114
+ <div class="d5__btn__container">
115
+ {#if dialogType === 'confirm-cancel'}
116
+ <div class="d5__confirm__grid">
117
+ <div class="fca">
118
+ <button type="button" class="ok__btn" onclick={canceled}>{cancelButtonText}</button>
119
+ </div>
120
+ <div class="fca">
121
+ <button type="button" class="confirm__btn" onclick={confirm}
122
+ >{confirmButtonText}</button
123
+ >
124
+ </div>
125
+ </div>
126
+ {/if}
127
+ {#if dialogType === 'ok'}
128
+ <div class="d5__ok">
129
+ <button type="button" class="ok__btn" onclick={confirm}>{okButtonText}</button>
130
+ </div>
131
+ {/if}
132
+ </div>
133
+ </div>
134
+ </div>
135
+ </div>
136
+ {/if}
137
+
138
+ <style>
139
+ .d5__container {
140
+ position: fixed;
141
+ top: 0;
142
+ left: 0;
143
+ width: 100vw;
144
+ height: 100vh;
145
+ z-index: 999;
146
+ }
147
+ .d5__content__container {
148
+ display: flex;
149
+ width: 100%;
150
+ height: 100%;
151
+ justify-content: center;
152
+ align-items: center;
153
+ padding: 0.75rem;
154
+ }
155
+ .d5__dialog {
156
+ position: relative;
157
+ min-width: var(--d5-width);
158
+ min-height: var(--d5-height);
159
+ display: grid;
160
+ grid-template-rows: auto 1fr 65px;
161
+ border-width: 1px;
162
+ border-radius: 0.75rem;
163
+ border-color: var(--d5-borderColor);
164
+ background-color: var(--d5-bgColor);
165
+ border-style: solid;
166
+ overflow: hidden;
167
+ }
168
+ .d5__title__container {
169
+ display: flex;
170
+ justify-content: center;
171
+ width: 100%;
172
+ background-color: var(--d5-titleBgColor);
173
+ }
174
+ .d5__btn__container {
175
+ padding: 0.75rem;
176
+ }
177
+ .d5__confirm__grid {
178
+ display: grid;
179
+ grid-template-columns: repeat(2, minmax(0, 1fr));
180
+ height: 100%;
181
+ gap: 0.75rem;
182
+ }
183
+
184
+ .confirm__btn {
185
+ color: var(--d5-confirmTextColor);
186
+ background-color: var(--d5-confirmButtonBgColor);
187
+ transition: colors;
188
+ }
189
+ button:hover {
190
+ filter: brightness(1.2);
191
+ }
192
+ .ok__btn {
193
+ color: var(--d5-textColor);
194
+ background-color: var(--d5-okButtonBgColor);
195
+ transition: colors;
196
+ }
197
+ .d5__ok {
198
+ display: flex;
199
+ justify-content: center;
200
+ height: 100%;
201
+ color: var(--d5-textColor);
202
+ }
203
+
204
+ button {
205
+ cursor: pointer;
206
+ border: none;
207
+ background-color: transparent;
208
+ border-radius: 0.25rem;
209
+ height: 100%;
210
+ width: 100%;
211
+ min-width: 150px;
212
+ max-width: 250px;
213
+ }
214
+ .fca {
215
+ display: flex;
216
+ justify-content: center;
217
+ align-items: center;
218
+ }
219
+ </style>
@@ -0,0 +1,19 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { Dialog5ColorScheme } from './types.js';
3
+ type $$ComponentProps = {
4
+ colorScheme?: Partial<Dialog5ColorScheme>;
5
+ modalStatus: boolean;
6
+ minWidth?: string;
7
+ minHeight?: string;
8
+ dialogType?: 'confirm-cancel' | 'ok';
9
+ title?: Snippet;
10
+ message?: string;
11
+ content?: Snippet;
12
+ confirmButtonText?: string;
13
+ cancelButtonText?: string;
14
+ okButtonText?: string;
15
+ onUpdate?: (value: boolean) => void;
16
+ };
17
+ declare const Dialog5: import("svelte").Component<$$ComponentProps, {}, "modalStatus">;
18
+ type Dialog5 = ReturnType<typeof Dialog5>;
19
+ export default Dialog5;
package/dist/index.d.ts CHANGED
@@ -5,6 +5,8 @@ import TimePicker5 from "./TimePicker5.svelte";
5
5
  import Accordion5 from "./Accordion5.svelte";
6
6
  import Chart5 from "./Chart5.svelte";
7
7
  import AdminPanel5 from "./AdminPanel5.svelte";
8
- import type { Input5ColorScheme, DatePicker5ColorScheme, TimePicker5ColorScheme, DropDownItem, DropDown5ColorScheme, Accordion5ColorScheme, Chart5ColorScheme, AdminPanel5ColorScheme } from "./types.js";
9
- export { DatePicker5, Input5, DropDown5, TimePicker5, Accordion5, Chart5, AdminPanel5 };
10
- export type { Input5ColorScheme, DatePicker5ColorScheme, TimePicker5ColorScheme, Accordion5ColorScheme, DropDown5ColorScheme, DropDownItem, Chart5ColorScheme, AdminPanel5ColorScheme };
8
+ import type { Input5ColorScheme, DatePicker5ColorScheme, TimePicker5ColorScheme, DropDownItem, DropDown5ColorScheme, Accordion5ColorScheme, Chart5ColorScheme, AdminPanel5ColorScheme, BottomSheet5ColorScheme, Dialog5ColorScheme } from "./types.js";
9
+ import BottomSheet5 from "./BottomSheet5.svelte";
10
+ import Dialog5 from "./Dialog5.svelte";
11
+ export { DatePicker5, Input5, DropDown5, TimePicker5, Accordion5, Chart5, AdminPanel5, BottomSheet5, Dialog5 };
12
+ export type { Input5ColorScheme, DatePicker5ColorScheme, TimePicker5ColorScheme, Accordion5ColorScheme, DropDown5ColorScheme, DropDownItem, Chart5ColorScheme, AdminPanel5ColorScheme, BottomSheet5ColorScheme, Dialog5ColorScheme };
package/dist/index.js CHANGED
@@ -6,4 +6,6 @@ import TimePicker5 from "./TimePicker5.svelte";
6
6
  import Accordion5 from "./Accordion5.svelte";
7
7
  import Chart5 from "./Chart5.svelte";
8
8
  import AdminPanel5 from "./AdminPanel5.svelte";
9
- export { DatePicker5, Input5, DropDown5, TimePicker5, Accordion5, Chart5, AdminPanel5 };
9
+ import BottomSheet5 from "./BottomSheet5.svelte";
10
+ import Dialog5 from "./Dialog5.svelte";
11
+ export { DatePicker5, Input5, DropDown5, TimePicker5, Accordion5, Chart5, AdminPanel5, BottomSheet5, Dialog5 };
package/dist/types.d.ts CHANGED
@@ -77,3 +77,15 @@ export interface AdminPanel5ColorScheme {
77
77
  drawerTitleBgColor?: string;
78
78
  iconColor?: string;
79
79
  }
80
+ export interface BottomSheet5ColorScheme {
81
+ bgColor?: string;
82
+ }
83
+ export interface Dialog5ColorScheme {
84
+ bgColor?: string;
85
+ titleBgColor?: string;
86
+ textColor?: string;
87
+ confirmTextColor?: string;
88
+ borderColor?: string;
89
+ okButtonBgColor?: string;
90
+ confirmButtonBgColor?: string;
91
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djcali570/component-lib",
3
- "version": "0.1.00",
3
+ "version": "0.1.2",
4
4
  "files": [
5
5
  "dist",
6
6
  "!dist/**/*.test.*",
@@ -19,8 +19,8 @@
19
19
  }
20
20
  },
21
21
  "peerDependencies": {
22
- "svelte": "^5.0.0",
23
- "@sveltejs/kit": "^2.16.0"
22
+ "@sveltejs/kit": "^2.16.0",
23
+ "svelte": "^5.0.0"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@eslint/compat": "^1.2.5",