Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/beyonk-group/svelte-trustpilot
Svelte / Vanilla JS Trustpilot Widget with proper SPA support
https://github.com/beyonk-group/svelte-trustpilot
beyonk ratings reviews spa svelte trustpilot vanillajs
Last synced: 2 months ago
JSON representation
Svelte / Vanilla JS Trustpilot Widget with proper SPA support
- Host: GitHub
- URL: https://github.com/beyonk-group/svelte-trustpilot
- Owner: beyonk-group
- License: mit
- Created: 2019-01-16T13:24:01.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-07-15T16:28:08.000Z (over 2 years ago)
- Last Synced: 2024-07-28T22:43:43.816Z (6 months ago)
- Topics: beyonk, ratings, reviews, spa, svelte, trustpilot, vanillajs
- Language: Svelte
- Size: 23.4 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Svelte Trustpilot
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com) [![CircleCI](https://circleci.com/gh/beyonk-adventures/svelte-trustpilot.svg?style=shield)](https://circleci.com/gh/beyonk-adventures/svelte-trustpilot) [![svelte-v2](https://img.shields.io/badge/svelte-v2-orange.svg)](https://v2.svelte.dev) [![svelte-v3](https://img.shields.io/badge/svelte-v3-blueviolet.svg)](https://svelte.dev)
Pure vanilla JS Trustpilot integration
![trustpilot](https://user-images.githubusercontent.com/218949/51251849-2ea51080-1992-11e9-8683-d46ea7aa8bf6.png)
## Install
```bash
$ npm install --save-dev @beyonk/svelte-trustpilot
```## Usage (With Svelte)
```html
import Trustpilot from '@beyonk/svelte-trustpilot'
```
The attributes you pass to the Trusilot component are listed below, but you need `domain` and `businessUnit` at a minimum.
## Usage (Vanilla JS)
```html
import Trustpilot from '@beyonk/svelte-trustpilot'
const trustpilot = new Trustpilot({
target: document.querySelector('#trustpilot-wrapper'),
data: {
businessUnit: '12345',
domain: 'www.example.com'
}
})```
## Other configuration attributes
There are a number of configuration attributes you can pass, but all are optional.
List of possible options in the module:
| Option | Default | Required | Description |
|-------------------|--------------|----------|---------------------------------------------------------------------------------------------------------------------------------------|
| widget (1) | micro-star | false | Widget type as per [https://businessapp.b2b.trustpilot.com/?locale=en-US#/integrations/trustbox/library](Trustpilot Trustbox library) |
| domain | - | true | Sets the domain/product name on Trustpilot (for the link when a user clicks your widget) |
| businessUnit | - | true | Sets `data-businessunit-id` as per docs |
| width | 100% | false | Sets `data-style-width` as per docs |
| height | 500px | false | Sets `data-style-height` as per docs |
| theme | dark | false | Sets `data-theme` as per Trustpilot docs |
| lib | package-name | false | Unique id to determine if component is loaded. You probably don't need to change this. |
| version | v5 | false | Trustpilot SDK version (best not to change) |
| * (2) | - | false | Pass any other parameter you want here. See below. |1) You can pass any widget template name in its hyphenated form, or, just pass the template id here instead. You can get the template id from the trustpilot integration url:
`https://businessapp.b2b.trustpilot.com/?locale=en-US#/integrations/trustbox/configuration/`
2) You can pass any `data-` attribute you normally pass to Trustpilot's widgets. These will be passed verbatim to the underlying widget HTML.
## License
[MIT License](./LICENSE)