acinguiux-preact-components 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +56 -0
- package/src/content/themes/theme-acinguiux-amg/theme-acinguiux-amg.css +23 -0
- package/src/content/themes/theme-acinguiux-cafe/theme-acinguiux-cafe.css +47 -0
- package/src/content/themes/theme-acinguiux-energy/theme-acinguiux-energy.css +45 -0
- package/src/content/themes/theme-acinguiux-livewire/theme-acinguiux-livewire.css +22 -0
- package/src/content/themes/theme-acinguiux-livewire-italy/theme-acinguiux-livewire-italy.css +22 -0
- package/src/content/themes/theme-acinguiux-recharge/theme-acinguiux-recharge.css +49 -0
- package/src/content/themes/theme-allon/theme-allon.css +25 -0
- package/src/content/themes/theme-atlas/theme-atlas.css +31 -0
- package/src/content/themes/theme-aurvana/resources/favicon/apple-touch-icon.png +0 -0
- package/src/content/themes/theme-aurvana/resources/favicon/favico.ico +0 -0
- package/src/content/themes/theme-aurvana/resources/favicon/favicon-96x96.png +0 -0
- package/src/content/themes/theme-aurvana/resources/favicon/favicon.ico +0 -0
- package/src/content/themes/theme-aurvana/resources/favicon/favicon.png +0 -0
- package/src/content/themes/theme-aurvana/resources/favicon/favicon.svg +13 -0
- package/src/content/themes/theme-aurvana/resources/favicon/google-touch-icon.png +0 -0
- package/src/content/themes/theme-aurvana/resources/favicon/manifest.json +14 -0
- package/src/content/themes/theme-aurvana/resources/favicon/site.webmanifest +21 -0
- package/src/content/themes/theme-aurvana/resources/favicon/web-app-manifest-192x192.png +0 -0
- package/src/content/themes/theme-aurvana/resources/favicon/web-app-manifest-512x512.png +0 -0
- package/src/content/themes/theme-aurvana/theme-aurvana.css +49 -0
- package/src/content/themes/theme-base/theme-base.css +49 -0
- package/src/content/themes/theme-base2/resources/favicon/android-chrome-192x192.png +0 -0
- package/src/content/themes/theme-base2/resources/favicon/android-chrome-512x512.png +0 -0
- package/src/content/themes/theme-base2/resources/favicon/apple-touch-icon.png +0 -0
- package/src/content/themes/theme-base2/resources/favicon/favico.ico +0 -0
- package/src/content/themes/theme-base2/resources/favicon/favicon-16x16.png +0 -0
- package/src/content/themes/theme-base2/resources/favicon/favicon-32x32.png +0 -0
- package/src/content/themes/theme-base2/resources/favicon/favicon-96x96.png +0 -0
- package/src/content/themes/theme-base2/resources/favicon/favicon.ico +0 -0
- package/src/content/themes/theme-base2/resources/favicon/favicon.png +0 -0
- package/src/content/themes/theme-base2/resources/favicon/favicon.svg +9 -0
- package/src/content/themes/theme-base2/resources/favicon/google-touch-icon.png +0 -0
- package/src/content/themes/theme-base2/resources/favicon/manifest.json +14 -0
- package/src/content/themes/theme-base2/resources/favicon/site.webmanifest +1 -0
- package/src/content/themes/theme-base2/resources/favicon/web-app-manifest-192x192.png +0 -0
- package/src/content/themes/theme-base2/resources/favicon/web-app-manifest-512x512.png +0 -0
- package/src/content/themes/theme-base2/resources/fonts/acinguiux-typeface-la-heavy-221208.woff2 +0 -0
- package/src/content/themes/theme-base2/theme-base2.css +47 -0
- package/src/content/themes/theme-eco-marathon/theme-eco-marathon.css +22 -0
- package/src/content/themes/theme-energy-transition-campus-amsterdam/theme-energy-transition-campus-amsterdam.css +26 -0
- package/src/content/themes/theme-evpass/theme-evpass.css +46 -0
- package/src/content/themes/theme-nam-2025/resources/favicon/apple-touch-icon.png +0 -0
- package/src/content/themes/theme-nam-2025/resources/favicon/favico.ico +0 -0
- package/src/content/themes/theme-nam-2025/resources/favicon/favicon-96x96.png +0 -0
- package/src/content/themes/theme-nam-2025/resources/favicon/favicon.ico +0 -0
- package/src/content/themes/theme-nam-2025/resources/favicon/favicon.png +0 -0
- package/src/content/themes/theme-nam-2025/resources/favicon/favicon.svg +9 -0
- package/src/content/themes/theme-nam-2025/resources/favicon/google-touch-icon.png +0 -0
- package/src/content/themes/theme-nam-2025/resources/favicon/manifest.json +14 -0
- package/src/content/themes/theme-nam-2025/resources/favicon/site.webmanifest +21 -0
- package/src/content/themes/theme-nam-2025/resources/favicon/web-app-manifest-192x192.png +0 -0
- package/src/content/themes/theme-nam-2025/resources/favicon/web-app-manifest-512x512.png +0 -0
- package/src/content/themes/theme-nam-2025/theme-nam-2025.css +47 -0
- package/src/content/themes/theme-pennzoil/theme-pennzoil.css +36 -0
- package/src/content/themes/theme-quaker-state/theme-quaker-state.css +63 -0
- package/src/content/themes/theme-tafawoq/theme-tafawoq.css +26 -0
- package/src/content/themes/theme-vegetable/resources/favicon/apple-touch-icon.png +0 -0
- package/src/content/themes/theme-vegetable/resources/favicon/favico.ico +0 -0
- package/src/content/themes/theme-vegetable/resources/favicon/favicon-96x96.png +0 -0
- package/src/content/themes/theme-vegetable/resources/favicon/favicon.ico +0 -0
- package/src/content/themes/theme-vegetable/resources/favicon/favicon.png +0 -0
- package/src/content/themes/theme-vegetable/resources/favicon/favicon.svg +13 -0
- package/src/content/themes/theme-vegetable/resources/favicon/google-touch-icon.png +0 -0
- package/src/content/themes/theme-vegetable/resources/favicon/manifest.json +14 -0
- package/src/content/themes/theme-vegetable/resources/favicon/site.webmanifest +21 -0
- package/src/content/themes/theme-vegetable/resources/favicon/web-app-manifest-192x192.png +0 -0
- package/src/content/themes/theme-vegetable/resources/favicon/web-app-manifest-512x512.png +0 -0
- package/src/content/themes/theme-vegetable/theme-vegetable.css +49 -0
- package/src/content/themes/theme-zeolyst/resources/fonts/type-ar-medium.woff2 +0 -0
- package/src/content/themes/theme-zeolyst/theme-zeolyst.css +29 -0
- package/src/main/atoms/audio.js +16 -0
- package/src/main/atoms/box.js +5 -0
- package/src/main/atoms/button.js +40 -0
- package/src/main/atoms/card.js +22 -0
- package/src/main/atoms/form.js +30 -0
- package/src/main/atoms/heading.js +17 -0
- package/src/main/atoms/icon.js +24 -0
- package/src/main/atoms/img.js +131 -0
- package/src/main/atoms/input.js +55 -0
- package/src/main/atoms/link-text.js +21 -0
- package/src/main/atoms/link.js +60 -0
- package/src/main/atoms/list.js +12 -0
- package/src/main/atoms/logo.js +9 -0
- package/src/main/atoms/menu.js +10 -0
- package/src/main/atoms/message.js +5 -0
- package/src/main/atoms/nav-link.js +49 -0
- package/src/main/atoms/popup.js +47 -0
- package/src/main/atoms/rich-text.js +128 -0
- package/src/main/atoms/scroller.js +224 -0
- package/src/main/atoms/svg.js +65 -0
- package/src/main/atoms/table.js +32 -0
- package/src/main/atoms/textarea.js +10 -0
- package/src/main/atoms/time.js +12 -0
- package/src/main/atoms/video.js +100 -0
- package/src/main/export-main.js +12 -0
- package/src/main/export-matter.js +86 -0
- package/src/main/export-preact-hooks.js +1 -0
- package/src/main/export-preact.js +1 -0
- package/src/main/index.js +13 -0
- package/src/main/molecules/asset.js +23 -0
- package/src/main/molecules/glossary.js +44 -0
- package/src/main/molecules/links.js +23 -0
- package/src/main/molecules/promo-text.js +27 -0
- package/src/main/molecules/tags.js +15 -0
- package/src/main/molecules/tree.js +51 -0
- package/src/main/organisms/accordion-item.js +106 -0
- package/src/main/organisms/author.js +29 -0
- package/src/main/organisms/breadcrumb.js +69 -0
- package/src/main/organisms/call-to-action.js +24 -0
- package/src/main/organisms/carousel.js +178 -0
- package/src/main/organisms/cart-item.js +156 -0
- package/src/main/organisms/cart.js +162 -0
- package/src/main/organisms/contact-form.js +141 -0
- package/src/main/organisms/container/ab-test.js +47 -0
- package/src/main/organisms/container/default.js +6 -0
- package/src/main/organisms/container/filtered-section.js +293 -0
- package/src/main/organisms/container/footer.js +12 -0
- package/src/main/organisms/container/grid.js +44 -0
- package/src/main/organisms/container/header.js +13 -0
- package/src/main/organisms/container/list.js +7 -0
- package/src/main/organisms/container/main.js +6 -0
- package/src/main/organisms/container/raw.js +7 -0
- package/src/main/organisms/container/section.js +28 -0
- package/src/main/organisms/container.js +29 -0
- package/src/main/organisms/content-owner.js +15 -0
- package/src/main/organisms/date-entry.js +56 -0
- package/src/main/organisms/external-search.js +73 -0
- package/src/main/organisms/filtered-item.js +163 -0
- package/src/main/organisms/footer-item.js +17 -0
- package/src/main/organisms/image-gallery.js +164 -0
- package/src/main/organisms/last-modified.js +20 -0
- package/src/main/organisms/legal-footer.js +16 -0
- package/src/main/organisms/list-item.js +48 -0
- package/src/main/organisms/metadata.js +11 -0
- package/src/main/organisms/navigation.js +232 -0
- package/src/main/organisms/notification.js +87 -0
- package/src/main/organisms/order-tracker.js +203 -0
- package/src/main/organisms/page-header-banner.js +26 -0
- package/src/main/organisms/page-header.js +33 -0
- package/src/main/organisms/page-tags.js +14 -0
- package/src/main/organisms/page.js +260 -0
- package/src/main/organisms/press-release.js +24 -0
- package/src/main/organisms/product-admin.js +204 -0
- package/src/main/organisms/promo-banner.js +28 -0
- package/src/main/organisms/promo-bottom.js +23 -0
- package/src/main/organisms/promo-button.js +8 -0
- package/src/main/organisms/promo-card-cover.js +35 -0
- package/src/main/organisms/promo-card.js +33 -0
- package/src/main/organisms/promo-full.js +20 -0
- package/src/main/organisms/promo-image.js +22 -0
- package/src/main/organisms/promo-lure.js +22 -0
- package/src/main/organisms/promo-product-card.js +187 -0
- package/src/main/organisms/promo-product-full.js +293 -0
- package/src/main/organisms/promo-simple.js +23 -0
- package/src/main/organisms/quote.js +21 -0
- package/src/main/organisms/search-form.js +42 -0
- package/src/main/organisms/search-nav.js +66 -0
- package/src/main/organisms/search-result.js +53 -0
- package/src/main/organisms/slider.js +26 -0
- package/src/main/organisms/standalone-asset.js +22 -0
- package/src/main/organisms/tabs.js +277 -0
- package/src/main/organisms/topbar.js +83 -0
- package/src/main/organisms/web-component.js +53 -0
- package/src/main/routing/annotation.js +9 -0
- package/src/main/routing/component.js +138 -0
- package/src/main/routing/empty.js +5 -0
- package/src/main/routing/error-handler.js +64 -0
- package/src/main/routing/placeholder-image.svg +5 -0
- package/src/main/routing/router.js +219 -0
- package/src/main/shared/analytics.js +677 -0
- package/src/main/shared/bubble-event.js +11 -0
- package/src/main/shared/custom-element.js +21 -0
- package/src/main/shared/deep-selector.js +28 -0
- package/src/main/shared/disable-transparency.js +10 -0
- package/src/main/shared/format-time.js +8 -0
- package/src/main/shared/get-id.js +5 -0
- package/src/main/shared/get-meta.js +3 -0
- package/src/main/shared/get-size-class.js +3 -0
- package/src/main/shared/get-size.js +11 -0
- package/src/main/shared/h.js +88 -0
- package/src/main/shared/hash-jump.js +33 -0
- package/src/main/shared/icons/arrow-back.svg +1 -0
- package/src/main/shared/icons/arrow-down.svg +1 -0
- package/src/main/shared/icons/arrow-next.svg +1 -0
- package/src/main/shared/icons/arrow-tail-right.svg +1 -0
- package/src/main/shared/icons/arrow-tail-up.svg +1 -0
- package/src/main/shared/icons/arrow-up.svg +1 -0
- package/src/main/shared/icons/asset-download.svg +1 -0
- package/src/main/shared/icons/logo.svg +5 -0
- package/src/main/shared/icons/low-carbon-placeholder.svg +9 -0
- package/src/main/shared/icons/media-pause.svg +1 -0
- package/src/main/shared/icons/media-play.svg +1 -0
- package/src/main/shared/icons/navigation-burger.svg +1 -0
- package/src/main/shared/icons/navigation-close.svg +1 -0
- package/src/main/shared/icons/navigation-link.svg +1 -0
- package/src/main/shared/icons/navigation-refresh.svg +1 -0
- package/src/main/shared/icons/navigation-search.svg +1 -0
- package/src/main/shared/icons/navigation-share.svg +1 -0
- package/src/main/shared/icons/toggle-newwindow.svg +1 -0
- package/src/main/shared/icons.js +18 -0
- package/src/main/shared/id-from-string.js +5 -0
- package/src/main/shared/mark-selection.js +19 -0
- package/src/main/shared/register.js +26 -0
- package/src/main/shared/renderer.js +43 -0
- package/src/main/shared/simple-consent-api.js +70 -0
- package/src/main/shared/split-links.js +11 -0
- package/src/main/shared/t.js +60 -0
- package/src/main/shared/twind.js +837 -0
- package/src/main/shared/update-head.js +34 -0
- package/src/main/shared/update-scrollbar-width.js +30 -0
- package/src/main/shared/use-link.js +151 -0
- package/src/main/shared/use-persistent-state.js +42 -0
- package/src/main/shared/wait-for-dom-ready.js +6 -0
- package/src/main/shared/wcm-mode.js +4 -0
- package/src/wcs/components/acinguiux-preact-doc/acinguiux-preact-doc.js +207 -0
- package/src/wcs/components/admin-dashboard/admin-dashboard.js +487 -0
- package/src/wcs/components/admin-login/admin-login.js +91 -0
- package/src/wcs/components/bazaar-voice/bazaar-voice.js +56 -0
- package/src/wcs/components/chatbot-koreai/chatbot-koreai.js +176 -0
- package/src/wcs/components/chatbot-koreai/koreai-transport.js +217 -0
- package/src/wcs/components/chatbot-ms/chatbot-ms.js +210 -0
- package/src/wcs/components/chatbot-test/chatbot-test.js +44 -0
- package/src/wcs/components/comparison-chart/comparison-chart.js +111 -0
- package/src/wcs/components/consent-banner/consent-banner.js +248 -0
- package/src/wcs/components/consent-banner/icons/ccpa.svg +6 -0
- package/src/wcs/components/consent-banner/icons/info.svg +1 -0
- package/src/wcs/components/consent-banner/provider-onetrust.js +131 -0
- package/src/wcs/components/decision-tree/arrow-back.svg +3 -0
- package/src/wcs/components/decision-tree/badges.js +37 -0
- package/src/wcs/components/decision-tree/decision-tree.js +162 -0
- package/src/wcs/components/dynamic-contact-details/dynamic-contact-details.js +111 -0
- package/src/wcs/components/example-accordion/example-accordion.js +10 -0
- package/src/wcs/components/example-asset/example-asset.js +12 -0
- package/src/wcs/components/example-form/example-form.js +59 -0
- package/src/wcs/components/example-nested/example-nested.js +10 -0
- package/src/wcs/components/example-routing/example-routing.js +51 -0
- package/src/wcs/components/example-rtl/example-rtl.js +28 -0
- package/src/wcs/components/example-tabs/example-tabs.js +12 -0
- package/src/wcs/components/example-web-component/example-web-component.js +34 -0
- package/src/wcs/components/floating-button/floating-button.js +17 -0
- package/src/wcs/components/formstack-form/fields/address.js +38 -0
- package/src/wcs/components/formstack-form/fields/checkbox.js +42 -0
- package/src/wcs/components/formstack-form/fields/date.js +22 -0
- package/src/wcs/components/formstack-form/fields/description.js +8 -0
- package/src/wcs/components/formstack-form/fields/input.js +8 -0
- package/src/wcs/components/formstack-form/fields/name.js +39 -0
- package/src/wcs/components/formstack-form/fields/radio.js +24 -0
- package/src/wcs/components/formstack-form/fields/rating.js +53 -0
- package/src/wcs/components/formstack-form/fields/section.js +8 -0
- package/src/wcs/components/formstack-form/fields/select.js +10 -0
- package/src/wcs/components/formstack-form/fields/textarea.js +8 -0
- package/src/wcs/components/formstack-form/fields/wrapper.js +11 -0
- package/src/wcs/components/formstack-form/formstack-form.js +280 -0
- package/src/wcs/components/fuel-prices/fuel-prices.js +45 -0
- package/src/wcs/components/furniture-overview/furniture-overview.js +115 -0
- package/src/wcs/components/gauge-value/gauge-value.js +65 -0
- package/src/wcs/components/help-centre/api.js +150 -0
- package/src/wcs/components/help-centre/help-centre.js +400 -0
- package/src/wcs/components/help-centre/icon-search.svg +1 -0
- package/src/wcs/components/image-gen/admin-panel.js +248 -0
- package/src/wcs/components/image-gen/image-gen.js +385 -0
- package/src/wcs/components/image-gen/labels.js +37 -0
- package/src/wcs/components/image-gen/use-api.js +392 -0
- package/src/wcs/components/inspired-gallery/inspired-gallery.js +118 -0
- package/src/wcs/components/launch-container/launch-container.js +95 -0
- package/src/wcs/components/launch-container/ledger.js +140 -0
- package/src/wcs/components/lng-map/lng-map.js +44 -0
- package/src/wcs/components/mouseflow-analytics/mouseflow-analytics.js +39 -0
- package/src/wcs/components/msds-search/msds-search.js +127 -0
- package/src/wcs/components/msds-search/navigation-search.svg +3 -0
- package/src/wcs/components/product-catalogue/icon-back.svg +3 -0
- package/src/wcs/components/product-catalogue/icon-cart.svg +3 -0
- package/src/wcs/components/product-catalogue/icon-close.svg +3 -0
- package/src/wcs/components/product-catalogue/product-catalogue.js +215 -0
- package/src/wcs/components/product-links/icon-cart.svg +3 -0
- package/src/wcs/components/product-links/product-links.js +43 -0
- package/src/wcs/components/rio-iframe/rio-iframe.js +137 -0
- package/src/wcs/components/salsify-products/filter-tools.js +60 -0
- package/src/wcs/components/salsify-products/icon-cart.svg +3 -0
- package/src/wcs/components/salsify-products/process-products.js +53 -0
- package/src/wcs/components/salsify-products/route-tools.js +54 -0
- package/src/wcs/components/salsify-products/salsify-products.js +281 -0
- package/src/wcs/components/shout-out/shout-out.js +51 -0
- package/src/wcs/components/simple-chart/simple-chart.js +53 -0
- package/src/wcs/components/single-stat/single-stat.js +85 -0
- package/src/wcs/components/site-feedback/site-feedback.js +56 -0
- package/src/wcs/components/skds-search/navigation-search.svg +3 -0
- package/src/wcs/components/skds-search/skds-search.js +103 -0
- package/src/wcs/components/smart-banner/smart-banner.js +104 -0
- package/src/wcs/components/standalone-table/arrow-up-down.svg +3 -0
- package/src/wcs/components/standalone-table/arrow-up.svg +3 -0
- package/src/wcs/components/standalone-table/standalone-table.js +440 -0
- package/src/wcs/components/station-locator/station-locator.js +49 -0
- package/src/wcs/components/store-badges/badges.js +60 -0
- package/src/wcs/components/store-badges/store-badges.js +93 -0
- package/src/wcs/components/topbar-button/person.svg +1 -0
- package/src/wcs/components/topbar-button/topbar-button.js +22 -0
- package/src/wcs/components/universal-gallery/universal-gallery.js +308 -0
- package/src/wcs/components/zendesk-chat/zendesk-chat.js +133 -0
- package/src/wcs/shared/chat-bot/README.md +61 -0
- package/src/wcs/shared/chat-bot/chat-bot.js +216 -0
- package/src/wcs/shared/chat-bot/resources/arrow-next.svg +1 -0
- package/src/wcs/shared/chat-bot/resources/navigation-close.svg +1 -0
- package/src/wcs/shared/chat-bot/resources/person.svg +1 -0
- package/src/wcs/shared/chat-bot/resources/upload.svg +1 -0
- package/src/wcs/shared/filtered-data/README.md +52 -0
- package/src/wcs/shared/filtered-data/fetch-data.js +33 -0
- package/src/wcs/shared/filtered-data/filtered-data.js +337 -0
- package/src/wcs/shared/promo-with-popup/icon-close.svg +3 -0
- package/src/wcs/shared/promo-with-popup/icon-next.svg +3 -0
- package/src/wcs/shared/promo-with-popup/icon-prev.svg +3 -0
- package/src/wcs/shared/promo-with-popup/promo-with-popup.js +93 -0
|
@@ -0,0 +1,440 @@
|
|
|
1
|
+
import Excel from 'exceljs'
|
|
2
|
+
|
|
3
|
+
import ICON_ARROW_UP from './arrow-up.svg'
|
|
4
|
+
import ICON_ARROW_UP_DOWN from './arrow-up-down.svg'
|
|
5
|
+
|
|
6
|
+
const { h, register, matter, preactHooks, t } = globalThis.ami
|
|
7
|
+
const { Box, Button, Heading, Icon, Input, Link, Message, Table } = matter // acinguiux-preact components
|
|
8
|
+
const { useState, useEffect, useMemo, useRef } = preactHooks // Preact hooks
|
|
9
|
+
|
|
10
|
+
const MAX_SIZE = 100_000
|
|
11
|
+
const MAX_ROWS = 200
|
|
12
|
+
const MAX_COLS = 15
|
|
13
|
+
const BYTE_LENGTH = 1000
|
|
14
|
+
const MAX_FILTER_OPTION_LENGTH = 20
|
|
15
|
+
const QUERY_ITEMS_PER_PAGE = 50
|
|
16
|
+
const DEBOUNCE_DELAY = 300
|
|
17
|
+
|
|
18
|
+
// Fetch & parse the document.
|
|
19
|
+
async function fetchAndParseSpreadsheet (src, isQueryable) {
|
|
20
|
+
if (!src) {
|
|
21
|
+
throw new Error('Missing document source.')
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Fetch the document.
|
|
25
|
+
const res = await fetch(src)
|
|
26
|
+
if (!res.ok) {
|
|
27
|
+
throw new Error(`Error loading document: ${src}`)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const arrayBuffer = await res.arrayBuffer()
|
|
31
|
+
if (arrayBuffer.byteLength > MAX_SIZE) {
|
|
32
|
+
throw new Error(`Please reduce the file size to a maximum of ${MAX_SIZE / BYTE_LENGTH}KB.`)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const workbook = new Excel.Workbook()
|
|
36
|
+
await workbook.xlsx.load(arrayBuffer)
|
|
37
|
+
if (workbook.worksheets.length < 1) {
|
|
38
|
+
throw new Error('No sheets found in the document.')
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const title = workbook.getWorksheet().name
|
|
42
|
+
const sheet = workbook.getWorksheet(title)
|
|
43
|
+
const workbookTitle = workbook?.title
|
|
44
|
+
const workbookDescription = workbook?.description
|
|
45
|
+
if ((!isQueryable && (sheet.actualRowCount > MAX_ROWS)) || sheet.actualColumnCount > MAX_COLS) {
|
|
46
|
+
throw new Error(`Please reduce the amount of content to display in this table to a maximum of ${MAX_COLS} columns and ${MAX_ROWS} rows.`)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const { header, table } = getSheetData(sheet)
|
|
50
|
+
return { ready: true, header, table, filteredTable: table, sortedTable: table, isQueryable, title, workbookTitle, workbookDescription }
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function getSheetData (sheet) {
|
|
54
|
+
let header
|
|
55
|
+
const table = []
|
|
56
|
+
sheet.eachRow((row, key) => {
|
|
57
|
+
const rowData = []
|
|
58
|
+
rowData.tableRowKey = key
|
|
59
|
+
const isHeader = row.number === 1
|
|
60
|
+
row.eachCell({ includeEmpty: true }, cell => {
|
|
61
|
+
rowData.push({
|
|
62
|
+
text: getCellValue(cell) ?? cell.value,
|
|
63
|
+
link: cell.hyperlink,
|
|
64
|
+
style: getStyle(cell)
|
|
65
|
+
})
|
|
66
|
+
})
|
|
67
|
+
if (isHeader) {
|
|
68
|
+
header = rowData
|
|
69
|
+
} else {
|
|
70
|
+
// Fix includeEmpty issue
|
|
71
|
+
while (rowData.length < header.length) {
|
|
72
|
+
rowData.push({ text: '' })
|
|
73
|
+
}
|
|
74
|
+
table.push(rowData)
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
return { header, table }
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function getCellValue (cell) {
|
|
81
|
+
const dateValue = cell.value?.toLocaleDateString?.(document.documentElement.lang, { timeZone: 'UTC' })
|
|
82
|
+
const superScriptSubscriptValue = cell.value?.richText?.map?.(text => text.text).join('')
|
|
83
|
+
const formulaValue = { 'TRUE()': 'True', 'FALSE()': 'False' }[cell.value?.formula] ?? cell.value?.result ?? cell.value?.text
|
|
84
|
+
const booleanValue = typeof cell.value === 'boolean' ? String(cell.value) : cell.value
|
|
85
|
+
|
|
86
|
+
return dateValue ?? formulaValue ?? superScriptSubscriptValue ?? booleanValue
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function getStyle (cell) {
|
|
90
|
+
const styles = []
|
|
91
|
+
cell.style.alignment?.horizontal && styles.push(`text-align: ${cell.style.alignment.horizontal}`)
|
|
92
|
+
cell.style.font?.bold && styles.push('font-weight: bold')
|
|
93
|
+
cell.style.font?.italic && styles.push('font-style: italic')
|
|
94
|
+
return styles.join(';')
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function useFeatures (rawFeatures) {
|
|
98
|
+
// Available features: sort,search,filter=column_number
|
|
99
|
+
return useMemo(() => {
|
|
100
|
+
// Keys treated as sets (mutliple values)
|
|
101
|
+
const FEATURE_SET_KEYS = new Set(['filter'])
|
|
102
|
+
const featureSplit = rawFeatures?.split?.(',') || []
|
|
103
|
+
return featureSplit.reduce((acc, curr) => {
|
|
104
|
+
const [key, value] = curr.split('=').map(v => v.trim())
|
|
105
|
+
if (FEATURE_SET_KEYS.has(key)) {
|
|
106
|
+
acc[key] = [...acc[key] || [], Number.parseInt(value, 10) || value]
|
|
107
|
+
} else {
|
|
108
|
+
acc[key] = true
|
|
109
|
+
}
|
|
110
|
+
return acc
|
|
111
|
+
}, {})
|
|
112
|
+
}, [rawFeatures])
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function Filter ({ data, features, onQuery, id }) {
|
|
116
|
+
const [filterFields, setFilterFields] = useState([])
|
|
117
|
+
const [filterVals, setFilterVals] = useState(new Map())
|
|
118
|
+
const [searchText, setSearchText] = useState('')
|
|
119
|
+
const [isQueried, setIsQueried] = useState(false)
|
|
120
|
+
|
|
121
|
+
useEffect(() => {
|
|
122
|
+
if (data?.table?.length && features.filter?.length) {
|
|
123
|
+
data.header && setFilterFields(features.filter.map(rawColumnNumber => {
|
|
124
|
+
const columnNumber = rawColumnNumber - 1
|
|
125
|
+
const headerCell = data.header[columnNumber]
|
|
126
|
+
if (!headerCell) {
|
|
127
|
+
return null
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return {
|
|
131
|
+
columnNumber,
|
|
132
|
+
name: headerCell.text,
|
|
133
|
+
// Filter value aggregation is case-sensitive
|
|
134
|
+
values: [
|
|
135
|
+
...data.table.reduce((acc, row) => {
|
|
136
|
+
const value = row[columnNumber]?.text
|
|
137
|
+
if (typeof value === 'number' || value) {
|
|
138
|
+
acc.add(value)
|
|
139
|
+
}
|
|
140
|
+
return acc
|
|
141
|
+
}, new Set())
|
|
142
|
+
].sort((v1, v2) => v1?.toLowerCase?.() < v2?.toLowerCase?.() ? -1 : 1).map(String)
|
|
143
|
+
}
|
|
144
|
+
}).filter(Boolean).sort())
|
|
145
|
+
}
|
|
146
|
+
}, [data])
|
|
147
|
+
|
|
148
|
+
useEffect(() => () => clearTimeout(searchTimeoutRef.current), [])
|
|
149
|
+
|
|
150
|
+
const handleQueryUpdate = (text, filters) => {
|
|
151
|
+
onQuery?.(text, filters)
|
|
152
|
+
setIsQueried(!!text || filters.size > 0)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const handleFilterChange = (value, field) => {
|
|
156
|
+
const newFilterVals = new Map(filterVals)
|
|
157
|
+
if (value) {
|
|
158
|
+
newFilterVals.set(field.columnNumber, value)
|
|
159
|
+
} else {
|
|
160
|
+
newFilterVals.delete(field.columnNumber)
|
|
161
|
+
}
|
|
162
|
+
setFilterVals(newFilterVals)
|
|
163
|
+
handleQueryUpdate(searchText, newFilterVals)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const searchTimeoutRef = useRef(null)
|
|
167
|
+
const textProps = {
|
|
168
|
+
_size: 'sm',
|
|
169
|
+
type: 'search',
|
|
170
|
+
placeholder: t('Enter your search term'),
|
|
171
|
+
name: 'text',
|
|
172
|
+
value: searchText,
|
|
173
|
+
'aria-controls': id,
|
|
174
|
+
onInput: e => {
|
|
175
|
+
const { value } = e.target
|
|
176
|
+
setSearchText(value)
|
|
177
|
+
clearTimeout(searchTimeoutRef.current)
|
|
178
|
+
// Adding a debounce to avoid too many queries.
|
|
179
|
+
searchTimeoutRef.current = setTimeout(() => {
|
|
180
|
+
handleQueryUpdate(value, filterVals)
|
|
181
|
+
}, DEBOUNCE_DELAY)
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return (features.search || (filterFields.length > 0)) && h('div', { className: 'space-y-5' },
|
|
186
|
+
h('div', { className: 'flex md:flex-col sm:flex-col gap-5' },
|
|
187
|
+
// Search box.
|
|
188
|
+
h('div', { className: 'grow' },
|
|
189
|
+
h(Input, textProps)
|
|
190
|
+
),
|
|
191
|
+
// Filters.
|
|
192
|
+
filterFields.map((field, fieldIndex) => h('div',
|
|
193
|
+
h(Input, {
|
|
194
|
+
type: 'select',
|
|
195
|
+
name: `filter-${fieldIndex + 1}`,
|
|
196
|
+
value: filterVals.get(field.columnNumber) || '',
|
|
197
|
+
'aria-controls': id,
|
|
198
|
+
onChange: e => {
|
|
199
|
+
const { value } = e.target
|
|
200
|
+
handleFilterChange(value, field)
|
|
201
|
+
},
|
|
202
|
+
children: [
|
|
203
|
+
h('option', { selected: true, value: '' }, field.name),
|
|
204
|
+
...field.values.map(value =>
|
|
205
|
+
h('option', { value }, value.length > MAX_FILTER_OPTION_LENGTH
|
|
206
|
+
? `${value.substring(0, MAX_FILTER_OPTION_LENGTH)}...`
|
|
207
|
+
: value
|
|
208
|
+
)
|
|
209
|
+
)
|
|
210
|
+
]
|
|
211
|
+
})
|
|
212
|
+
))
|
|
213
|
+
),
|
|
214
|
+
// Reset filters
|
|
215
|
+
isQueried && h(Link, {
|
|
216
|
+
role: 'button',
|
|
217
|
+
_variant: 'full',
|
|
218
|
+
'aria-controls': id,
|
|
219
|
+
_model: {
|
|
220
|
+
name: t('Reset filters'),
|
|
221
|
+
value: '#'
|
|
222
|
+
},
|
|
223
|
+
onClick: e => {
|
|
224
|
+
e.preventDefault()
|
|
225
|
+
setSearchText('')
|
|
226
|
+
setFilterVals(new Map())
|
|
227
|
+
onQuery?.('', new Map())
|
|
228
|
+
setIsQueried(false)
|
|
229
|
+
}
|
|
230
|
+
})
|
|
231
|
+
)
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function TableRow ({ key, row, sortData, isHeader, onColumnSort }) {
|
|
235
|
+
return h('tr', { key }, row.map((cell, cellIndex) => {
|
|
236
|
+
// Regular cell.
|
|
237
|
+
if (!isHeader) {
|
|
238
|
+
return h('td', { className: 'whitespace-pre-wrap', style: cell.style }, cell.link
|
|
239
|
+
? h(Link, { _model: { name: cell.text, value: cell.link }, _variant: 'full' })
|
|
240
|
+
: h('span', {}, cell.text)
|
|
241
|
+
)
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// Non sortable header.
|
|
245
|
+
if (!sortData) {
|
|
246
|
+
return h('th', { className: 'whitespace-pre-wrap', style: cell.style }, cell.text)
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const sortProps = { icon: ICON_ARROW_UP_DOWN, flipClass: '', label: () => t('Click to sort') }
|
|
250
|
+
if (sortData?.columnNumber === cellIndex) {
|
|
251
|
+
sortProps.icon = ICON_ARROW_UP
|
|
252
|
+
sortProps.label = name => t('Sorted ascending - {0}', name)
|
|
253
|
+
if (!sortData.isAsc) {
|
|
254
|
+
sortProps.flipClass = 'rotate-180'
|
|
255
|
+
sortProps.label = name => t('Sorted descending - {0}', name)
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// Sortable header.
|
|
260
|
+
return h('th', {
|
|
261
|
+
className: 'cursor-pointer whitespace-nowrap clickable',
|
|
262
|
+
'aria-live': 'assertive',
|
|
263
|
+
'aria-label': sortProps.label(cell.text),
|
|
264
|
+
style: cell.style,
|
|
265
|
+
onClick: () => onColumnSort(cellIndex),
|
|
266
|
+
children: h('div', { className: 'flex gap-1' },
|
|
267
|
+
cell.text,
|
|
268
|
+
h('div', { className: `flex items-center justify-center ${sortProps.flipClass}` },
|
|
269
|
+
h(Icon, { _size: 'sm' }, sortProps.icon)
|
|
270
|
+
)
|
|
271
|
+
)
|
|
272
|
+
})
|
|
273
|
+
}))
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
function TableContents ({ features, data, sortData, page, setPage, onColumnSort, id, 'aria-live': ariaLive }) {
|
|
277
|
+
let dataRows = data.sortedTable
|
|
278
|
+
let pageCount
|
|
279
|
+
if (page !== null) {
|
|
280
|
+
dataRows = data.sortedTable.slice(0, page * QUERY_ITEMS_PER_PAGE)
|
|
281
|
+
pageCount = Math.ceil(data.sortedTable.length / QUERY_ITEMS_PER_PAGE)
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const rows = [data.header, ...dataRows]
|
|
285
|
+
const noItems = rows.length <= 1
|
|
286
|
+
|
|
287
|
+
return [
|
|
288
|
+
noItems && h('div', { className: 'text-center' }, 'No items.'),
|
|
289
|
+
!noItems && h(Table, { id, 'aria-live': ariaLive }, rows.map((row, rowIndex) =>
|
|
290
|
+
h(TableRow, { key: row.tableRowKey, row, sortData: features.sort && sortData, isHeader: rowIndex === 0, onColumnSort }))
|
|
291
|
+
),
|
|
292
|
+
(page > 0) && (page < pageCount) && h('div', { className: 'text-center' },
|
|
293
|
+
h(Button, {
|
|
294
|
+
_size: 'sm',
|
|
295
|
+
'aria-controls': id,
|
|
296
|
+
_model: {
|
|
297
|
+
name: t('Load more')
|
|
298
|
+
},
|
|
299
|
+
onClick: e => {
|
|
300
|
+
e.preventDefault()
|
|
301
|
+
setPage(page + 1)
|
|
302
|
+
}
|
|
303
|
+
})
|
|
304
|
+
)
|
|
305
|
+
]
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
function getQueryKey (text) {
|
|
309
|
+
return typeof text === 'number' ? `${text}` : text
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
function getOnQuery (data, setData, sortTable, setPage) {
|
|
313
|
+
return (rawSearchText, filterVals) => {
|
|
314
|
+
let newTable = data.table
|
|
315
|
+
const searchText = rawSearchText?.trim?.()?.toLowerCase()
|
|
316
|
+
|
|
317
|
+
if (searchText) {
|
|
318
|
+
newTable = newTable.filter(row => row.some(cell => getQueryKey(cell.text)?.toLowerCase?.().includes?.(searchText)))
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
for (const [columnNumber, value] of filterVals.entries()) {
|
|
322
|
+
newTable = newTable.filter(row => getQueryKey(row[columnNumber]?.text) === value)
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
setData({
|
|
326
|
+
...data,
|
|
327
|
+
filteredTable: newTable,
|
|
328
|
+
sortedTable: sortTable(newTable)
|
|
329
|
+
})
|
|
330
|
+
setPage(1)
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
function getCompareKey (rawValue) {
|
|
335
|
+
return typeof rawValue === 'number' ? rawValue : (rawValue?.toLowerCase?.() || '')
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
function sortCompare (rawValue1, rawValue2, multiplier) {
|
|
339
|
+
const value1 = getCompareKey(rawValue1)
|
|
340
|
+
const value2 = getCompareKey(rawValue2)
|
|
341
|
+
// Numbers go before strings
|
|
342
|
+
if (typeof value1 === 'number' && typeof value2 !== 'number') {
|
|
343
|
+
return -1 * multiplier
|
|
344
|
+
} else if (typeof value1 !== 'number' && typeof value2 === 'number') {
|
|
345
|
+
return multiplier
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// Both of same type or falsy
|
|
349
|
+
if (value1 < value2) {
|
|
350
|
+
return -multiplier
|
|
351
|
+
} else if (value2 < value1) {
|
|
352
|
+
return multiplier
|
|
353
|
+
} else {
|
|
354
|
+
return 0
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
function getSortTable (sortData) {
|
|
359
|
+
return table => {
|
|
360
|
+
const col = sortData.columnNumber
|
|
361
|
+
|
|
362
|
+
return col === null
|
|
363
|
+
? table
|
|
364
|
+
: [...table].sort((row1, row2) => sortCompare(row1[col]?.text, row2[col]?.text, sortData.isAsc ? 1 : -1))
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
function getOnColumnSort (sortData, setSortData) {
|
|
369
|
+
return cellIndex => {
|
|
370
|
+
if (sortData.columnNumber === cellIndex) {
|
|
371
|
+
if (sortData.isAsc) {
|
|
372
|
+
setSortData({ columnNumber: cellIndex, isAsc: false })
|
|
373
|
+
} else {
|
|
374
|
+
setSortData({ columnNumber: null, isAsc: true })
|
|
375
|
+
}
|
|
376
|
+
} else {
|
|
377
|
+
setSortData({
|
|
378
|
+
columnNumber: cellIndex,
|
|
379
|
+
isAsc: true
|
|
380
|
+
})
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
export function StandaloneTable ({ src, features: rawFeatures, prefix, 'show-title-description': showTitleDescription }) {
|
|
386
|
+
const [data, setData] = useState({ ready: false, table: [], filteredTable: [], sortedTable: [], isQueryable: false, title: null, error: null })
|
|
387
|
+
const [page, setPage] = useState(null)
|
|
388
|
+
const [sortData, setSortData] = useState({ columnNumber: null, isAsc: true })
|
|
389
|
+
const features = useFeatures(rawFeatures)
|
|
390
|
+
const [id] = useState(() => `_${crypto.randomUUID()}`)
|
|
391
|
+
|
|
392
|
+
const sortTable = getSortTable(sortData)
|
|
393
|
+
const onQuery = getOnQuery(data, setData, sortTable, setPage)
|
|
394
|
+
const onColumnSort = getOnColumnSort(sortData, setSortData)
|
|
395
|
+
|
|
396
|
+
useEffect(() => {
|
|
397
|
+
(async function () {
|
|
398
|
+
try {
|
|
399
|
+
const isQueryable = features.search || features.filter
|
|
400
|
+
setData(await fetchAndParseSpreadsheet(src, isQueryable))
|
|
401
|
+
if (isQueryable) {
|
|
402
|
+
setPage(1)
|
|
403
|
+
}
|
|
404
|
+
} catch (error) {
|
|
405
|
+
setData({ error: error.message })
|
|
406
|
+
}
|
|
407
|
+
})()
|
|
408
|
+
}, [src])
|
|
409
|
+
|
|
410
|
+
useEffect(() => {
|
|
411
|
+
setData({
|
|
412
|
+
...data,
|
|
413
|
+
sortedTable: sortData.columnNumber === null ? data.filteredTable : sortTable(data.filteredTable)
|
|
414
|
+
})
|
|
415
|
+
}, [sortData.columnNumber, sortData.isAsc])
|
|
416
|
+
|
|
417
|
+
if (data.error) {
|
|
418
|
+
return h(Message, data.error)
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// Title and Subtitle
|
|
422
|
+
let headerContent
|
|
423
|
+
if (showTitleDescription === 'true') {
|
|
424
|
+
headerContent = [
|
|
425
|
+
data.workbookTitle && h(Heading, { _level: 3 }, data.workbookTitle),
|
|
426
|
+
data.title && h(Heading, { _level: 4 }, prefix ? `${prefix} ${data.title}` : data.title),
|
|
427
|
+
]
|
|
428
|
+
} else {
|
|
429
|
+
headerContent = [data.title && h(Heading, { _level: 3 }, data.title)]
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
return data.ready && h(Box, { className: 'bg-bga text-txa rounded-2xl' },
|
|
433
|
+
...headerContent,
|
|
434
|
+
h(Filter, { data, features, onQuery, id }),
|
|
435
|
+
h(TableContents, { features, data, sortData, page, setPage, onColumnSort, id, 'aria-live': 'polite' }),
|
|
436
|
+
showTitleDescription === 'true' && data.workbookDescription && h('p', {}, data.workbookDescription)
|
|
437
|
+
)
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
register(StandaloneTable, 'standalone-table')
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const { h, register, preactHooks, getConsent } = globalThis.ami
|
|
2
|
+
const { useRef, useEffect } = preactHooks
|
|
3
|
+
|
|
4
|
+
const POLL_INTERVAL = 1000
|
|
5
|
+
|
|
6
|
+
function StationLocator ({ src }) {
|
|
7
|
+
const ref = useRef(null)
|
|
8
|
+
|
|
9
|
+
// Deep linking.
|
|
10
|
+
const url = new URL(src)
|
|
11
|
+
const params = new URLSearchParams(location.search)
|
|
12
|
+
const filters = params.get('station-locator-filters')
|
|
13
|
+
filters && url.searchParams.set('prefilters', filters)
|
|
14
|
+
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
let interval = null
|
|
17
|
+
if (!ref.current) {
|
|
18
|
+
return null
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const iframe = ref.current
|
|
22
|
+
const origin = new URL(src).origin
|
|
23
|
+
|
|
24
|
+
// Post consent to iframe.
|
|
25
|
+
const onLoad = () => {
|
|
26
|
+
interval = setInterval(() => {
|
|
27
|
+
iframe?.contentWindow?.postMessage({ consent: JSON.stringify(getConsent()) }, origin)
|
|
28
|
+
}, POLL_INTERVAL)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
iframe.addEventListener('load', onLoad)
|
|
32
|
+
|
|
33
|
+
// Clear interval and load event when destroyed.
|
|
34
|
+
return () => {
|
|
35
|
+
clearInterval(interval)
|
|
36
|
+
iframe.removeEventListener('load', onLoad)
|
|
37
|
+
}
|
|
38
|
+
}, [src, ref.current])
|
|
39
|
+
|
|
40
|
+
return h('iframe', {
|
|
41
|
+
allow: 'clipboard-write; geolocation',
|
|
42
|
+
ref,
|
|
43
|
+
className: 'block w-full rounded-2xl border border-txa/20 sm:h-svh md:h-svh lg:aspect-4/3',
|
|
44
|
+
style: 'max-height: calc(100svh - 48px)',
|
|
45
|
+
src: url.href
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
register(StationLocator, 'station-locator')
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export const google = text => `<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<svg width="200" version="1.1" viewBox="0 0 180 53.333" xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<defs>
|
|
4
|
+
<clipPath id="clipPath5">
|
|
5
|
+
<path transform="translate(-140 -10)" d="m0 60h155v-60h-155z"/>
|
|
6
|
+
</clipPath>
|
|
7
|
+
<clipPath id="clipPath7">
|
|
8
|
+
<path transform="translate(-140 -50)" d="m0 60h155v-60h-155z"/>
|
|
9
|
+
</clipPath>
|
|
10
|
+
<clipPath id="clipPath25">
|
|
11
|
+
<path d="m0 60h155v-60h-155z"/>
|
|
12
|
+
</clipPath>
|
|
13
|
+
<clipPath id="clipPath27">
|
|
14
|
+
<path transform="translate(-30.717 -30.576)" d="m0 60h155v-60h-155z"/>
|
|
15
|
+
</clipPath>
|
|
16
|
+
<clipPath id="clipPath29">
|
|
17
|
+
<path transform="translate(-41.488 -32.5)" d="m0 60h155v-60h-155z"/>
|
|
18
|
+
</clipPath>
|
|
19
|
+
<clipPath id="clipPath31">
|
|
20
|
+
<path transform="translate(-20.07 -40.723)" d="m0 60h155v-60h-155z"/>
|
|
21
|
+
</clipPath>
|
|
22
|
+
<clipPath id="clipPath33">
|
|
23
|
+
<path transform="translate(-30.796 -29.999)" d="m0 60h155v-60h-155z"/>
|
|
24
|
+
</clipPath>
|
|
25
|
+
</defs>
|
|
26
|
+
<g>
|
|
27
|
+
<path transform="matrix(1.3333 0 0 -1.3333 173.33 53.333)" d="m0 0h-125c-2.75 0-5 2.25-5 5v30c0 2.75 2.25 5 5 5h125c2.75 0 5-2.25 5-5v-30c0-2.75-2.25-5-5-5" clip-path="url(#clipPath5)"/>
|
|
28
|
+
<path transform="matrix(1.3333 0 0 -1.3333 173.33 .000266)" d="m0 0h-125c-2.75 0-5-2.25-5-5v-30c0-2.75 2.25-5 5-5h125c2.75 0 5 2.25 5 5v30c0 2.75-2.25 5-5 5m0-0.8c2.316 0 4.2-1.884 4.2-4.2v-30c0-2.316-1.884-4.2-4.2-4.2h-125c-2.316 0-4.2 1.884-4.2 4.2v30c0 2.316 1.884 4.2 4.2 4.2z" clip-path="url(#clipPath7)" fill="#a6a6a6"/>
|
|
29
|
+
<path transform="matrix(1.3333 0 0 -1.3333 -13.333 66.667)" d="m116.94 20h1.866v12.501h-1.866zm16.807 7.998-2.139-5.42h-0.064l-2.22 5.42h-2.01l3.329-7.575-1.897-4.214h1.945l5.131 11.789zm-10.582-6.578c-0.612 0-1.464 0.305-1.464 1.062 0 0.964 1.061 1.334 1.978 1.334 0.82 0 1.207-0.177 1.705-0.418-0.145-1.158-1.142-1.978-2.219-1.978m0.225 6.851c-1.351 0-2.751-0.595-3.329-1.914l1.656-0.691c0.354 0.691 1.013 0.917 1.705 0.917 0.965 0 1.946-0.579 1.962-1.609v-0.128c-0.338 0.193-1.061 0.482-1.946 0.482-1.785 0-3.603-0.981-3.603-2.814 0-1.673 1.464-2.751 3.104-2.751 1.255 0 1.947 0.563 2.381 1.223h0.064v-0.965h1.801v4.793c0 2.219-1.656 3.457-3.795 3.457m-11.532-1.795h-2.654v4.285h2.654c1.395 0 2.187-1.155 2.187-2.142 0-0.969-0.792-2.143-2.187-2.143m-0.048 6.025h-4.471v-12.501h1.865v4.736h2.606c2.068 0 4.101 1.498 4.101 3.883s-2.033 3.882-4.101 3.882m-24.381-11.083c-1.289 0-2.368 1.079-2.368 2.561 0 1.498 1.079 2.594 2.368 2.594 1.273 0 2.271-1.096 2.271-2.594 0-1.482-0.998-2.561-2.271-2.561m2.143 5.88h-0.065c-0.419 0.499-1.224 0.95-2.239 0.95-2.127 0-4.076-1.868-4.076-4.269 0-2.384 1.949-4.237 4.076-4.237 1.015 0 1.82 0.451 2.239 0.967h0.065v-0.613c0-1.627-0.87-2.497-2.272-2.497-1.144 0-1.853 0.822-2.143 1.515l-1.627-0.677c0.467-1.128 1.708-2.513 3.77-2.513 2.191 0 4.044 1.289 4.044 4.43v7.637h-1.772zm3.061-7.298h1.869v12.502h-1.869zm4.623 4.124c-0.048 1.643 1.273 2.481 2.223 2.481 0.742 0 1.37-0.37 1.579-0.902zm5.8 1.418c-0.354 0.95-1.434 2.706-3.641 2.706-2.191 0-4.011-1.723-4.011-4.253 0-2.384 1.804-4.253 4.22-4.253 1.95 0 3.078 1.192 3.545 1.885l-1.45 0.967c-0.483-0.709-1.144-1.176-2.095-1.176-0.95 0-1.627 0.435-2.062 1.288l5.687 2.353zm-45.308 1.401v-1.804h4.317c-0.129-1.015-0.467-1.756-0.982-2.271-0.629-0.629-1.612-1.322-3.335-1.322-2.659 0-4.737 2.143-4.737 4.801 0 2.659 2.078 4.801 4.737 4.801 1.434 0 2.481-0.564 3.254-1.289l1.273 1.273c-1.08 1.031-2.513 1.821-4.527 1.821-3.641 0-6.702-2.965-6.702-6.606s3.061-6.605 6.702-6.605c1.965 0 3.447 0.645 4.607 1.853 1.193 1.192 1.563 2.867 1.563 4.221 0 0.419-0.032 0.805-0.097 1.127zm11.079-5.525c-1.289 0-2.401 1.063-2.401 2.577 0 1.531 1.112 2.578 2.401 2.578 1.288 0 2.4-1.047 2.4-2.578 0-1.514-1.112-2.577-2.4-2.577m0 6.83c-2.353 0-4.27-1.788-4.27-4.253 0-2.449 1.917-4.253 4.27-4.253 2.352 0 4.269 1.804 4.269 4.253 0 2.465-1.917 4.253-4.269 4.253m9.313-6.83c-1.289 0-2.401 1.063-2.401 2.577 0 1.531 1.112 2.578 2.401 2.578s2.4-1.047 2.4-2.578c0-1.514-1.111-2.577-2.4-2.577m0 6.83c-2.352 0-4.269-1.788-4.269-4.253 0-2.449 1.917-4.253 4.269-4.253s4.269 1.804 4.269 4.253c0 2.465-1.917 4.253-4.269 4.253" clip-path="url(#clipPath25)" fill="#fff"/>
|
|
30
|
+
<path transform="matrix(1.3333 0 0 -1.3333 27.623 25.899)" d="m0 0-10.647-11.3c1e-3 -2e-3 1e-3 -5e-3 2e-3 -7e-3 0.327-1.227 1.447-2.13 2.777-2.13 0.532 0 1.031 0.144 1.459 0.396l0.034 0.02 11.984 6.915z" clip-path="url(#clipPath27)" fill="#ea4335"/>
|
|
31
|
+
<path transform="matrix(1.3333 0 0 -1.3333 41.984 23.333)" d="m0 0-0.01 7e-3 -5.174 2.999-5.829-5.187 5.85-5.848 5.146 2.969c0.902 0.488 1.515 1.439 1.515 2.535 0 1.09-0.604 2.036-1.498 2.525" clip-path="url(#clipPath29)" fill="#fbbc04"/>
|
|
32
|
+
<path transform="matrix(1.3333 0 0 -1.3333 13.427 12.37)" d="m0 0c-0.064-0.236-0.098-0.484-0.098-0.74v-19.968c0-0.256 0.034-0.504 0.099-0.739l11.012 11.011z" clip-path="url(#clipPath31)" fill="#4285f4"/>
|
|
33
|
+
<path transform="matrix(1.3333 0 0 -1.3333 27.728 26.668)" d="m0 0 5.51 5.509-11.97 6.94c-0.435 0.261-0.943 0.411-1.486 0.411-1.33 0-2.452-0.905-2.779-2.133 0-1e-3 -1e-3 -2e-3 -1e-3 -3e-3z" clip-path="url(#clipPath33)" fill="#34a853"/>
|
|
34
|
+
</g>
|
|
35
|
+
<text x="54.212109" y="17.529634" fill="#f9f9f9" font-family="Arial" font-size="11px" font-weight="bold" letter-spacing=".2px" xml:space="preserve"><tspan x="54.212109" y="17.529634" font-family="Arial" font-size="11px" font-weight="bold" letter-spacing=".2px">${text.toUpperCase()}</tspan></text>
|
|
36
|
+
</svg>
|
|
37
|
+
`
|
|
38
|
+
|
|
39
|
+
export const apple = text => `<?xml version="1.0" encoding="UTF-8"?>
|
|
40
|
+
<svg id="livetype" width="200" version="1.1" viewBox="0 0 119.66 40" xmlns="http://www.w3.org/2000/svg">
|
|
41
|
+
<path d="m110.13 0h-100.6c-0.3667 0-0.729 0-1.0947 2e-3 -0.30615 2e-3 -0.60986 0.00781-0.91895 0.0127a13.215 13.215 0 0 0-2.0039 0.17671 6.6651 6.6651 0 0 0-1.9009 0.627 6.4378 6.4378 0 0 0-1.6186 1.1787 6.2584 6.2584 0 0 0-1.1782 1.6211 6.6012 6.6012 0 0 0-0.625 1.9033 12.993 12.993 0 0 0-0.1792 2.002c-0.00928 0.3066-0.01026 0.61422-0.01515 0.92086v23.114c0.00489 0.3105 0.00587 0.6113 0.01515 0.9219a12.992 12.992 0 0 0 0.1792 2.0019 6.5876 6.5876 0 0 0 0.625 1.9043 6.2078 6.2078 0 0 0 1.1782 1.6143 6.2744 6.2744 0 0 0 1.6186 1.1787 6.7008 6.7008 0 0 0 1.9009 0.6308 13.455 13.455 0 0 0 2.0039 0.1768c0.30909 0.0068 0.6128 0.0107 0.91895 0.0107 0.36572 2e-3 0.72805 2e-3 1.0947 2e-3h100.6c0.3594 0 0.7246 0 1.084-2e-3 0.3047 0 0.6172-0.0039 0.9219-0.0107a13.279 13.279 0 0 0 2-0.1768 6.8043 6.8043 0 0 0 1.9082-0.6308 6.2774 6.2774 0 0 0 1.6172-1.1787 6.3948 6.3948 0 0 0 1.1816-1.6143 6.6041 6.6041 0 0 0 0.6191-1.9043 13.506 13.506 0 0 0 0.1856-2.0019c4e-3 -0.3106 4e-3 -0.6114 4e-3 -0.9219 8e-3 -0.3633 8e-3 -0.7246 8e-3 -1.0938v-20.929c0-0.36621 0-0.72949-8e-3 -1.0918 0-0.30664 0-0.61426-4e-3 -0.9209a13.507 13.507 0 0 0-0.1856-2.002 6.6177 6.6177 0 0 0-0.6191-1.9033 6.4662 6.4662 0 0 0-2.7988-2.7998 6.7675 6.7675 0 0 0-1.9082-0.627 13.044 13.044 0 0 0-2-0.17676c-0.3047-0.00488-0.6172-0.01074-0.9219-0.01269-0.3594-2e-3 -0.7246-2e-3 -1.084-2e-3z" fill="#a6a6a6"/>
|
|
42
|
+
<path d="m8.4448 39.125c-0.30468 0-0.602-0.0039-0.90429-0.0107a12.687 12.687 0 0 1-1.8691-0.1631 5.8838 5.8838 0 0 1-1.6567-0.5479 5.4057 5.4057 0 0 1-1.397-1.0166 5.3208 5.3208 0 0 1-1.0205-1.3965 5.7219 5.7219 0 0 1-0.543-1.6572 12.414 12.414 0 0 1-0.1665-1.875c-0.00634-0.2109-0.01464-0.9131-0.01464-0.9131v-23.101s0.00884-0.69141 0.01469-0.89454a12.37 12.37 0 0 1 0.16553-1.8721 5.7555 5.7555 0 0 1 0.54346-1.6621 5.3735 5.3735 0 0 1 1.0151-1.398 5.5654 5.5654 0 0 1 1.4023-1.0225 5.8231 5.8231 0 0 1 1.6533-0.54394 12.586 12.586 0 0 1 1.8755-0.16406l0.90232-0.01221h102.77l0.9131 0.0127a12.385 12.385 0 0 1 1.8584 0.16259 5.9383 5.9383 0 0 1 1.6709 0.54785 5.5937 5.5937 0 0 1 2.415 2.4199 5.7627 5.7627 0 0 1 0.5352 1.6489 12.995 12.995 0 0 1 0.1738 1.8872c3e-3 0.2832 3e-3 0.5874 3e-3 0.89014 8e-3 0.375 8e-3 0.73193 8e-3 1.0918v20.929c0 0.3633 0 0.7178-8e-3 1.0752 0 0.3252 0 0.6231-4e-3 0.9297a12.731 12.731 0 0 1-0.1709 1.8535 5.739 5.739 0 0 1-0.54 1.67 5.4803 5.4803 0 0 1-1.0156 1.3857 5.4129 5.4129 0 0 1-1.3994 1.0225 5.8617 5.8617 0 0 1-1.668 0.5498 12.542 12.542 0 0 1-1.8692 0.1631c-0.2929 0.0068-0.5996 0.0107-0.8974 0.0107l-1.084 2e-3z"/>
|
|
43
|
+
<g data-name="<Group>">
|
|
44
|
+
<g fill="#fff" data-name="<Group>">
|
|
45
|
+
<path id="_Path_" d="m24.769 20.301a4.9488 4.9488 0 0 1 2.3566-4.1521 5.0657 5.0657 0 0 0-3.9912-2.1577c-1.6792-0.17626-3.3072 1.0048-4.1629 1.0048-0.87227 0-2.1898-0.98733-3.6085-0.95814a5.3153 5.3153 0 0 0-4.4729 2.7279c-1.934 3.3484-0.49141 8.2695 1.3612 10.976 0.9269 1.3254 2.0102 2.8058 3.4276 2.7533 1.3871-0.05753 1.9051-0.88448 3.5794-0.88448 1.6588 0 2.1448 0.88448 3.591 0.8511 1.4884-0.02416 2.4261-1.3312 3.3205-2.6691a10.962 10.962 0 0 0 1.5184-3.0925 4.782 4.782 0 0 1-2.9192-4.3992z" data-name="<Path>"/>
|
|
46
|
+
<path d="m22.037 12.211a4.8725 4.8725 0 0 0 1.1145-3.4906 4.9575 4.9575 0 0 0-3.2076 1.6596 4.6363 4.6363 0 0 0-1.1437 3.3614 4.099 4.099 0 0 0 3.2368-1.5304z" data-name="<Path>"/>
|
|
47
|
+
</g>
|
|
48
|
+
</g>
|
|
49
|
+
<g fill="#fff">
|
|
50
|
+
<path d="m42.302 27.14h-4.7334l-1.1367 3.3564h-2.0049l4.4834-12.418h2.083l4.4834 12.418h-2.0391zm-4.2432-1.5488h3.752l-1.8496-5.4473h-0.05176z"/>
|
|
51
|
+
<path d="m55.16 25.97c0 2.8135-1.5059 4.6211-3.7783 4.6211a3.0693 3.0693 0 0 1-2.8486-1.584h-0.043v4.4844h-1.8584v-12.049h1.7989v1.5059h0.03418a3.2116 3.2116 0 0 1 2.8828-1.6006c2.2978 1e-5 3.8125 1.8164 3.8125 4.6221zm-1.9102 0c0-1.833-0.94727-3.0381-2.3926-3.0381-1.4199 0-2.375 1.2305-2.375 3.0381 0 1.8242 0.95508 3.0459 2.375 3.0459 1.4453 0 2.3926-1.1963 2.3926-3.0459z"/>
|
|
52
|
+
<path d="m65.125 25.97c0 2.8135-1.5059 4.6211-3.7783 4.6211a3.0693 3.0693 0 0 1-2.8486-1.584h-0.043v4.4844h-1.8584v-12.049h1.7988v1.5059h0.03418a3.2116 3.2116 0 0 1 2.8828-1.6006c2.2979 0 3.8125 1.8164 3.8125 4.6221zm-1.9102 0c0-1.833-0.94727-3.0381-2.3926-3.0381-1.4199 0-2.375 1.2305-2.375 3.0381 0 1.8242 0.95508 3.0459 2.375 3.0459 1.4453 0 2.3926-1.1963 2.3926-3.0459z"/>
|
|
53
|
+
<path d="m71.71 27.036c0.1377 1.2314 1.334 2.04 2.9688 2.04 1.5664 0 2.6934-0.80859 2.6934-1.919 0-0.96387-0.67969-1.541-2.2891-1.9365l-1.6094-0.3877c-2.2803-0.55078-3.3389-1.6172-3.3389-3.3477 0-2.1426 1.8672-3.6143 4.5186-3.6143 2.624 0 4.4228 1.4717 4.4834 3.6143h-1.876c-0.1123-1.2393-1.1367-1.9873-2.6338-1.9873s-2.5215 0.75684-2.5215 1.8584c0 0.87793 0.6543 1.3945 2.2549 1.79l1.3682 0.33594c2.5478 0.60254 3.6064 1.626 3.6064 3.4424 0 2.3232-1.8506 3.7783-4.794 3.7783-2.7539 0-4.6133-1.4209-4.7334-3.667z"/>
|
|
54
|
+
<path d="m83.346 19.3v2.1426h1.7217v1.4717h-1.7217v4.9912c0 0.77539 0.34473 1.1367 1.1016 1.1367a5.8075 5.8075 0 0 0 0.61133-0.043v1.4629a5.1035 5.1035 0 0 1-1.0322 0.08594c-1.833 0-2.5478-0.68848-2.5478-2.4443v-5.1894h-1.3164v-1.4717h1.3164v-2.1426z"/>
|
|
55
|
+
<path d="m86.065 25.97c0-2.8486 1.6777-4.6387 4.294-4.6387 2.625 0 4.2949 1.79 4.2949 4.6387 0 2.8564-1.6611 4.6387-4.2949 4.6387-2.6329 0-4.294-1.7822-4.294-4.6387zm6.6953 0c0-1.9541-0.89551-3.1074-2.4014-3.1074s-2.4004 1.1621-2.4004 3.1074c0 1.9619 0.89453 3.1064 2.4004 3.1064s2.4013-1.1445 2.4013-3.1064z"/>
|
|
56
|
+
<path d="m96.186 21.442h1.7725v1.541h0.043a2.1594 2.1594 0 0 1 2.1777-1.6357 2.8662 2.8662 0 0 1 0.63672 0.06934v1.7383a2.5979 2.5979 0 0 0-0.835-0.1123 1.8726 1.8726 0 0 0-1.9365 2.083v5.3701h-1.8584z"/>
|
|
57
|
+
<path d="m109.38 27.837c-0.25 1.6436-1.8506 2.7715-3.8984 2.7715-2.6338 0-4.2686-1.7646-4.2686-4.5957 0-2.8398 1.6436-4.6816 4.1904-4.6816 2.5049 0 4.0801 1.7207 4.0801 4.4658v0.63672h-6.3945v0.1123a2.358 2.358 0 0 0 2.4356 2.5644 2.0483 2.0483 0 0 0 2.0908-1.2734zm-6.2822-2.7022h4.5264a2.1773 2.1773 0 0 0-2.2207-2.2978 2.292 2.292 0 0 0-2.3057 2.2979z"/>
|
|
58
|
+
</g>
|
|
59
|
+
<text x="33.771507" y="14.804743" fill="#ffffff" font-family="Arial" font-size="8.5px" letter-spacing=".5px" xml:space="preserve"><tspan x="33.771507" y="14.804743">${text}</tspan></text>
|
|
60
|
+
</svg>`
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { google, apple } from './badges.js'
|
|
2
|
+
import { NAVIGATION_CLOSE } from '#acinguiux-preact/main/shared/icons.js'
|
|
3
|
+
import { encodeQR } from 'qr'
|
|
4
|
+
|
|
5
|
+
const { h, t, register, matter, preactHooks } = globalThis.ami
|
|
6
|
+
const { useState, useMemo } = preactHooks
|
|
7
|
+
const { Box, Heading, Link, SVG, Popup, Button } = matter
|
|
8
|
+
|
|
9
|
+
function StoreBadges ({
|
|
10
|
+
title,
|
|
11
|
+
text,
|
|
12
|
+
'app-store-link': appStoreLink,
|
|
13
|
+
'play-store-link': playStoreLink,
|
|
14
|
+
}) {
|
|
15
|
+
return h(Box, { className: 'rounded-2xl bg-bga text-txa h-full' },
|
|
16
|
+
title && h(Heading, { _level: 3, _align: 'center' }, title),
|
|
17
|
+
text && h('p', { className: 'text-center' }, text),
|
|
18
|
+
h('div', { className: 'flex gap-5 justify-center max-h-16' },
|
|
19
|
+
h(StoreLink, {
|
|
20
|
+
name: t('Download on the {0}', ''),
|
|
21
|
+
value: appStoreLink,
|
|
22
|
+
'aria-label': t('Download on the {0}', 'App Store'),
|
|
23
|
+
iconFunc: apple
|
|
24
|
+
}),
|
|
25
|
+
h(StoreLink, {
|
|
26
|
+
name: t('Get it on {0}', ''),
|
|
27
|
+
value: playStoreLink,
|
|
28
|
+
'aria-label': t('Get it on {0}', 'Google Play'),
|
|
29
|
+
iconFunc: google
|
|
30
|
+
})
|
|
31
|
+
)
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function StoreLink ({ name, value, 'aria-label': ariaLabel, iconFunc }) {
|
|
36
|
+
const popupTitle = t('Scan the QR code to download the app or click the link below')
|
|
37
|
+
const [showPopup, setShowPopup] = useState(false)
|
|
38
|
+
const isMobile = useMemo(() => /iPad|iPhone|iPod|Android/.test(navigator.userAgent), [])
|
|
39
|
+
const qrCode = useMemo(() => value ? encodeQR(value, 'svg', { ecc: 'low' }) : null, [value])
|
|
40
|
+
|
|
41
|
+
if (isMobile || !value) {
|
|
42
|
+
return h(Link, { _model: { name, value }, 'aria-label': ariaLabel, className: 'h-16' },
|
|
43
|
+
h(SVG, { _tall: true, _model: { src: iconFunc(name) } })
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return [
|
|
48
|
+
h('button', {
|
|
49
|
+
className: 'clickable cursor-pointer h-16',
|
|
50
|
+
'aria-label': ariaLabel,
|
|
51
|
+
'aria-haspopup': 'dialog',
|
|
52
|
+
type: 'button',
|
|
53
|
+
onClick: () => {
|
|
54
|
+
setShowPopup(true)
|
|
55
|
+
},
|
|
56
|
+
children: h(SVG, { _tall: true, _model: { src: iconFunc(name) } }),
|
|
57
|
+
}),
|
|
58
|
+
h(Popup, {
|
|
59
|
+
_show: showPopup,
|
|
60
|
+
_layout: 'center',
|
|
61
|
+
// Synchronise state with native popup open/close.
|
|
62
|
+
onBeforeToggle: event => setShowPopup(event.newState === 'open'),
|
|
63
|
+
children: [
|
|
64
|
+
h('div', { className: 'flex gap-2' },
|
|
65
|
+
h('div', { className: 'shrink-0 grow-0 order-last' },
|
|
66
|
+
h(Button, {
|
|
67
|
+
_variant: 'plain',
|
|
68
|
+
_textless: true,
|
|
69
|
+
_size: 'xs',
|
|
70
|
+
_model: {
|
|
71
|
+
name: t('Dismiss'),
|
|
72
|
+
icon: NAVIGATION_CLOSE
|
|
73
|
+
},
|
|
74
|
+
onClick: event => {
|
|
75
|
+
event.preventDefault()
|
|
76
|
+
setShowPopup(false)
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
),
|
|
80
|
+
h(Heading, { _level: 3 }, popupTitle)
|
|
81
|
+
),
|
|
82
|
+
qrCode && h('div', { style: 'fill: currentColor', className: 'm-auto w-4/5' },
|
|
83
|
+
h(SVG, { _model: { src: qrCode, alt: popupTitle } })
|
|
84
|
+
),
|
|
85
|
+
h('div',
|
|
86
|
+
h(Link, { _variant: 'underline', _model: { name: ariaLabel, value } })
|
|
87
|
+
)
|
|
88
|
+
]
|
|
89
|
+
})
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
register(StoreBadges, 'store-badges')
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#404040" class="block w-full h-full"><path fill-rule="evenodd" clip-rule="evenodd" d="M12 12c2.213 0 4-1.787 4-4s-1.787-4-4-4-4 1.787-4 4 1.787 4 4 4Zm0 2c-2.667 0-8 1.61-8 4.537v.963a.5.5 0 0 0 .5.5h15a.5.5 0 0 0 .5-.5v-.963C20 15.61 14.667 14 12 14Z"></path></svg>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const { h, register, matter, MEDIUM } = globalThis.ami
|
|
2
|
+
const { Button } = matter
|
|
3
|
+
|
|
4
|
+
const DEFAULT_POSITION = 'absolute'
|
|
5
|
+
|
|
6
|
+
function TopbarButton ({ label, href, icon, position }) {
|
|
7
|
+
return h('div', {
|
|
8
|
+
className: `top-2 ${position ?? DEFAULT_POSITION} z-10`,
|
|
9
|
+
style: 'inset-inline-end: max(8px, calc((100vw - var(--page-width)) / 2))',
|
|
10
|
+
children: h(Button, {
|
|
11
|
+
_size: 'xs',
|
|
12
|
+
_style: id => `
|
|
13
|
+
@media screen and (max-width: ${MEDIUM - 1}px) {
|
|
14
|
+
${id} > *:first-child { display: none }
|
|
15
|
+
}
|
|
16
|
+
`,
|
|
17
|
+
_model: { name: label, value: href, icon },
|
|
18
|
+
}),
|
|
19
|
+
})
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
register(TopbarButton, 'topbar-button')
|