@djcali570/component-lib 0.1.5 → 0.1.7

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
@@ -1,241 +1,65 @@
1
- # DJCali570 Svelte 5 Component Library
1
+ # Svelte library
2
2
 
3
- Components make use of Svelte's runes so will only work with Svelte 5
3
+ Everything you need to build a Svelte library, powered by [`sv`](https://npmjs.com/package/sv).
4
4
 
5
- ## Input
5
+ Read more about creating a library [in the docs](https://svelte.dev/docs/kit/packaging).
6
6
 
7
- Use default or customize the input color scheme
7
+ ## Creating a project
8
8
 
9
- ```bash
10
- import { Input5 } from '@djcali570/component-lib';
11
- import type { Input5ColorScheme } from '@djcali570/component-lib';
9
+ If you're seeing this, you've probably already done this step. Congrats!
12
10
 
13
- let ics: Input5ColorScheme = {
14
- mainTextColor: '#D6D6D6',
15
- mainBgColor: '#121212',
16
- titleColor: '#989A9A'
17
- }
18
- ```
19
-
20
- #### Features
21
- - Counter
22
- - readonly / disabled options
23
- - onUpdate Callback
24
- - types: Text, Number or Password
25
- - Input formatting
26
- - Input or Textarea
27
-
28
- ### Use of the Input component
29
-
30
- ```
31
- <Input5 title="Input Title" colorScheme={ics} validator="phone" />
32
- ```
33
-
34
- ## Accordion
35
-
36
- Use default or customize the accordion color scheme
37
-
38
- ```bash
39
- import { Accordion5 } from '@djcali570/component-lib';
40
- import type { Accordion5ColorScheme } from '@djcali570/component-lib';
41
-
42
- let acs: Accordion5ColorScheme = {
43
- bgColor: '#121212',
44
- textColor: '#D6D6D6',
45
- triggerColor: '#D6D6D6'
46
- }
47
- ```
48
-
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"
55
-
56
- ### Use of the Accordion component
57
-
58
- ```
59
- <Accordion5 colorScheme={acs}>
60
- {#snippet title()}
61
- <h1>My Title</h1>
62
- {/snippet}
63
- {#snippet panel()}
64
- <p>Accordion Contents</p>
65
- {/snippet}
66
- </Accordion5>
67
- ```
68
-
69
- ## Chart
70
-
71
- Use the default or customize the chart color scheme
72
-
73
- ```bash
74
- import { Chart5 } from '@djcali570/component-lib';
75
- import type { Chart5ColorScheme } from '@djcali570/component-lib';
11
+ ```sh
12
+ # create a new project in the current directory
13
+ npx sv create
76
14
 
77
- let ccs: Chart5ColorScheme = {
78
- bgColor: '#121212',
79
- gridLineColor: '#303030',
80
- xAxisTextColor: '#5ac1dd',
81
- yAxisTextColor: '#5ac1dd'
82
- }
15
+ # create a new project in my-app
16
+ npx sv create my-app
83
17
  ```
84
18
 
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
19
+ To recreate this project with the same configuration:
91
20
 
92
- ### Use of the Chart component
93
-
94
- ```
95
- let labels: string[] = ['Label1', 'label2'];
96
- let values: number[] = [35, 20];
97
-
98
- <Chart5 {labels} {values} colorScheme={ccs} height="300px">
99
- {#snippet title()}
100
- <p>My Title</p>
101
- {/snippet}
102
- </Chart5>
21
+ ```sh
22
+ # recreate this project
23
+ pnpm dlx sv create --template library --types ts --add prettier eslint sveltekit-adapter="adapter:node" devtools-json --install pnpm component-lib-restored
103
24
  ```
104
25
 
105
- ## Admin Panel
106
-
107
- Use the default or customize the color scheme
108
-
109
- ```bash
110
- import { AdminPanel5 } from '@djcali570/component-lib';
111
- import type { AdminPanel5ColorScheme } from '@djcali570/component-lib';
26
+ ## Developing
112
27
 
113
- let apcs: AdminPanel5ColorScheme = {
114
- panelMenuBgColor: '#181818',
115
- panelBgColor: '#151515',
116
- drawerBgColor: '#121212',
117
- drawerTitleBgColor: '#151515',
118
- iconColor: '#D6D6D6'
119
- }
120
- ```
28
+ Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
121
29
 
122
- ### Use of the Admin Panel component
30
+ ```sh
31
+ npm run dev
123
32
 
124
- ```
125
- <AdminPanel5>
126
- {#snippet navigation()}
127
- <div>This is Navigation</div>
128
- {/snippet}
129
- {#snippet title()}
130
- <div style="display: flex; align-items:center; height:100%; width:100%;">
131
- <p style="color: #fff;">Title</p>
132
- </div>
133
- {/snippet}
134
- {#snippet panel()}
135
- <div style="display: flex; align-items:center; width:100%; padding:1em;">
136
- <p style="color: #fff;">This is the content</p>
137
- </div>
138
- {/snippet}
139
- {#snippet drawerTitle()}
140
- <div
141
- style="display:flex; justify-content:flex-start; align-items:center; width: 100%; height:100%;"
142
- >
143
- <div style="color: white;">This is a drawer title</div>
144
- </div>
145
- {/snippet}
146
- </AdminPanel5>
33
+ # or start the server and open the app in a new browser tab
34
+ npm run dev -- --open
147
35
  ```
148
36
 
149
- ## Bottom Sheet
37
+ Everything inside `src/lib` is part of your library, everything inside `src/routes` can be used as a showcase or preview app.
150
38
 
151
- Use the default or customize the color scheme
39
+ ## Building
152
40
 
153
- ```bash
154
- import { BottomSheet5 } from '@djcali570/component-lib';
155
- import type { BottomSheet5ColorScheme } from '@djcali570/component-lib';
41
+ To build your library:
156
42
 
157
- let bscs: BottomSheet5ColorScheme = {
158
- bgColor: '#121212',
159
- }
43
+ ```sh
44
+ npm pack
160
45
  ```
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
46
 
167
- ### Use of the component
168
-
169
- ```
170
- let modalStatus = $state(false);
47
+ To create a production version of your showcase app:
171
48
 
172
- <BottomSheet5 bind:modalStatus top="50%">
173
- {#snippet content()}
174
- <div>Place bottom sheet content here</div>
175
- {/snippet}
176
- </BottomSheet5>
49
+ ```sh
50
+ npm run build
177
51
  ```
178
52
 
179
- ## Dialog
53
+ You can preview the production build with `npm run preview`.
180
54
 
181
- Use the default or customize the color scheme
55
+ > To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.
182
56
 
183
- ```bash
184
- import { Dialog5 } from '@djcali570/component-lib';
185
- import type { Dialog5ColorScheme } from '@djcali570/component-lib';
57
+ ## Publishing
186
58
 
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.
59
+ Go into the `package.json` and give your package the desired name through the `"name"` option. Also consider adding a `"license"` field and point it to a `LICENSE` file which you can create from a template (one popular option is the [MIT license](https://opensource.org/license/mit/)).
205
60
 
206
- ### Use of the component
61
+ To publish your library to [npm](https://www.npmjs.com):
207
62
 
63
+ ```sh
64
+ npm publish
208
65
  ```
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
-
232
- # Updates
233
- #### 0.1.5 - Fixed issue where Accordion did not handle dynamic content.
234
- #### 0.1.4 - Updated Accordion component to add innerPadding prop.
235
- #### 0.1.3 - Updated Time Picker to allow binding to timeText.
236
- #### 0.1.2 - Fixed some minor styling issues with Dialog component.
237
- #### 0.1.1 - Added Bottom Sheet component & Dialog component.
238
- #### 0.1.0 - Updated Accordion component to use snippets for title.
239
- #### 0.0.14 - Fixed Input5 textarea height was not being applied. Removed Tailwind dependencies.
240
- #### 0.0.13 - Added Admin Panel 5 Component.
241
- #### 0.0.12 - Made all components colorScheme properties optional.
@@ -0,0 +1,119 @@
1
+ <script lang="ts">
2
+ let {
3
+ colorScheme: partialColorScheme = {},
4
+ name = 'checkbox',
5
+ title = 'Title',
6
+ checked = $bindable(false),
7
+ disabled = false,
8
+ hideText = false,
9
+ onChange = (checked: boolean) => {}
10
+ }: {
11
+ colorScheme?: Partial<{
12
+ mainTextColor: string;
13
+ mainBgColor: string;
14
+ borderColor: string;
15
+ focusedColor: string;
16
+ checkmarkColor: string;
17
+ }>;
18
+ name?: string;
19
+ title?: string;
20
+ checked?: boolean;
21
+ disabled?: boolean;
22
+ hideText?: boolean;
23
+ onChange?: (checked: boolean) => void;
24
+ } = $props();
25
+
26
+ const defaultColorScheme = {
27
+ mainTextColor: '#D6D6D6',
28
+ mainBgColor: '#121212',
29
+ borderColor: '#262626',
30
+ focusedColor: '#5ac1dd',
31
+ checkmarkColor: '#5ac1dd'
32
+ };
33
+
34
+ // svelte-ignore state_referenced_locally
35
+ const colorScheme = { ...defaultColorScheme, ...partialColorScheme };
36
+ const id = `checkbox-${Math.random().toString(36).slice(2, 8)}`;
37
+
38
+ $effect(() => {
39
+ onChange(checked);
40
+ });
41
+ </script>
42
+
43
+ <div
44
+ class="air5__checkbox__container"
45
+ style="
46
+ --air5__mainTextColor: {colorScheme.mainTextColor};
47
+ --air5__mainBgColor: {colorScheme.mainBgColor};
48
+ --air5__borderColor: {colorScheme.borderColor};
49
+ --air5__focusedColor: {colorScheme.focusedColor};
50
+ --air5__checkmarkColor: {colorScheme.checkmarkColor};
51
+ "
52
+ >
53
+ <label for={id}>
54
+ <input type="checkbox" {id} {name} bind:checked {disabled} />
55
+ <span class="air5__checkbox__custom">
56
+ {#if checked}
57
+ <svg viewBox="0 0 24 24">
58
+ <path
59
+ fill="currentColor"
60
+ d="M18 6 L6 18 M6 6 L18 18"
61
+ stroke="currentColor"
62
+ stroke-width="2"
63
+ stroke-linecap="round"
64
+ />
65
+ </svg>
66
+ {/if}
67
+ </span>
68
+ {#if !hideText}
69
+ <span class="air5__checkbox__title">{title}</span>
70
+ {/if}
71
+ </label>
72
+ </div>
73
+
74
+ <style>
75
+ .air5__checkbox__container {
76
+ display: flex;
77
+ flex-direction: column;
78
+ font-family: inherit;
79
+ color: var(--air5__mainTextColor);
80
+ }
81
+
82
+ input[type='checkbox'] {
83
+ display: none;
84
+ }
85
+
86
+ label {
87
+ display: flex;
88
+ align-items: center;
89
+ cursor: pointer;
90
+ }
91
+
92
+ .air5__checkbox__custom {
93
+ width: 32px;
94
+ height: 32px;
95
+ border: 1px solid var(--air5__borderColor);
96
+ border-radius: 0.25rem;
97
+ background-color: var(--air5__mainBgColor);
98
+ display: flex;
99
+ align-items: center;
100
+ justify-content: center;
101
+ margin-right: 0.5rem;
102
+ transition: box-shadow 0.2s ease;
103
+ }
104
+
105
+ label:focus-within .air5__checkbox__custom,
106
+ label:hover .air5__checkbox__custom {
107
+ box-shadow: 0 0 0 2px var(--air5__focusedColor);
108
+ }
109
+
110
+ .air5__checkbox__custom svg {
111
+ width: 24px;
112
+ height: 24px;
113
+ color: var(--air5__checkmarkColor);
114
+ }
115
+
116
+ .air5__checkbox__title {
117
+ font-size: 0.875rem;
118
+ }
119
+ </style>
@@ -0,0 +1,18 @@
1
+ type $$ComponentProps = {
2
+ colorScheme?: Partial<{
3
+ mainTextColor: string;
4
+ mainBgColor: string;
5
+ borderColor: string;
6
+ focusedColor: string;
7
+ checkmarkColor: string;
8
+ }>;
9
+ name?: string;
10
+ title?: string;
11
+ checked?: boolean;
12
+ disabled?: boolean;
13
+ hideText?: boolean;
14
+ onChange?: (checked: boolean) => void;
15
+ };
16
+ declare const Checkbox5: import("svelte").Component<$$ComponentProps, {}, "checked">;
17
+ type Checkbox5 = ReturnType<typeof Checkbox5>;
18
+ export default Checkbox5;
package/dist/index.d.ts CHANGED
@@ -5,8 +5,9 @@ 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, BottomSheet5ColorScheme, Dialog5ColorScheme } from "./types.js";
8
+ import Checkbox5 from "./Checkbox5.svelte";
9
+ import type { Input5ColorScheme, DatePicker5ColorScheme, TimePicker5ColorScheme, DropDownItem, DropDown5ColorScheme, Accordion5ColorScheme, Chart5ColorScheme, AdminPanel5ColorScheme, BottomSheet5ColorScheme, Dialog5ColorScheme, Checkbox5ColorScheme } from "./types.js";
9
10
  import BottomSheet5 from "./BottomSheet5.svelte";
10
11
  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 };
12
+ export { DatePicker5, Input5, DropDown5, TimePicker5, Accordion5, Chart5, AdminPanel5, BottomSheet5, Dialog5, Checkbox5 };
13
+ export type { Input5ColorScheme, DatePicker5ColorScheme, TimePicker5ColorScheme, Accordion5ColorScheme, DropDown5ColorScheme, DropDownItem, Chart5ColorScheme, AdminPanel5ColorScheme, BottomSheet5ColorScheme, Dialog5ColorScheme, Checkbox5ColorScheme };
package/dist/types.d.ts CHANGED
@@ -89,3 +89,11 @@ export interface Dialog5ColorScheme {
89
89
  okButtonBgColor?: string;
90
90
  confirmButtonBgColor?: string;
91
91
  }
92
+
93
+ export interface Checkbox5ColorScheme {
94
+ mainTextColor?: string;
95
+ mainBgColor?: string;
96
+ borderColor?: string;
97
+ focusedColor?: string;
98
+ checkmarkColor?: string;
99
+ }
package/package.json CHANGED
@@ -1,64 +1,64 @@
1
1
  {
2
- "name": "@djcali570/component-lib",
3
- "version": "0.1.5",
4
- "files": [
5
- "dist",
6
- "!dist/**/*.test.*",
7
- "!dist/**/*.spec.*"
8
- ],
9
- "sideEffects": [
10
- "**/*.css"
11
- ],
12
- "svelte": "./dist/index.js",
13
- "types": "./dist/index.d.ts",
14
- "type": "module",
15
- "exports": {
16
- ".": {
17
- "types": "./dist/index.d.ts",
18
- "svelte": "./dist/index.js"
19
- }
20
- },
21
- "peerDependencies": {
22
- "@sveltejs/kit": "^2.16.0",
23
- "svelte": "^5.0.0"
24
- },
25
- "devDependencies": {
26
- "@eslint/compat": "^1.2.5",
27
- "@eslint/js": "^9.18.0",
28
- "@sveltejs/adapter-auto": "^6.0.0",
29
- "@sveltejs/kit": "^2.16.0",
30
- "@sveltejs/package": "^2.0.0",
31
- "@sveltejs/vite-plugin-svelte": "^5.0.0",
32
- "@tailwindcss/vite": "^4.0.0",
33
- "eslint": "^9.18.0",
34
- "eslint-config-prettier": "^10.0.1",
35
- "eslint-plugin-svelte": "^3.0.0",
36
- "globals": "^16.0.0",
37
- "prettier": "^3.4.2",
38
- "prettier-plugin-svelte": "^3.3.3",
39
- "publint": "^0.3.2",
40
- "svelte": "^5.0.0",
41
- "svelte-check": "^4.0.0",
42
- "typescript": "^5.0.0",
43
- "typescript-eslint": "^8.20.0",
44
- "vite": "^6.2.6"
45
- },
46
- "keywords": [
47
- "svelte",
48
- "SvelteKit",
49
- "components"
50
- ],
51
- "author": {
52
- "name": "Jay Cali"
53
- },
54
- "scripts": {
55
- "dev": "vite dev",
56
- "build": "vite build && npm run prepack",
57
- "package": "svelte-kit sync && svelte-package && publint",
58
- "preview": "vite preview",
59
- "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
60
- "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
61
- "format": "prettier --write .",
62
- "lint": "prettier --check . && eslint ."
63
- }
2
+ "name": "@djcali570/component-lib",
3
+ "version": "0.1.7",
4
+ "files": [
5
+ "dist",
6
+ "!dist/**/*.test.*",
7
+ "!dist/**/*.spec.*"
8
+ ],
9
+ "sideEffects": [
10
+ "**/*.css"
11
+ ],
12
+ "svelte": "./dist/index.js",
13
+ "types": "./dist/index.d.ts",
14
+ "type": "module",
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "svelte": "./dist/index.js"
19
+ }
20
+ },
21
+ "peerDependencies": {
22
+ "svelte": "^5.0.0"
23
+ },
24
+ "devDependencies": {
25
+ "@eslint/compat": "^2.0.2",
26
+ "@eslint/js": "^9.39.2",
27
+ "@sveltejs/adapter-node": "^5.5.2",
28
+ "@sveltejs/kit": "^2.50.2",
29
+ "@sveltejs/package": "^2.5.7",
30
+ "@sveltejs/vite-plugin-svelte": "^6.2.4",
31
+ "@types/node": "^22",
32
+ "eslint": "^9.39.2",
33
+ "eslint-config-prettier": "^10.1.8",
34
+ "eslint-plugin-svelte": "^3.14.0",
35
+ "globals": "^17.3.0",
36
+ "prettier": "^3.8.1",
37
+ "prettier-plugin-svelte": "^3.4.1",
38
+ "publint": "^0.3.17",
39
+ "svelte": "^5.49.2",
40
+ "svelte-check": "^4.3.6",
41
+ "typescript": "^5.9.3",
42
+ "typescript-eslint": "^8.54.0",
43
+ "vite": "^7.3.1",
44
+ "vite-plugin-devtools-json": "^1.0.0"
45
+ },
46
+ "keywords": [
47
+ "svelte",
48
+ "SvelteKit",
49
+ "components"
50
+ ],
51
+ "author": {
52
+ "name": "Jay Cali"
53
+ },
54
+ "scripts": {
55
+ "dev": "vite dev",
56
+ "build": "vite build && npm run prepack",
57
+ "package": "svelte-kit sync && svelte-package && publint",
58
+ "preview": "vite preview",
59
+ "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
60
+ "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
61
+ "format": "prettier --write .",
62
+ "lint": "prettier --check . && eslint ."
63
+ }
64
64
  }