@sesamy/sesamy-components 2.11.0 → 2.12.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 CHANGED
@@ -1,21 +1,119 @@
1
1
  # 🌐 sesamy-components
2
2
 
3
- > A project for building a shareable web components library using [Vite](https://vitejs.dev), [Svelte](https://svelte.dev), [storybook](https://storybook.js.org) and [TypeScript](https://www.typescriptlang.org).
3
+ > A shareable web components library using [Vite](https://vitejs.dev), [Svelte](https://svelte.dev), [storybook](https://storybook.js.org) and [TypeScript](https://www.typescriptlang.org).
4
4
 
5
- This templates generates typed [web components](https://developer.mozilla.org/en-US/docs/Web/Web_Components) than can be used with [plain HTML](https://www.webcomponents.org/introduction#how-do-i-use-a-web-component-) or within any major frameworks, such as React, Angular, Vue or Svelte (see [compatibility](https://custom-elements-everywhere.com/)).
5
+ This library provides typed [web components](https://developer.mozilla.org/en-US/docs/Web/Web_Components) that can be used with [plain HTML](https://www.webcomponents.org/introduction#how-do-i-use-a-web-component-) or within any major frameworks, such as React, Angular, Vue or Svelte (see [compatibility](https://custom-elements-everywhere.com/)).
6
6
 
7
- ## How to use this template
7
+ ## Installation
8
8
 
9
- You can directly create a new GitHub repo from this template by selecting the **Use this template** button on GitHub.
10
-
11
- You can also clone it locally with the following commands:
9
+ You can install the package with:
12
10
 
13
11
  ```bash
14
- npx degit sesamy/sesamy-components
15
- cd sesamy-components
16
- yarn
12
+ npm install @sesamy/sesamy-components
13
+ # or
14
+ yarn add @sesamy/sesamy-components
17
15
  ```
18
16
 
17
+ ## Components
18
+
19
+ ### sesamy-login
20
+
21
+ 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
+
23
+ **Props/Attributes:**
24
+ - `buttonText`: Text to display on the login button
25
+ - `loading`: Boolean to show loading state
26
+ - `loggedIn`: Boolean indicating if user is logged in
27
+ - `userAvatar`: URL to the user's avatar image
28
+ - `lang`: Language setting for the component
29
+ - `variant`: Appearance variant ('text', 'picture', or 'link')
30
+ - `class`: CSS classes to apply to the component
31
+
32
+ **Events:**
33
+ - `login`: Dispatched when login action is triggered
34
+
35
+ **Basic Usage Example:**
36
+ ```html
37
+ <!-- Simple login button -->
38
+ <sesamy-login></sesamy-login>
39
+
40
+ <!-- Customized login button -->
41
+ <sesamy-login button-text="Sign In Now"></sesamy-login>
42
+ ```
43
+
44
+ ### sesamy-content-container
45
+
46
+ A web component that controls access to content based on user authentication and entitlements, with support for different content locking mechanisms.
47
+
48
+ **Props/Attributes:**
49
+ - `item-src`: URL of the content item
50
+ - `pass`: Semicolon-separated list of pass IDs that grant access
51
+ - `access-level`: Access level required ('public', 'logged-in', or 'entitlement')
52
+ - `publisher-content-id`: ID of the content from the publisher
53
+ - `lock-mode`: Content locking mechanism ('embed', 'encode', 'signedUrl', 'event', or 'proxy')
54
+ - `locked-content-selector`: CSS selector for locked content when using signed URLs
55
+
56
+ **Events:**
57
+ - `sesamyUnlocked`: Dispatched when content is unlocked (with `item-src` and `publisher-content-id` in detail)
58
+
59
+ **Basic Usage Example:**
60
+ ```html
61
+ <!-- Basic content container with preview and locked content -->
62
+ <sesamy-content-container item-src="https://example.com/article.html">
63
+ <div slot="preview">This is a preview visible to everyone</div>
64
+ <div slot="content">This is the full content for authorized users</div>
65
+ </sesamy-content-container>
66
+
67
+ <!-- Content visible only to logged-in users -->
68
+ <sesamy-content-container access-level="logged-in">
69
+ <div slot="preview">Please log in to view this content</div>
70
+ <div slot="content">This content is for logged-in users only</div>
71
+ </sesamy-content-container>
72
+ ```
73
+
74
+ ### sesamy-paywall
75
+
76
+ A web component that displays a paywall for content, loading paywall settings from a remote URL and supporting different templates (Article, Boxes, Login).
77
+
78
+ **Props/Attributes:**
79
+ - `settings-url`: URL to fetch paywall settings (required)
80
+ - `item-src`: URL of the content item
81
+ - `price`: Price of the content
82
+ - `currency`: Currency code for the price
83
+ - `redirect-url`: URL to redirect after purchase
84
+ - `utm-source`, `utm-medium`, `utm-campaign`, `utm-term`, `utm-content`: UTM parameters for tracking
85
+ - `pass`: Pass ID for access
86
+
87
+ **Basic Usage Example:**
88
+ ```html
89
+ <!-- Article paywall -->
90
+ <sesamy-paywall
91
+ settings-url="https://api.example.com/paywall/settings"
92
+ item-src="https://example.com/article"
93
+ price="99"
94
+ currency="USD">
95
+ </sesamy-paywall>
96
+
97
+ <!-- Login paywall -->
98
+ <sesamy-paywall settings-url="https://api.example.com/paywall/login-settings">
99
+ <div slot="below-headline">Additional content below headline</div>
100
+ </sesamy-paywall>
101
+ ```
102
+
103
+ ### sesamy-visibility
104
+
105
+ A simple web component that conditionally renders content based on user authentication status.
106
+
107
+ **Basic Usage Example:**
108
+ ```html
109
+ <sesamy-visibility>
110
+ <div slot="logged-in">This content is only visible when logged in</div>
111
+ <div slot="not-logged-in">This content is only visible when not logged in</div>
112
+ </sesamy-visibility>
113
+ ```
114
+
115
+ ## Development
116
+
19
117
  Your components source code lives in `lib/` folder. Only components with the `.wc.svelte` extension will be exported as web components and available in your library. This means that you can also use regular Svelte components with the `.svelte` extension as child components for your implementation details.
20
118
 
21
119
  You can add additional components by adding them to the `lib` folder and editing `lib/index.js`.