Decuga as web components
<decuga-changelog>, <decuga-roadmap> and <decuga-helpdesk> are standard custom elements. They work on a plain HTML page, and in Angular, Svelte, Solid, Astro or any framework that renders HTML. Each is complete (loading and error states, sign-in, forms) and styles itself inside a shadow root, so your CSS cannot break it and it cannot leak into yours.
They need a browser with custom elements and shadow DOM, which current Chrome, Edge, Firefox and Safari have. The package is in beta; see the SDKs overview for what you need first.
Install
From a CDN
<script src="https://cdn.jsdelivr.net/npm/@decuga/[email protected]"></script>The script registers the three elements and exposes a global called Decuga. Pin the version, as above, in production.
From npm
npm install @decuga/elementsimport '@decuga/elements'Plain HTML
<script src="https://cdn.jsdelivr.net/npm/@decuga/[email protected]"></script>
<decuga-changelog project-id="YOUR_PROJECT_ID" page-size="5" locale="en-GB"></decuga-changelog>
<decuga-roadmap project-id="YOUR_PROJECT_ID" show-header></decuga-roadmap>
<decuga-helpdesk project-id="YOUR_PROJECT_ID"></decuga-helpdesk>
<script>
document.querySelector('decuga-roadmap').addEventListener('decuga-vote', e => {
console.log('voted for', e.detail.title)
})
</script>Several elements on one page share a client for the same project, so they share one storage and one set of settings. Signing in is separate for each kind: someone who verified their email to vote is not also signed in to the helpdesk.
Helpdesk for customers signed in to your app
By default <decuga-helpdesk> asks the customer for their email and an emailed code before it shows their requests. If your app already signs them in, give the element a client that has a session from your server, and it opens on their requests with no sign-in step and no sign-out button.
import { DecugaClient } from '@decuga/client'
import '@decuga/elements'
const client = new DecugaClient({
projectId: 'YOUR_PROJECT_ID',
// Your own server route, which asks Decuga for the session with a project API key kept on the server
session: () => fetch('/decuga-session', { method: 'POST', credentials: 'include' }).then(r => r.json()),
})
document.querySelector('decuga-helpdesk').client = clientAngular
Angular renders custom elements natively. Import the package in the browser, and allow custom elements in the component.
import { Component, CUSTOM_ELEMENTS_SCHEMA, Inject, OnInit, PLATFORM_ID } from '@angular/core'
import { isPlatformBrowser } from '@angular/common'
@Component({
selector: 'app-support',
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: `
<decuga-roadmap project-id="YOUR_PROJECT_ID" show-header (decuga-vote)="onVote($event)"></decuga-roadmap>
<decuga-helpdesk project-id="YOUR_PROJECT_ID"></decuga-helpdesk>
`,
})
export class SupportComponent implements OnInit {
constructor(@Inject(PLATFORM_ID) private platform: object) {}
ngOnInit() {
// Browser only: the package touches the DOM as it loads (this matters with server rendering)
if (isPlatformBrowser(this.platform)) void import('@decuga/elements')
}
onVote(event: Event) {
console.log((event as CustomEvent).detail)
}
}Pass an object (a client you made, or a first page of the changelog) with a property binding, such as [client]="decugaClient". There is no separate Angular package yet. If you want one, tell us.
Svelte and SvelteKit
<script>
import { onMount } from 'svelte'
let roadmap
onMount(async () => {
await import('@decuga/elements') // browser only, so SvelteKit's server render is unaffected
roadmap.addEventListener('decuga-vote', e => console.log(e.detail))
})
</script>
<decuga-changelog project-id="YOUR_PROJECT_ID" page-size="5"></decuga-changelog>
<decuga-roadmap bind:this={roadmap} project-id="YOUR_PROJECT_ID" show-header></decuga-roadmap>Astro and Solid
Astro
<decuga-changelog project-id="YOUR_PROJECT_ID"></decuga-changelog>
<script>
import '@decuga/elements'
</script>Astro bundles a plain <script> for the browser, so the import runs there only.
Solid
import '@decuga/elements' // in your client entry
// A one-time type declaration so JSX accepts the tags:
declare module 'solid-js' {
namespace JSX {
interface IntrinsicElements {
'decuga-changelog': any
'decuga-roadmap': any
'decuga-helpdesk': any
}
}
}
// <decuga-roadmap project-id="YOUR_PROJECT_ID" />Elements reference
Attributes every element accepts
| Attribute | Values | What it does |
|---|---|---|
project-id | string (required) | Your project id. |
base-url | URL | Where Decuga is served. Default https://decuga.com. |
storage | session | local | memory | Where a signed-in visitor is remembered. Default session (gone when the tab closes). |
theme | light | dark | auto | Colour scheme. auto follows the visitor's system setting. Default light. |
locale | language tag | Language for dates, for example en-GB. Default the visitor's browser. |
<decuga-changelog>
| Attribute or property | What it does |
|---|---|
page-size | Entries per page, 1 to 50. Default 5. |
infinite-scroll | Set to "false" to use only the Load more button. Default: the next page loads as the visitor scrolls. |
initialPage | Property. A first page you already fetched, shown with no request. |
<decuga-roadmap>
| Attribute | What it does |
|---|---|
view | "board" (columns side by side, the default) or "list" (stacked). |
show-header | Show the roadmap's title and description from Decuga. |
suggestions | Set to "false" to hide the Suggest a feature button. |
<decuga-helpdesk>
| Attribute | What it does |
|---|---|
form-id | Show one form and skip the picker. |
show-header | Set to "false" to hide the portal's logo and welcome text. |
tickets | Set to "false" to hide the My requests tab and show only the form. |
Theming
Custom properties
Set these on the element or on any parent (even :root). Anything you leave out keeps its default.
| Property | Default | Used for |
|---|---|---|
--decuga-color-primary | #4f46e5 | Buttons, links, the active tab, your own votes. |
--decuga-color-text | #0f172a | Main text. |
--decuga-color-muted | #64748b | Secondary text. |
--decuga-color-surface | #ffffff | Cards and inputs. |
--decuga-color-bg | transparent | Behind the widget. |
--decuga-color-border | #e2e8f0 | Lines and borders. |
--decuga-color-danger | #dc2626 | Errors. |
--decuga-color-success | #059669 | Confirmations. |
--decuga-radius | 12px | Corner radius. |
--decuga-font | inherits | Font family. |
--decuga-color-feature | #047857 | Changelog: New features heading. |
--decuga-color-improvement | #1d4ed8 | Changelog: Improvements heading. |
--decuga-color-fix | #b45309 | Changelog: Bug fixes heading. |
--decuga-color-considering | #f59e0b | Roadmap: Considering dot. Also -planned, -in-progress and -shipped. |
CSS parts
Parts reach inside the shadow root: decuga-roadmap::part(vote) { border-radius: 999px }.
| Element | Parts |
|---|---|
decuga-changelog | entry, entry-title, version, date, summary, section-title, item, load-more |
decuga-roadmap | column, column-title, item, item-title, vote, category |
decuga-helpdesk | header, form, submit, ticket, status, reply |
Events and properties
Events bubble and cross the shadow boundary, so you can listen on the element or on any parent. The payload is in event.detail.
| Element | Event | Detail |
|---|---|---|
decuga-changelog | decuga-load | The page of entries that arrived. |
decuga-roadmap | decuga-load | The items. |
decuga-roadmap | decuga-vote | The item, after a vote or a removed vote. |
decuga-roadmap | decuga-signin | The voter (token and email). |
decuga-roadmap | decuga-suggest | None. A suggestion was sent. |
decuga-helpdesk | decuga-submit | The ticket that was created. |
decuga-helpdesk | decuga-signin | The customer who signed in. |
| Any | decuga-error | A message about what could not be loaded. |
Elements also have a client property. Assign a DecugaClient (exported on the Decuga global and from the package) to use your own settings, such as a custom fetch:
const client = new Decuga.DecugaClient({ projectId: 'YOUR_PROJECT_ID', storage: 'local' })
document.querySelector('decuga-roadmap').client = client