@cal.macconnachie/web-components 0.0.21 → 1.0.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 +27 -149
- package/dist/components/{auth.js → auth-form.js} +689 -805
- package/dist/components/base-button.js +894 -0
- package/dist/components/base-card.js +879 -0
- package/dist/components/base-date-picker.js +1458 -0
- package/dist/components/base-datetime-picker.js +1697 -0
- package/dist/components/base-drawer.js +1300 -0
- package/dist/components/base-input.js +883 -0
- package/dist/components/base-select.js +1076 -0
- package/dist/components/base-tab.js +653 -0
- package/dist/components/base-tabs.js +1246 -0
- package/dist/components/base-textarea.js +921 -0
- package/dist/components/base-time-picker.js +1141 -0
- package/dist/components/favicon.ico +0 -0
- package/dist/components/index.d.ts +399 -33
- package/dist/components/quantity-select.js +859 -0
- package/dist/components/theme-toggle.js +185 -165
- package/dist/favicon.ico +0 -0
- package/dist/index.d.ts +399 -33
- package/dist/index.js +7365 -2352
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,164 +1,42 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @cal.macconnachie/web-components
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A collection of lightweight, framework-agnostic web components built with Lit.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Components
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- **auth-form** - Authentication with OAuth and email/password
|
|
8
|
+
- **base-button** - Customizable button component
|
|
9
|
+
- **base-card** - Card container component
|
|
10
|
+
- **base-date-picker** - Date selection input
|
|
11
|
+
- **base-datetime-picker** - Combined date and time picker
|
|
12
|
+
- **base-drawer** - Slide-out drawer panel
|
|
13
|
+
- **base-input** - Text input field
|
|
14
|
+
- **base-select** - Dropdown select menu
|
|
15
|
+
- **base-tabs** & **base-tab** - Tabbed content interface
|
|
16
|
+
- **base-textarea** - Multi-line text input
|
|
17
|
+
- **base-time-picker** - Time selection input
|
|
18
|
+
- **quantity-select** - Quantity increment/decrement control
|
|
19
|
+
- **theme-toggle** - Light/dark mode switcher
|
|
8
20
|
|
|
9
|
-
|
|
21
|
+
## Quick Start
|
|
10
22
|
|
|
11
|
-
|
|
12
|
-
<script type="module" src="https://cdn.cals-api.com/index"></script>
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
### Option 2: Load individual components (recommended)
|
|
16
|
-
|
|
17
|
-
Load only the components you need:
|
|
23
|
+
Load from CDN:
|
|
18
24
|
|
|
19
25
|
```html
|
|
20
|
-
<!-- Load
|
|
21
|
-
<script type="module" src="https://cdn.cals-api.com/
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
### Option 3: Using with Vue, React, or other frameworks
|
|
26
|
+
<!-- Load all components -->
|
|
27
|
+
<script type="module" src="https://cdn.cals-api.com/index.js"></script>
|
|
25
28
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
```html
|
|
29
|
-
<!-- index.html -->
|
|
30
|
-
<script type="module" src="https://cdn.cals-api.com/components/auth.js"></script>
|
|
29
|
+
<!-- Or load individual components -->
|
|
30
|
+
<script type="module" src="https://cdn.cals-api.com/components/auth-form.js"></script>
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
```typescript
|
|
36
|
-
// src/types/auth.d.ts
|
|
37
|
-
export interface Auth extends HTMLElement {
|
|
38
|
-
openModal(): void;
|
|
39
|
-
logout(): void;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
declare global {
|
|
43
|
-
interface HTMLElementTagNameMap {
|
|
44
|
-
'auth': Auth;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
Now you can use it with full type safety in your components:
|
|
50
|
-
|
|
51
|
-
**Vue:**
|
|
52
|
-
```vue
|
|
53
|
-
<template>
|
|
54
|
-
<auth ref="authRef" app-name="Marketplace"></auth>
|
|
55
|
-
<button @click="openAuth">Login / Sign up</button>
|
|
56
|
-
</template>
|
|
57
|
-
|
|
58
|
-
<script setup lang="ts">
|
|
59
|
-
import { ref } from 'vue';
|
|
60
|
-
import type { Auth } from '@/types/auth';
|
|
61
|
-
|
|
62
|
-
const authRef = ref<Auth>();
|
|
63
|
-
|
|
64
|
-
const openAuth = () => {
|
|
65
|
-
authRef.value?.openModal();
|
|
66
|
-
};
|
|
67
|
-
</script>
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
**React:**
|
|
71
|
-
```tsx
|
|
72
|
-
import { useRef } from 'react';
|
|
73
|
-
import type { Auth } from '@/types/auth';
|
|
74
|
-
|
|
75
|
-
function App() {
|
|
76
|
-
const authRef = useRef<Auth>(null);
|
|
77
|
-
|
|
78
|
-
return (
|
|
79
|
-
<>
|
|
80
|
-
<auth ref={authRef} app-name="Marketplace"></auth>
|
|
81
|
-
<button onClick={() => authRef.current?.openModal()}>
|
|
82
|
-
Login / Sign up
|
|
83
|
-
</button>
|
|
84
|
-
</>
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
### Usage Example
|
|
90
|
-
|
|
91
|
-
HTML:
|
|
33
|
+
Use in your HTML:
|
|
92
34
|
|
|
93
35
|
```html
|
|
94
|
-
<
|
|
95
|
-
|
|
96
|
-
<button id="open-auth">Login / Sign up</button>
|
|
97
|
-
<button id="logout-auth">Logout</button>
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
JavaScript:
|
|
101
|
-
```js
|
|
102
|
-
const auth = document.querySelector('auth');
|
|
103
|
-
|
|
104
|
-
document.getElementById('open-auth')?.addEventListener('click', () => {
|
|
105
|
-
auth?.openModal();
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
document.getElementById('logout-auth')?.addEventListener('click', () => {
|
|
109
|
-
auth?.logout();
|
|
110
|
-
});
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
TypeScript:
|
|
114
|
-
```typescript
|
|
115
|
-
import type { Auth } from 'https://cdn.cals-api.com/components/auth.js';
|
|
116
|
-
|
|
117
|
-
const auth = document.querySelector<Auth>('auth');
|
|
118
|
-
|
|
119
|
-
document.getElementById('open-auth')?.addEventListener('click', () => {
|
|
120
|
-
auth?.openModal();
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
document.getElementById('logout-auth')?.addEventListener('click', () => {
|
|
124
|
-
auth?.logout();
|
|
125
|
-
});
|
|
36
|
+
<base-button>Click me</base-button>
|
|
37
|
+
<auth-form app-name="My App"></auth-form>
|
|
126
38
|
```
|
|
127
39
|
|
|
128
|
-
##
|
|
129
|
-
|
|
130
|
-
- `auth` - Authentication component with sign in, sign up, and password reset
|
|
131
|
-
|
|
132
|
-
## Project Structure
|
|
133
|
-
|
|
134
|
-
This repository uses Yarn workspaces to manage two packages:
|
|
135
|
-
- **Root package** (`web-components`): The Lit web component library
|
|
136
|
-
- **CDN package** (`cdn/`): AWS CDK infrastructure for deploying the component to CloudFront
|
|
137
|
-
|
|
138
|
-
## Develop
|
|
139
|
-
|
|
140
|
-
### Web Component Development
|
|
141
|
-
- `yarn install` – install dependencies for all workspaces
|
|
142
|
-
- `yarn dev` – run the Vite playground at `http://localhost:5173`
|
|
143
|
-
- `yarn build` – bundle the full library to `dist/`
|
|
144
|
-
- `yarn build:components` – build individual components to `dist/components/{component-name}/`
|
|
145
|
-
- `yarn typecheck` – run TypeScript without emitting
|
|
146
|
-
|
|
147
|
-
### CDK Infrastructure
|
|
148
|
-
- `yarn cdk:synth` – synthesize the CDK stack
|
|
149
|
-
- `yarn cdk:diff` – compare deployed stack with current state
|
|
150
|
-
- `yarn cdk:deploy` – deploy the CDK stack to AWS
|
|
151
|
-
- `yarn cdk:destroy` – destroy the CDK stack
|
|
152
|
-
- `yarn cdk <command>` – run any CDK command
|
|
153
|
-
|
|
154
|
-
## Publish
|
|
155
|
-
|
|
156
|
-
Publishing to the CDN is automated on pushes to `main` via `.github/workflows/publish.yml`.
|
|
40
|
+
## Playground
|
|
157
41
|
|
|
158
|
-
|
|
159
|
-
1. Builds the full bundle and individual components
|
|
160
|
-
2. Deploys the CDK stack (S3 + CloudFront)
|
|
161
|
-
3. Uploads files to S3:
|
|
162
|
-
- Full bundle at root: `https://cdn.cals-api.com/index.es.js`
|
|
163
|
-
- Individual components: `https://cdn.cals-api.com/components/{component-name}/index.es.js`
|
|
164
|
-
4. Invalidates CloudFront cache
|
|
42
|
+
View live examples and documentation at [https://cdn.cals-api.com/](https://cdn.cals-api.com/)
|