@sesamy/sesamy-components 2.14.0 → 2.15.0

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
@@ -14,13 +14,12 @@ npm install @sesamy/sesamy-components
14
14
  yarn add @sesamy/sesamy-components
15
15
  ```
16
16
 
17
- ## Components
18
-
19
- ### sesamy-login
17
+ # sesamy-login
20
18
 
21
19
  A web component that provides authentication functionality, displaying a login button for unauthenticated users and an avatar with a dropdown menu for authenticated users.
22
20
 
23
21
  **Props/Attributes:**
22
+
24
23
  - `buttonText`: Text to display on the login button
25
24
  - `loading`: Boolean to show loading state
26
25
  - `loggedIn`: Boolean indicating if user is logged in
@@ -30,9 +29,11 @@ A web component that provides authentication functionality, displaying a login b
30
29
  - `class`: CSS classes to apply to the component
31
30
 
32
31
  **Events:**
32
+
33
33
  - `login`: Dispatched when login action is triggered
34
34
 
35
35
  **Basic Usage Example:**
36
+
36
37
  ```html
37
38
  <!-- Simple login button -->
38
39
  <sesamy-login></sesamy-login>
@@ -42,6 +43,7 @@ A web component that provides authentication functionality, displaying a login b
42
43
  ```
43
44
 
44
45
  **Design tokens:**
46
+
45
47
  ```html
46
48
  <sesamy-login
47
49
  style="
@@ -63,11 +65,83 @@ A web component that provides authentication functionality, displaying a login b
63
65
  ></sesamy-login>
64
66
  ```
65
67
 
68
+ ## Slots
69
+
70
+ The `sesamy-login` component provides several slots for customizing its appearance and behavior:
71
+
72
+ ### button-text
73
+
74
+ - **Purpose:** Replaces the default login button text.
75
+ - **Behavior:** Content in this slot will be rendered as the main text of the login button, replacing the default (localized) "login" text.
76
+ - **Example:**
77
+ ```html
78
+ <sesamy-login>
79
+ <span slot="button-text">Sign in with Email</span>
80
+ </sesamy-login>
81
+ ```
82
+
83
+ ### button-text-prefix
84
+
85
+ - **Purpose:** Inserts content before the login button text.
86
+ - **Behavior:** Content in this slot will appear before the main button text, useful for adding icons or labels.
87
+ - **Example:**
88
+ ```html
89
+ <sesamy-login>
90
+ <span slot="button-text-prefix">🔒</span>
91
+ </sesamy-login>
92
+ ```
93
+
94
+ ### button-text-suffix
95
+
96
+ - **Purpose:** Inserts content after the login button text.
97
+ - **Behavior:** Content in this slot will appear after the main button text, useful for adding icons or additional info.
98
+ - **Example:**
99
+ ```html
100
+ <sesamy-login>
101
+ <span slot="button-text-suffix">→</span>
102
+ </sesamy-login>
103
+ ```
104
+
105
+ ### avatar
106
+
107
+ - **Purpose:** Replaces the default avatar shown when logged in.
108
+ - **Behavior:** Content in this slot will be rendered instead of the default avatar image/button when the user is authenticated.
109
+ - **Example:**
110
+ ```html
111
+ <sesamy-login>
112
+ <img
113
+ slot="avatar"
114
+ src="/my-avatar.png"
115
+ alt="User avatar"
116
+ style="width:32px;height:32px;border-radius:50%"
117
+ />
118
+ </sesamy-login>
119
+ ```
120
+
121
+ ### popup-menu
122
+
123
+ - **Purpose:** Replaces the default popup menu shown when clicking the avatar.
124
+ - **Behavior:** Content in this slot will be rendered instead of the default menu (email/account/logout) when the user is authenticated and opens the menu.
125
+ - **Example:**
126
+ ```html
127
+ <sesamy-login>
128
+ <div slot="popup-menu">
129
+ <a href="/profile">Profile</a>
130
+ <a href="/logout">Logout</a>
131
+ </div>
132
+ </sesamy-login>
133
+ ```
134
+
135
+ **Note:**
136
+
137
+ - All slots are optional. If not provided, the component will render its default content for each area.
138
+
66
139
  ### sesamy-content-container
67
140
 
68
141
  A web component that controls access to content based on user authentication and entitlements, with support for different content locking mechanisms.
69
142
 
70
143
  **Props/Attributes:**
144
+
71
145
  - `item-src`: URL of the content item
72
146
  - `pass`: Semicolon-separated list of pass IDs that grant access
73
147
  - `access-level`: Access level required ('public', 'logged-in', or 'entitlement')
@@ -76,9 +150,11 @@ A web component that controls access to content based on user authentication and
76
150
  - `locked-content-selector`: CSS selector for locked content when using signed URLs
77
151
 
78
152
  **Events:**
153
+
79
154
  - `sesamyUnlocked`: Dispatched when content is unlocked (with `item-src` and `publisher-content-id` in detail)
80
155
 
81
156
  **Basic Usage Example:**
157
+
82
158
  ```html
83
159
  <!-- Basic content container with preview and locked content -->
84
160
  <sesamy-content-container item-src="https://example.com/article.html">
@@ -93,11 +169,12 @@ A web component that controls access to content based on user authentication and
93
169
  </sesamy-content-container>
94
170
  ```
95
171
 
96
- ### sesamy-paywall
172
+ # sesamy-paywall
97
173
 
98
174
  A web component that displays a paywall for content, loading paywall settings from a remote URL and supporting different templates (Article, Boxes, Login).
99
175
 
100
176
  **Props/Attributes:**
177
+
101
178
  - `settings-url`: URL to fetch paywall settings (required)
102
179
  - `item-src`: URL of the content item
103
180
  - `price`: Price of the content
@@ -106,27 +183,72 @@ A web component that displays a paywall for content, loading paywall settings fr
106
183
  - `utm-source`, `utm-medium`, `utm-campaign`, `utm-term`, `utm-content`: UTM parameters for tracking
107
184
  - `pass`: Pass ID for access
108
185
 
186
+ **Slots:**
187
+
188
+ - `below-headline`: Content rendered below the paywall headline (e.g., additional info, custom elements)
189
+ - `features`: Content rendered in the features section of the paywall (e.g., feature list, benefits)
190
+
109
191
  **Basic Usage Example:**
192
+
110
193
  ```html
111
194
  <!-- Article paywall -->
112
- <sesamy-paywall
113
- settings-url="https://api.example.com/paywall/settings"
195
+ <sesamy-paywall
196
+ settings-url="https://api.example.com/paywall/settings"
114
197
  item-src="https://example.com/article"
115
198
  price="99"
116
- currency="USD">
199
+ currency="USD"
200
+ >
201
+ <div slot="features">✔️ Unlimited access<br />✔️ Cancel anytime</div>
117
202
  </sesamy-paywall>
118
203
 
119
- <!-- Login paywall -->
204
+ <!-- Login paywall with below-headline slot -->
120
205
  <sesamy-paywall settings-url="https://api.example.com/paywall/login-settings">
121
206
  <div slot="below-headline">Additional content below headline</div>
122
207
  </sesamy-paywall>
123
208
  ```
124
209
 
125
- ### sesamy-visibility
210
+ ## Slots
211
+
212
+ The `sesamy-paywall` component provides two main slots for customization:
213
+
214
+ ### below-headline
215
+
216
+ - **Purpose:** Inserts custom content directly below the paywall headline.
217
+ - **Behavior:** The content you provide in this slot will be rendered in addition to the default paywall content, immediately below the headline. Use this for adding extra information, banners, or custom elements.
218
+ - **Example:**
219
+ ```html
220
+ <sesamy-paywall settings-url="https://api.example.com/paywall/login-settings">
221
+ <div slot="below-headline">Special offer for new users!</div>
222
+ </sesamy-paywall>
223
+ ```
224
+
225
+ ### features
226
+
227
+ - **Purpose:** Replaces the default features section of the paywall.
228
+ - **Behavior:** When you provide content in the `features` slot, it will completely replace the built-in features list or section. Use this slot to fully customize the list of benefits, features, or selling points shown to the user.
229
+ - **Example:**
230
+ ```html
231
+ <sesamy-paywall settings-url="https://api.example.com/paywall/settings">
232
+ <div slot="features">
233
+ <ul>
234
+ <li>✔️ Unlimited access</li>
235
+ <li>✔️ Cancel anytime</li>
236
+ <li>✔️ Exclusive articles</li>
237
+ </ul>
238
+ </div>
239
+ </sesamy-paywall>
240
+ ```
241
+
242
+ **Note:**
243
+
244
+ - The `below-headline` slot adds to the paywall, while the `features` slot replaces the default features section entirely.
245
+
246
+ # sesamy-visibility
126
247
 
127
248
  A simple web component that conditionally renders content based on user authentication status.
128
249
 
129
250
  **Basic Usage Example:**
251
+
130
252
  ```html
131
253
  <sesamy-visibility>
132
254
  <div slot="logged-in">This content is only visible when logged in</div>