@sesamy/sesamy-components 2.21.5 → 2.21.7

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,9 +1,26 @@
1
1
  # 🌐 sesamy-components
2
2
 
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).
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
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
+ ## Table of Contents
8
+
9
+ - [Installation](#installation)
10
+ - [Components](#components)
11
+ - [sesamy-login](#sesamy-login)
12
+ - [sesamy-content-container](#sesamy-content-container)
13
+ - [sesamy-paywall](#sesamy-paywall)
14
+ - [sesamy-visibility](#sesamy-visibility)
15
+ - [sesamy-avatar](#sesamy-avatar)
16
+ - [sesamy-button](#sesamy-button)
17
+ - [sesamy-login-menu-item](#sesamy-login-menu-item)
18
+ - [Internationalization](#internationalization)
19
+ - [Development](#development)
20
+ - [Testing](#testing-your-components)
21
+ - [Building](#building-the-library)
22
+ - [Create a New Component](#create-a-new-component)
23
+
7
24
  ## Installation
8
25
 
9
26
  You can install the package with:
@@ -14,6 +31,16 @@ npm install @sesamy/sesamy-components
14
31
  yarn add @sesamy/sesamy-components
15
32
  ```
16
33
 
34
+ ### CDN Usage
35
+
36
+ You can also use the components directly via CDN:
37
+
38
+ ```html
39
+ <script type="module" src="https://unpkg.com/@sesamy/sesamy-components"></script>
40
+ ```
41
+
42
+ ## Components
43
+
17
44
  # sesamy-login
18
45
 
19
46
  A web component that provides authentication functionality, displaying a login button for unauthenticated users and an avatar with a dropdown menu for authenticated users.
@@ -203,9 +230,7 @@ A web component that displays a paywall for content, loading paywall settings fr
203
230
  price="99"
204
231
  currency="USD"
205
232
  >
206
- <<<<<<< HEAD =======
207
233
  <div slot="features">✔️ Unlimited access<br />✔️ Cancel anytime</div>
208
- >>>>>>> main
209
234
  </sesamy-paywall>
210
235
 
211
236
  <!-- Login paywall with below-headline slot -->
@@ -263,31 +288,167 @@ A simple web component that conditionally renders content based on user authenti
263
288
  </sesamy-visibility>
264
289
  ```
265
290
 
291
+ # sesamy-avatar
292
+
293
+ A web component that displays a user avatar image with configurable size and loading state.
294
+
295
+ **Props/Attributes:**
296
+
297
+ - `src`: URL of the avatar image
298
+ - `alt`: Alt text for the image
299
+ - `size`: Size of the avatar ('sm', 'md', or 'lg')
300
+ - `loading`: Boolean to show loading state
301
+
302
+ **Basic Usage Example:**
303
+
304
+ ```html
305
+ <!-- Default avatar -->
306
+ <sesamy-avatar src="https://example.com/user.jpg" alt="User avatar"></sesamy-avatar>
307
+
308
+ <!-- Large avatar with loading state -->
309
+ <sesamy-avatar src="https://example.com/user.jpg" size="lg" loading></sesamy-avatar>
310
+ ```
311
+
312
+ # sesamy-button
313
+
314
+ A customizable button web component with multiple variants and sizes.
315
+
316
+ **Props/Attributes:**
317
+
318
+ - `variant`: Button style variant ('primary', 'secondary', or 'tertiary')
319
+ - `size`: Button size ('sm', 'md', or 'lg')
320
+ - `loading`: Boolean to show loading spinner
321
+ - `disabled`: Boolean to disable the button
322
+ - `href`: URL if the button should act as a link
323
+ - `type`: Button type ('button', 'submit', etc.)
324
+ - `class`: Additional CSS classes
325
+
326
+ **Basic Usage Example:**
327
+
328
+ ```html
329
+ <!-- Primary button -->
330
+ <sesamy-button variant="primary">Subscribe</sesamy-button>
331
+
332
+ <!-- Secondary button with loading state -->
333
+ <sesamy-button variant="secondary" loading>Processing...</sesamy-button>
334
+
335
+ <!-- Button as a link -->
336
+ <sesamy-button href="/checkout" variant="primary">Go to Checkout</sesamy-button>
337
+ ```
338
+
339
+ # sesamy-login-menu-item
340
+
341
+ A web component for individual menu items in the login dropdown menu. Can be used to customize the logged-in user menu.
342
+
343
+ **Props/Attributes:**
344
+
345
+ - `type`: Type of menu item ('EMAIL', 'ACCOUNT', 'LOGOUT', or 'LINK')
346
+ - `href`: URL for link type items
347
+ - `target`: Link target attribute (e.g., '\_blank')
348
+ - `text`: Custom text for the menu item
349
+
350
+ **Basic Usage Example:**
351
+
352
+ ```html
353
+ <!-- Account link -->
354
+ <sesamy-login-menu-item type="ACCOUNT"></sesamy-login-menu-item>
355
+
356
+ <!-- Custom link -->
357
+ <sesamy-login-menu-item
358
+ type="LINK"
359
+ href="https://example.com/settings"
360
+ text="Settings"
361
+ ></sesamy-login-menu-item>
362
+
363
+ <!-- Logout button -->
364
+ <sesamy-login-menu-item type="LOGOUT"></sesamy-login-menu-item>
365
+ ```
366
+
367
+ ## Internationalization
368
+
369
+ The components support multiple languages out of the box. Supported languages:
370
+
371
+ - 🇬🇧 English (en)
372
+ - 🇸🇪 Swedish (sv)
373
+ - 🇳🇴 Norwegian Bokmål (nb)
374
+ - 🇩🇰 Danish (da)
375
+ - 🇫🇮 Finnish (fi)
376
+ - 🇮🇹 Italian (it)
377
+ - 🇵🇱 Polish (pl)
378
+ - 🇨🇿 Czech (cs)
379
+
380
+ Set the language using the `lang` attribute on supported components:
381
+
382
+ ```html
383
+ <sesamy-login lang="sv"></sesamy-login>
384
+ ```
385
+
266
386
  ## Development
267
387
 
268
- 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.
388
+ Your components source code lives in `packages/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.
389
+
390
+ You can add additional components by adding them to the `packages/lib/src` folder and editing `packages/lib/index.ts`.
269
391
 
270
- You can add additional components by adding them to the `lib` folder and editing `lib/index.js`.
392
+ ### Available Scripts
393
+
394
+ | Command | Description |
395
+ | ---------------------- | -------------------------------------------------- |
396
+ | `yarn dev` | Start the development server |
397
+ | `yarn build` | Build both library and demo |
398
+ | `yarn build:lib` | Build the library only |
399
+ | `yarn storybook` | Start Storybook for component development |
400
+ | `yarn build:storybook` | Build Storybook for deployment |
401
+ | `yarn test` | Run Playwright tests |
402
+ | `yarn check` | Run Svelte type checking |
403
+ | `yarn pull-translations` | Pull latest translations from i18nexus |
271
404
 
272
405
  ## Testing your components
273
406
 
274
407
  You can start a development server with:
275
408
 
276
409
  ```bash
277
- npm start
410
+ yarn dev
278
411
  ```
279
412
 
280
413
  Then open your browser to [localhost:5173](http://localhost:5173).
281
414
 
282
- This will build the demo application located in the `demo/` folder, in which you can use and test your web components during development.
415
+ This will build the demo application located in the `packages/demo/` folder, in which you can use and test your web components during development.
416
+
417
+ ### Storybook
283
418
 
284
- If you need unit tests, you can take a look at [Jest](https://jestjs.io) and [Jest testing library](https://github.com/testing-library/svelte-testing-library).
419
+ For component development and visual testing, use Storybook:
420
+
421
+ ```bash
422
+ yarn storybook
423
+ ```
424
+
425
+ Then open your browser to [localhost:6006](http://localhost:6006).
426
+
427
+ ### End-to-End Tests
428
+
429
+ Run Playwright tests with:
430
+
431
+ ```bash
432
+ yarn test
433
+ ```
434
+
435
+ For running E2E tests in Docker (ensuring consistent snapshots):
436
+
437
+ ```bash
438
+ yarn e2e
439
+ ```
440
+
441
+ To update snapshots:
442
+
443
+ ```bash
444
+ yarn e2e:snapshots
445
+ ```
285
446
 
286
447
  ### Using the built web components with the demo app
287
448
 
288
- The demo application is provided for development and testing of your components, that's why it imports the `.svelte` files from the `lib/` folder directly by default.
449
+ The demo application is provided for development and testing of your components, that's why it imports the `.svelte` files from the `packages/lib/` folder directly by default.
289
450
 
290
- If you prefer, you can import the built web components from the `dist/` folder instead, by editing `demo/src/App.svelte` and replacing the `import '../../lib';` statement with `import '../../../dist/lib';` if you have the `bundleComponents` option enabled, or individually import your components with `import import '../../dist/MyComponent.wc.js';` otherwise.
451
+ If you prefer, you can import the built web components from the `dist/` folder instead, by editing `packages/demo/src/App.svelte` and replacing the import statement with `import '../../../dist/lib';` if you have the `bundleComponents` option enabled.
291
452
 
292
453
  You'll also have to make sure to run the `yarn build` script to generate the `dist/lib/` folder first.
293
454
 
@@ -337,7 +498,11 @@ Here's an example:
337
498
 
338
499
  These are the files needed to create a new component:
339
500
 
340
- - Add the `my-component.wc.svelte` file in the `lib/src` folder.
341
- - Add the class in the `lib/src/sesamy-component.d.ts` file to get the types exported.
342
- - Add the component to the `lib/src/index.ts` file to export it.
343
- - Add a story in the `stories` folder.
501
+ 1. Add the `my-component.wc.svelte` file in the `packages/lib/src` folder.
502
+ 2. Add the class in the `packages/lib/src/sesamy-components.d.ts` file to get the types exported.
503
+ 3. Add the component to the `packages/lib/index.ts` file to export it.
504
+ 4. Add a story in the `packages/lib/src/stories` folder.
505
+
506
+ ## License
507
+
508
+ This project is proprietary software by Sesamy.