@hotosm/hanko-auth 0.3.4 → 0.4.1
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 +39 -43
- package/dist/hanko-auth.esm.js +1869 -1693
- package/dist/hanko-auth.iife.js +490 -329
- package/dist/hanko-auth.umd.js +490 -329
- package/package.json +1 -5
- package/src/hanko-auth.styles.ts +406 -0
- package/src/hanko-auth.ts +180 -345
- package/src/translations.ts +87 -0
package/README.md
CHANGED
|
@@ -15,36 +15,11 @@ pnpm add @hotosm/hanko-auth
|
|
|
15
15
|
yarn add @hotosm/hanko-auth
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
### Peer Dependencies
|
|
19
|
-
|
|
20
|
-
This package requires Web Awesome to be installed separately:
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
# npm
|
|
24
|
-
npm install @awesome.me/webawesome
|
|
25
|
-
|
|
26
|
-
# pnpm
|
|
27
|
-
pnpm add @awesome.me/webawesome
|
|
28
|
-
|
|
29
|
-
# yarn
|
|
30
|
-
yarn add @awesome.me/webawesome
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
**Why peer dependencies?**
|
|
34
|
-
|
|
35
|
-
- Control the Web Awesome version in your project
|
|
36
|
-
- Share Web Awesome across multiple packages without duplication
|
|
37
|
-
- Reduce bundle size when multiple packages use Web Awesome
|
|
38
|
-
|
|
39
18
|
## Quick Start
|
|
40
19
|
|
|
41
20
|
### Import the component
|
|
42
21
|
|
|
43
|
-
```
|
|
44
|
-
// Import Web Awesome (required peer dependency)
|
|
45
|
-
import "@awesome.me/webawesome";
|
|
46
|
-
|
|
47
|
-
// Import the auth component
|
|
22
|
+
```js
|
|
48
23
|
import "@hotosm/hanko-auth";
|
|
49
24
|
```
|
|
50
25
|
|
|
@@ -61,7 +36,6 @@ import "@hotosm/hanko-auth";
|
|
|
61
36
|
|
|
62
37
|
```tsx
|
|
63
38
|
import { useEffect, useRef } from "react";
|
|
64
|
-
import "@awesome.me/webawesome";
|
|
65
39
|
import "@hotosm/hanko-auth";
|
|
66
40
|
|
|
67
41
|
export function AuthButton({ hankoUrl, onLogin }) {
|
|
@@ -99,10 +73,13 @@ export function AuthButton({ hankoUrl, onLogin }) {
|
|
|
99
73
|
|
|
100
74
|
### Display
|
|
101
75
|
|
|
102
|
-
| Attribute
|
|
103
|
-
|
|
|
104
|
-
| `show-profile`
|
|
105
|
-
| `display-name`
|
|
76
|
+
| Attribute | Type | Default | Description |
|
|
77
|
+
| ---------------- | ------- | ---------- | ----------------------------------------------------------------- |
|
|
78
|
+
| `show-profile` | boolean | `false` | Show full profile (vs header button) |
|
|
79
|
+
| `display-name` | string | `""` | Override display name |
|
|
80
|
+
| `lang` | string | `"en"` | Language/locale code (e.g., "en", "es", "fr"). Enlish as fallback |
|
|
81
|
+
| `button-variant` | string | `"filled"` | Button style: `filled`, `outline`, or `plain` |
|
|
82
|
+
| `button-color` | string | `"primary"`| Button color: `primary`, `neutral`, or `danger` |
|
|
106
83
|
|
|
107
84
|
### Redirects
|
|
108
85
|
|
|
@@ -132,7 +109,7 @@ The component dispatches the following custom events:
|
|
|
132
109
|
|
|
133
110
|
### Event Handling Example
|
|
134
111
|
|
|
135
|
-
```
|
|
112
|
+
```js
|
|
136
113
|
const auth = document.querySelector("hotosm-auth");
|
|
137
114
|
|
|
138
115
|
auth.addEventListener("hanko-login", (e) => {
|
|
@@ -164,6 +141,36 @@ Shows a compact login button in the header:
|
|
|
164
141
|
</header>
|
|
165
142
|
```
|
|
166
143
|
|
|
144
|
+
#### Button Styling
|
|
145
|
+
|
|
146
|
+
Customize the login button appearance with `button-variant` and `button-color`:
|
|
147
|
+
|
|
148
|
+
```html
|
|
149
|
+
<!-- Filled primary button (default) -->
|
|
150
|
+
<hotosm-auth hanko-url="https://login.hotosm.org"></hotosm-auth>
|
|
151
|
+
|
|
152
|
+
<!-- Outline button -->
|
|
153
|
+
<hotosm-auth
|
|
154
|
+
hanko-url="https://login.hotosm.org"
|
|
155
|
+
button-variant="outline"
|
|
156
|
+
button-color="primary"
|
|
157
|
+
></hotosm-auth>
|
|
158
|
+
|
|
159
|
+
<!-- Plain text button -->
|
|
160
|
+
<hotosm-auth
|
|
161
|
+
hanko-url="https://login.hotosm.org"
|
|
162
|
+
button-variant="plain"
|
|
163
|
+
button-color="neutral"
|
|
164
|
+
></hotosm-auth>
|
|
165
|
+
|
|
166
|
+
<!-- Filled danger button -->
|
|
167
|
+
<hotosm-auth
|
|
168
|
+
hanko-url="https://login.hotosm.org"
|
|
169
|
+
button-variant="filled"
|
|
170
|
+
button-color="danger"
|
|
171
|
+
></hotosm-auth>
|
|
172
|
+
```
|
|
173
|
+
|
|
167
174
|
### Profile Mode
|
|
168
175
|
|
|
169
176
|
Shows full authentication form (for login pages):
|
|
@@ -203,14 +210,3 @@ The component detects the Hanko URL in the following priority order:
|
|
|
203
210
|
</script>
|
|
204
211
|
<hotosm-auth></hotosm-auth>
|
|
205
212
|
```
|
|
206
|
-
|
|
207
|
-
## Styling
|
|
208
|
-
|
|
209
|
-
The component uses Shadow DOM. Override styles with CSS custom properties:
|
|
210
|
-
|
|
211
|
-
```css
|
|
212
|
-
hotosm-auth {
|
|
213
|
-
--primary-color: #d73f3f;
|
|
214
|
-
--text-color: #333;
|
|
215
|
-
}
|
|
216
|
-
```
|