@decuga/elements

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

HTML
<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

Terminal
npm install @decuga/elements
Your entry file
import '@decuga/elements'
The package touches the DOM as it loads, so it must run in the browser. In a framework that renders on the server, import it from browser-only code (the examples below show where).

Plain HTML

index.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.

Your page's script (a bundler or a module)
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 = client
The project API key must stay on your server. The page only receives the session. See the helpdesk auto-login guide for the server call, the errors and how companies work. If the session cannot be had, the element says the customer could not be signed in and does not fall back to the emailed code.

Angular

Angular renders custom elements natively. Import the package in the browser, and allow custom elements in the component.

app.component.ts
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

Support.svelte
<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

src/pages/changelog.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

src/index.tsx
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" />
For a search-engine-indexed changelog, draw it on the server with the React or Vue component, or with the JavaScript client in your own template. The web component draws its content in the browser.

Elements reference

Attributes every element accepts

AttributeValuesWhat it does
project-idstring (required)Your project id.
base-urlURLWhere Decuga is served. Default https://decuga.com.
storagesession | local | memoryWhere a signed-in visitor is remembered. Default session (gone when the tab closes).
themelight | dark | autoColour scheme. auto follows the visitor's system setting. Default light.
localelanguage tagLanguage for dates, for example en-GB. Default the visitor's browser.

<decuga-changelog>

Attribute or propertyWhat it does
page-sizeEntries per page, 1 to 50. Default 5.
infinite-scrollSet to "false" to use only the Load more button. Default: the next page loads as the visitor scrolls.
initialPageProperty. A first page you already fetched, shown with no request.

<decuga-roadmap>

AttributeWhat it does
view"board" (columns side by side, the default) or "list" (stacked).
show-headerShow the roadmap's title and description from Decuga.
suggestionsSet to "false" to hide the Suggest a feature button.

<decuga-helpdesk>

AttributeWhat it does
form-idShow one form and skip the picker.
show-headerSet to "false" to hide the portal's logo and welcome text.
ticketsSet 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.

PropertyDefaultUsed for
--decuga-color-primary#4f46e5Buttons, links, the active tab, your own votes.
--decuga-color-text#0f172aMain text.
--decuga-color-muted#64748bSecondary text.
--decuga-color-surface#ffffffCards and inputs.
--decuga-color-bgtransparentBehind the widget.
--decuga-color-border#e2e8f0Lines and borders.
--decuga-color-danger#dc2626Errors.
--decuga-color-success#059669Confirmations.
--decuga-radius12pxCorner radius.
--decuga-fontinheritsFont family.
--decuga-color-feature#047857Changelog: New features heading.
--decuga-color-improvement#1d4ed8Changelog: Improvements heading.
--decuga-color-fix#b45309Changelog: Bug fixes heading.
--decuga-color-considering#f59e0bRoadmap: Considering dot. Also -planned, -in-progress and -shipped.

CSS parts

Parts reach inside the shadow root: decuga-roadmap::part(vote) { border-radius: 999px }.

ElementParts
decuga-changelogentry, entry-title, version, date, summary, section-title, item, load-more
decuga-roadmapcolumn, column-title, item, item-title, vote, category
decuga-helpdeskheader, 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.

ElementEventDetail
decuga-changelogdecuga-loadThe page of entries that arrived.
decuga-roadmapdecuga-loadThe items.
decuga-roadmapdecuga-voteThe item, after a vote or a removed vote.
decuga-roadmapdecuga-signinThe voter (token and email).
decuga-roadmapdecuga-suggestNone. A suggestion was sent.
decuga-helpdeskdecuga-submitThe ticket that was created.
decuga-helpdeskdecuga-signinThe customer who signed in.
Anydecuga-errorA 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:

Custom client
const client = new Decuga.DecugaClient({ projectId: 'YOUR_PROJECT_ID', storage: 'local' })
document.querySelector('decuga-roadmap').client = client

Next