Here is an example of using the Add Favourites in a plain html page:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<link href="https://developer.temenos.com/uux/base.css" rel="stylesheet" />
<script src="https://developer.temenos.com/uux/unified-ux-web.min.js"></script>
</head>
<body>
<uwc-add-favourites setAddNewFavourites setAddNewFavTypeFor="QuickFilter" localStorageIndexName="QuickFilterfavourites"
id="add-favourites-1">
</uwc-add-favourites>
<br>
</br>
<form id="quick-filter-form">
<uwc-form id="quick-filter-uwc-form">
<uwc-text variant="h2">Quick Filter</uwc-text>
<uwc-combobox mode="multiple" id="uwc-combobox" options='[
"Apple",
"Artichoke",
"Asparagus",
"Banana",
"Beets",
"Cherry",
"Mango",
"Orange"]'
filterOperator="contains" label="uwc-combobox" name="uwc-combobox"></uwc-combobox>
<uwc-select label="My Favourite Fruit" id="uwc-select" name="uwc-select"
innerAriaLabel="Favourite Fruit options">
<uwc-list-item></uwc-list-item>
<uwc-list-item value="0">Apple</uwc-list-item>
<uwc-list-item value="1">Banana</uwc-list-item>
<uwc-list-item value="2">Cherry</uwc-list-item>
<uwc-list-item value="3">Melon</uwc-list-item>
</uwc-select>
</uwc-form>
</form>
<script>
const addFavourites = document.querySelector("#add-favourites-1");
addFavourites.addEventListener("handleCustomAddNewFavClick",() => { handledQuickfilter() });
addFavourites.addEventListener("getFavourites", (e) => { console.log(e) });
function handledQuickfilter() {
const form = document.querySelector("#quick-filter-form");
if (form) {
// Check form validity
const formData = new FormData(form);
const filterQueryParamsObject = {};
formData.forEach((value, key) => {
if (filterQueryParamsObject[key]) {
if (Array.isArray(filterQueryParamsObject[key])) {
filterQueryParamsObject[key].push(value);
} else {
filterQueryParamsObject[key] = [filterQueryParamsObject[key], value];
}
} else {
filterQueryParamsObject[key] = value;
}
});
const newFavourite =
{
"filterQuery": `combobox:eq=${filterQueryParamsObject['uwc-combobox']}&select:eq=${filterQueryParamsObject['uwc-select']}`,
"filterType": "QuickFilter",
"filterData": filterQueryParamsObject
};
addFavourites.filterQueryParams = newFavourite;
addFavourites.requestUpdate();
}
}
</script>
</body>
</html>