Skip to main content

Load More Ready

This template shows how to build a simple load more pattern that utilizes Button component’s loading state. Please note that the example below does not represent a real use case.

Hint: Press F on your keyboard to view both templates and components in fullscreen and ESC to exit the fullscreen mode. You can also open the template in a new browser window.


Open in new window
<!DOCTYPE html>
<html class="duet-bg-gradient duet-sticky-footer" lang="fi">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<title>LähiTapiola</title>
<link rel="stylesheet" href="https://cdn.duetds.com/api/fonts/3.0.51/lib/localtapiola.css" integrity="sha384-5JYmtSD7nykpUvSmTW1CHMoBDkBZUpUmG0vuh+NUVtZag3F75Kr7+/JU3J7JV6Wq" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdn.duetds.com/api/css/4.0.45/lib/duet.min.css" integrity="sha384-UoMJnpXiN8f7fKVnTzfKfyi7LzQlApQ+WTS9O3PXlYr6CO9yzou4glfsHV747f3v" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdn.duetds.com/api/tokens/4.0.59/lib/tokens.custom-properties.css" integrity="sha384-AexjbYNj18dJLZR54wNVU44b/akdDc+tpbLIWhAnzjMAbwFSli2DHpSP+7NCK+Xw" crossorigin="anonymous" />
<script type="module" src="https://cdn.duetds.com/api/components/8.7.1/lib/duet/duet.esm.js" integrity="sha384-c3hLghWHTPntUxndMlK4myD7d59stA2U0EvBp2rPb3ibtacAwh56geBpq6z7nXLn" crossorigin="anonymous"></script>
<script nomodule src="https://cdn.duetds.com/api/components/8.7.1/lib/duet/duet.js" integrity="sha384-H7RH4Ssj/LmElXa1VCHFSIjvtCSoLXMiPXG/KQZTS9EvYujTo7tWaj0V6/GGkY16" crossorigin="anonymous"></script>
</head>
<body>
<style>
.load {
transition: 500ms 100ms ease;
opacity: 0;
visibility: hidden;
}
.load.active {
opacity: 1;
visibility: visible;
}
</style>
<duet-header
language="fi"
skip-to-id="#content"
contact="Ota yhteyttä"
current-href="/vakuutukset/"
items='[
{ "label": "Etusivu","href": "/" },
{ "label": "Vakuutukset", "href": "/vakuutukset/" },
{ "label": "Vahinkoasiat", "href": "#" },
{ "label": "Säästöt ja sijoitukset", "href": "#" },
{ "label": "Laskut", "href": "#", "badge": "true" },
{ "label": "Viestit", "href": "#" }
]'

language-items='[
{ "label": "Suomeksi", "country": "fi", "href": "/?lang=fi" },
{ "label": "På Svenska", "country": "sv", "href": "/?lang=sv" },
{ "label": "In English", "country": "en", "href": "/?lang=en" }
]'

contact-items='[
{ "label": "Lähetä viesti", "href": "/viestit/laheta" },
{ "label": "Avaa chat", "href": "/chat/" },
{ "label": "Yhteystiedot", "href": "/yhteystiedot/" }
]'

session='{ "label": "Kirjaudu ulos", "href": "/?logout", "type": "logout" }'
user='{ "label": "Elina", "href": "/?userId=elina" }'>

</duet-header>
<duet-layout header-distance="with-links" id="content">
<div slot="main">
<duet-visually-hidden>
<duet-heading level="h1">Vakuutukset</duet-heading>
</duet-visually-hidden>
<duet-grid alignment="center" direction="vertical">
<duet-grid-item max-width="920px" fill>
<duet-card accessible-label="Pariturva-henkivakuutus, Laura-Karoliina Mäkinen" url="#" padding="large">
<duet-grid responsive distribution="space-between" alignment="top">
<duet-grid alignment="center" responsive breakpoint="medium">
<duet-grid-item fill>
<duet-heading level="h2" visual-level="h3">Pariturva-henkivakuutus</duet-heading>
<duet-spacer size="xx-small"></duet-spacer>
<duet-list padding="none" margin="none">
<duet-list-item>
<span slot="label">Hakemuksen luoja</span>
<span slot="value">Laura-Karoliina Mäkinen</span>
</duet-list-item>
<duet-list-item>
<span slot="label">Vakuutusmäärä</span>
<span slot="value">55&nbsp;000,00&nbsp;</span>
</duet-list-item>
<duet-list-item>
<span slot="label">Hinta</span>
<span slot="value">480,77&nbsp;€ / vuosi</span>
</duet-list-item>
<duet-list-item>
<span slot="label">Hakemus luotu</span>
<span slot="value">20.02.2020</span>
</duet-list-item>
</duet-list>
</duet-grid-item>
<duet-grid-item margin="none">
<duet-grid mobile="center">
<duet-spacer breakpoint="medium" direction="horizontal" size="xxxx-large">
</duet-spacer>
<duet-button tabindex="-1" wrapping="none" margin="none" variation="primary">
Valitse
</duet-button>
</duet-grid>
<duet-spacer breakpoint="x-small" direction="vertical" size="large"></duet-spacer>
</duet-grid-item>
</duet-grid>
</duet-grid>
</duet-card>
<duet-card accessible-label="Pariturva-henkivakuutus, Minna Mikkola" url="#" padding="large">
<duet-grid responsive distribution="space-between" alignment="top">
<duet-grid alignment="center" responsive breakpoint="medium">
<duet-grid-item fill>
<duet-heading level="h2" visual-level="h3">Pariturva-henkivakuutus</duet-heading>
<duet-spacer size="xx-small"></duet-spacer>
<duet-list padding="none" margin="none">
<duet-list-item>
<span slot="label">Hakemuksen luoja</span>
<span slot="value">Minna Mikkola</span>
</duet-list-item>
<duet-list-item>
<span slot="label">Vakuutusmäärä</span>
<span slot="value">80&nbsp;000,00&nbsp;</span>
</duet-list-item>
<duet-list-item>
<span slot="label">Hinta</span>
<span slot="value">620,80&nbsp;€ / vuosi</span>
</duet-list-item>
<duet-list-item>
<span slot="label">Hakemus luotu</span>
<span slot="value">01.05.2019</span>
</duet-list-item>
</duet-list>
</duet-grid-item>
<duet-grid-item margin="none">
<duet-grid mobile="center">
<duet-spacer breakpoint="medium" direction="horizontal" size="xxxx-large">
</duet-spacer>
<duet-button tabindex="-1" wrapping="none" margin="none" variation="primary">
Valitse
</duet-button>
</duet-grid>
<duet-spacer breakpoint="x-small" direction="vertical" size="large"></duet-spacer>
</duet-grid-item>
</duet-grid>
</duet-grid>
</duet-card>
<duet-card accessible-label="Pariturva-henkivakuutus, Hanna Koskinen" url="#" padding="large">
<duet-grid responsive distribution="space-between" alignment="top">
<duet-grid alignment="center" responsive breakpoint="medium">
<duet-grid-item fill>
<duet-heading level="h2" visual-level="h3">Pariturva-henkivakuutus</duet-heading>
<duet-spacer size="xx-small"></duet-spacer>
<duet-list padding="none" margin="none">
<duet-list-item>
<span slot="label">Hakemuksen luoja</span>
<span slot="value">Hanna Koskinen</span>
</duet-list-item>
<duet-list-item>
<span slot="label">Vakuutusmäärä</span>
<span slot="value">48&nbsp;000,00&nbsp;</span>
</duet-list-item>
<duet-list-item>
<span slot="label">Hinta</span>
<span slot="value">426,30&nbsp;€ / vuosi</span>
</duet-list-item>
<duet-list-item>
<span slot="label">Hakemus luotu</span>
<span slot="value">22.01.2019</span>
</duet-list-item>
</duet-list>
</duet-grid-item>
<duet-grid-item margin="none">
<duet-grid mobile="center">
<duet-spacer breakpoint="medium" direction="horizontal" size="xxxx-large">
</duet-spacer>
<duet-button tabindex="-1" wrapping="none" margin="none" variation="primary">
Valitse
</duet-button>
</duet-grid>
<duet-spacer breakpoint="x-small" direction="vertical" size="large"></duet-spacer>
</duet-grid-item>
</duet-grid>
</duet-grid>
</duet-card>
<duet-card accessible-label="Pariturva-henkivakuutus, Anna Grönlund" url="#" padding="large">
<duet-grid responsive distribution="space-between" alignment="top">
<duet-grid alignment="center" responsive breakpoint="medium">
<duet-grid-item fill>
<duet-heading level="h2" visual-level="h3">Pariturva-henkivakuutus</duet-heading>
<duet-spacer size="xx-small"></duet-spacer>
<duet-list padding="none" margin="none">
<duet-list-item>
<span slot="label">Hakemuksen luoja</span>
<span slot="value">Anna Grönlund</span>
</duet-list-item>
<duet-list-item>
<span slot="label">Vakuutusmäärä</span>
<span slot="value">90&nbsp;000,00&nbsp;</span>
</duet-list-item>
<duet-list-item>
<span slot="label">Hinta</span>
<span slot="value">822,40&nbsp;€ / vuosi</span>
</duet-list-item>
<duet-list-item>
<span slot="label">Hakemus luotu</span>
<span slot="value">06.02.2018</span>
</duet-list-item>
</duet-list>
</duet-grid-item>
<duet-grid-item margin="none">
<duet-grid mobile="center">
<duet-spacer breakpoint="medium" direction="horizontal" size="xxxx-large">
</duet-spacer>
<duet-button tabindex="-1" wrapping="none" margin="none" variation="primary">
Valitse
</duet-button>
</duet-grid>
<duet-spacer breakpoint="x-small" direction="vertical" size="large"></duet-spacer>
</duet-grid-item>
</duet-grid>
</duet-grid>
</duet-card>
<div class="load"></div>
</duet-grid-item>
<duet-spacer direction="vertical"></duet-spacer>
<duet-grid alignment="center" distribution="center">
<duet-button class="button" variation="secondary">Lataa lisää</duet-button>
</duet-grid>
</duet-grid>
</div>
</duet-layout>
<duet-footer
logo-href="#"
language="fi"
items='[
{ "label": "Hae korvausta", "href": "#", "icon": "navigation-make-claim" },
{ "label": "Osta vakuutus", "href": "#", "icon": "action-buy-insurance" },
{ "label": "Yhteystiedot", "href": "#", "icon": "form-tel" }
]'

menu='[
{ "label": "Turvallisuus ja käyttöehdot", "href": "#" },
{ "label": "Evästeet", "href": "#" },
{ "label": "Henkilötietojen käsittely", "href": "#" }
]'
>

</duet-footer>
<duet-visually-hidden>
<span aria-live="assertive"></span>
</duet-visually-hidden>
<script>
// Save references to components we want to adjust below
var button = document.querySelector(".button")
var load = document.querySelector(".load")
var aria = document.querySelector("duet-visually-hidden span")

// When using campaign code, change UI state
button.addEventListener("click", function (e) {
e.preventDefault()
var fragment = document.createDocumentFragment()
var cards = document.querySelectorAll("duet-card")

cards.forEach(function (card, i) {
var clone = card.cloneNode(true)
if (i === 0) {
clone.classList.add("first")
}
fragment.appendChild(clone)
})

button.loading = true
aria.innerHTML = "Ladataan."

setTimeout(function () {
button.parentNode.removeChild(button)
load.appendChild(fragment)
load.classList.add("active")

// Timeout to wait for the element to be visible first
setTimeout(function () {
document.querySelector(".first").setFocus()
aria.innerHTML = "Sivulle ladattiin lisää vakuutuksia."
}, 300)
}, 1000)
})
</script>
</body>
</html>

Integration

To install this template’s dependencies into your project, run:

npm install @duetds/components
npm install @duetds/css
npm install @duetds/fonts

For further guidelines, please see each package’s documentation.



Tutorials

Follow these practical tutorials to learn how to build simple page layouts using Duet’s CSS Framework, Web Components and other features:

Tutorials

Building Layouts

Tutorials

Using CLI Tools

Tutorials

Creating Custom Patterns

Tutorials

Server Side Rendering

Tutorials

Sharing Prototypes

Tutorials

Usage With Markdown


Troubleshooting

If you experience any issues while using a template, please head over to the Support page for more guidelines and help.