@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 CHANGED
@@ -1,164 +1,42 @@
1
- # Cals Web Components
1
+ # @cal.macconnachie/web-components
2
2
 
3
- Repo to handle any and all web components I may want to build
3
+ A collection of lightweight, framework-agnostic web components built with Lit.
4
4
 
5
- ## Install & use
5
+ ## Components
6
6
 
7
- ### Option 1: Load the full bundle (all components)
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
- Load all components from the CDN:
21
+ ## Quick Start
10
22
 
11
- ```html
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 just the auth component -->
21
- <script type="module" src="https://cdn.cals-api.com/components/auth.js"></script>
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
- For framework projects (Vue, React, etc.), load the component via script tag in your `index.html`:
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
- Then create a type declaration file for TypeScript support:
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
- <auth id="auth" app-name="Marketplace"></auth>
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
- ## Available Components
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
- The workflow:
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/)