From ee28a9858d7c29eac76ef18090d171f3e2e1deaf Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Pasquier <contact@jbpasquier.eu> Date: Tue, 27 Feb 2024 11:40:40 +0100 Subject: [PATCH] chore: cleanup repository --- src/components/badge-firstnationsled.js | 44 ------------------- src/{solid-ofn-rpp.js => components/main.js} | 13 +++--- src/components/multiple-badge-list.js | 41 ----------------- src/components/partials/wholesale-buy.js | 2 +- .../widgets/badge-firstnationsled.js | 41 +++++++++++++++++ .../widgets/display-firstnationsled.js | 18 ++++++++ src/components/widgets/multiple-badge-list.js | 38 ++++++++++++++++ .../{ => widgets}/multiple-badge-small.js | 6 +-- .../{ => widgets}/multiple-badge.js | 6 +-- .../{ => widgets}/safe-html-value-short.js | 3 +- .../{ => widgets}/safe-html-value.js | 3 +- .../{ => widgets}/search-firstnationsled.js | 4 +- src/components/{ => widgets}/social-links.js | 4 +- src/{ => helpers}/utils.js | 0 src/index.js | 26 +++++------ vite.config.js | 9 ++++ 16 files changed, 135 insertions(+), 123 deletions(-) delete mode 100644 src/components/badge-firstnationsled.js rename src/{solid-ofn-rpp.js => components/main.js} (98%) delete mode 100644 src/components/multiple-badge-list.js create mode 100644 src/components/widgets/badge-firstnationsled.js create mode 100644 src/components/widgets/display-firstnationsled.js create mode 100644 src/components/widgets/multiple-badge-list.js rename src/components/{ => widgets}/multiple-badge-small.js (82%) rename src/components/{ => widgets}/multiple-badge.js (82%) rename src/components/{ => widgets}/safe-html-value-short.js (73%) rename src/components/{ => widgets}/safe-html-value.js (77%) rename src/components/{ => widgets}/search-firstnationsled.js (91%) rename src/components/{ => widgets}/social-links.js (92%) rename src/{ => helpers}/utils.js (100%) diff --git a/src/components/badge-firstnationsled.js b/src/components/badge-firstnationsled.js deleted file mode 100644 index 421324b..0000000 --- a/src/components/badge-firstnationsled.js +++ /dev/null @@ -1,44 +0,0 @@ -import { LitElement, css, html } from "lit"; - -import("../utils.js").then((utils) => { - // Custom widget for First Nations Led - customElements.define( - "custom-badge-firstnationsled", - class extends LitElement { - constructor() { - super(); - } - static properties = { - value: { attribute: "value" }, - }; - static styles = css` - div { - display: inline-block; - font-size: 12px; - font-weight: 600; - line-height: 16px; - height: auto; - text-align: left; - background-color: #ede7e2; - color: #191c1d; - border-radius: 41px; - text-transform: uppercase; - padding: 4px; - padding-right: 12px; - margin-right: 6px; - margin-bottom: 6px; - background-image: url(/Australian_Aboriginal_Flag.png); - background-repeat: no-repeat; - background-size: 31px 15px; - padding-left: 50px; - background-position: 12px; - } - `; - render() { - return html`${this.value.length > 0 - ? html`<div>First Nations Led</div>` - : ""}`; - } - } - ); -}); diff --git a/src/solid-ofn-rpp.js b/src/components/main.js similarity index 98% rename from src/solid-ofn-rpp.js rename to src/components/main.js index 4cad0c8..aa22ed6 100644 --- a/src/solid-ofn-rpp.js +++ b/src/components/main.js @@ -1,6 +1,6 @@ import { LitElement, html, unsafeCSS } from "lit"; -import makeExpand from './helpers/expand.js'; -import style from "./styles/index.scss?inline"; +import makeExpand from '@helpers/expand.js'; +import style from "@styles/index.scss?inline"; import "~icons/mdi/home-silo"; import "~icons/mdi/food-apple"; import "~icons/mdi/open-in-new"; @@ -10,7 +10,7 @@ import "~icons/mdi/linkedin"; import "~icons/mdi/whatsapp"; import "~icons/mdi/email-outline"; -import("./utils.js").then((utils) => { +import("@helpers/utils.js").then((utils) => { import(/* @vite-ignore */ utils.coreVersion()).then((core) => { const expand = makeExpand(core, utils); @@ -674,11 +674,8 @@ import("./utils.js").then((utils) => { <div class="row"> <solid-display bind-resources="" - required-ofn:first_nations_country="" - fields="title, fnc(ofn:First_Nations_country)" - value-title="First Nation Country" - class-title="col s12 text-14 bold" - class-fnc="col s12 text-14" + fields="ofn:First_Nations_country" + widget-ofn:First_Nations_country="custom-display-firstnationsled" ></solid-display> </div> <div class="row text-link valign-wrapper"> diff --git a/src/components/multiple-badge-list.js b/src/components/multiple-badge-list.js deleted file mode 100644 index 6fd70a6..0000000 --- a/src/components/multiple-badge-list.js +++ /dev/null @@ -1,41 +0,0 @@ -import { LitElement, css, html } from "lit"; - -import("../utils.js").then((utils) => { - // Custom widget for badges (simple array) - customElements.define( - "custom-multiple-badge-list", - class extends LitElement { - constructor() { - super(); - } - static properties = { - value: { attribute: "value" }, - }; - static styles = css` - div { - display: inline-block; - font-size: 12px; - font-weight: 600; - line-height: 16px; - height: auto; - text-align: left; - background-color: #ede7e2; - color: #191c1d; - border-radius: 41px; - text-transform: uppercase; - padding: 4px; - padding-left: 12px; - padding-right: 12px; - margin-right: 6px; - margin-bottom: 6px; - } - `; - render() { - const badges = this.value.replace(/[\[\]\"]/g, "").split(","); - return html`${badges.map((chip) => - chip.length > 0 ? html`<div>${chip}</div>` : "" - )}`; - } - } - ); -}); diff --git a/src/components/partials/wholesale-buy.js b/src/components/partials/wholesale-buy.js index fd460cf..8d33259 100644 --- a/src/components/partials/wholesale-buy.js +++ b/src/components/partials/wholesale-buy.js @@ -3,7 +3,7 @@ import { Task } from "@lit/task"; import "~icons/mdi/phone-in-talk"; import "~icons/mdi/open-in-new"; -import("../../utils.js").then((utils) => { +import("@helpers/utils.js").then((utils) => { import(/* @vite-ignore */ utils.coreVersion()).then((core) => { // Custom widget for wholesale customElements.define( diff --git a/src/components/widgets/badge-firstnationsled.js b/src/components/widgets/badge-firstnationsled.js new file mode 100644 index 0000000..f67f43f --- /dev/null +++ b/src/components/widgets/badge-firstnationsled.js @@ -0,0 +1,41 @@ +import { LitElement, css, html } from "lit"; + +customElements.define( + "custom-badge-firstnationsled", + class extends LitElement { + constructor() { + super(); + } + static properties = { + value: { attribute: "value" }, + }; + static styles = css` + div { + display: inline-block; + font-size: 12px; + font-weight: 600; + line-height: 16px; + height: auto; + text-align: left; + background-color: #ede7e2; + color: #191c1d; + border-radius: 41px; + text-transform: uppercase; + padding: 4px; + padding-right: 12px; + margin-right: 6px; + margin-bottom: 6px; + background-image: url(/Australian_Aboriginal_Flag.png); + background-repeat: no-repeat; + background-size: 31px 15px; + padding-left: 50px; + background-position: 12px; + } + `; + render() { + return html`${this.value.length > 0 + ? html`<div>First Nations Led</div>` + : ""}`; + } + } +); diff --git a/src/components/widgets/display-firstnationsled.js b/src/components/widgets/display-firstnationsled.js new file mode 100644 index 0000000..0c7cb50 --- /dev/null +++ b/src/components/widgets/display-firstnationsled.js @@ -0,0 +1,18 @@ +import { LitElement, html } from "lit"; + +customElements.define( + "custom-display-firstnationsled", + class extends LitElement { + constructor() { + super(); + } + static properties = { + value: { attribute: "value" }, + }; + render() { + return html`${this.value.length > 0 + ? html`<div class="col s12 text-14 bold">First Nations Led</div><div class="col s12 text-14">${this.value}</div>` + : ""}`; + } + } +); diff --git a/src/components/widgets/multiple-badge-list.js b/src/components/widgets/multiple-badge-list.js new file mode 100644 index 0000000..c1fcfb2 --- /dev/null +++ b/src/components/widgets/multiple-badge-list.js @@ -0,0 +1,38 @@ +import { LitElement, css, html } from "lit"; + +customElements.define( + "custom-multiple-badge-list", + class extends LitElement { + constructor() { + super(); + } + static properties = { + value: { attribute: "value" }, + }; + static styles = css` + div { + display: inline-block; + font-size: 12px; + font-weight: 600; + line-height: 16px; + height: auto; + text-align: left; + background-color: #ede7e2; + color: #191c1d; + border-radius: 41px; + text-transform: uppercase; + padding: 4px; + padding-left: 12px; + padding-right: 12px; + margin-right: 6px; + margin-bottom: 6px; + } + `; + render() { + const badges = this.value.replace(/[\[\]\"]/g, "").split(","); + return html`${badges.map((chip) => + chip.length > 0 ? html`<div>${chip}</div>` : "" + )}`; + } + } +); diff --git a/src/components/multiple-badge-small.js b/src/components/widgets/multiple-badge-small.js similarity index 82% rename from src/components/multiple-badge-small.js rename to src/components/widgets/multiple-badge-small.js index 6a783e7..5d94873 100644 --- a/src/components/multiple-badge-small.js +++ b/src/components/widgets/multiple-badge-small.js @@ -1,9 +1,9 @@ -import makeExpand from '../helpers/expand.js'; +import makeExpand from '@helpers/expand.js'; -import("../utils.js").then((utils) => { +import("@helpers/utils.js").then((utils) => { import(/* @vite-ignore */ utils.coreVersion()).then((core) => { const expand = makeExpand(core, utils); - // Custom widget for badges (from ldp container) + core.Sib.register({ name: "custom-multiple-badge-small", use: [core.StoreMixin], diff --git a/src/components/multiple-badge.js b/src/components/widgets/multiple-badge.js similarity index 82% rename from src/components/multiple-badge.js rename to src/components/widgets/multiple-badge.js index 6283462..9c7bea6 100644 --- a/src/components/multiple-badge.js +++ b/src/components/widgets/multiple-badge.js @@ -1,9 +1,9 @@ -import makeExpand from '../helpers/expand.js'; +import makeExpand from '@helpers/expand.js'; -import("../utils.js").then((utils) => { +import("@helpers/utils.js").then((utils) => { import(/* @vite-ignore */ utils.coreVersion()).then((core) => { const expand = makeExpand(core, utils); - // Custom widget for badges (from ldp container) + core.Sib.register({ name: "custom-multiple-badge", use: [core.StoreMixin], diff --git a/src/components/safe-html-value-short.js b/src/components/widgets/safe-html-value-short.js similarity index 73% rename from src/components/safe-html-value-short.js rename to src/components/widgets/safe-html-value-short.js index 1472e3e..063b90e 100644 --- a/src/components/safe-html-value-short.js +++ b/src/components/widgets/safe-html-value-short.js @@ -1,7 +1,6 @@ import { LitElement, html } from "lit"; -import("../utils.js").then((utils) => { - // Custom widget for producer description, original contains some unsafe html, truncated +import("@helpers/utils.js").then((utils) => { customElements.define( "custom-safe-html-value-short", class extends LitElement { diff --git a/src/components/safe-html-value.js b/src/components/widgets/safe-html-value.js similarity index 77% rename from src/components/safe-html-value.js rename to src/components/widgets/safe-html-value.js index 4add98b..f5f6d4e 100644 --- a/src/components/safe-html-value.js +++ b/src/components/widgets/safe-html-value.js @@ -1,8 +1,7 @@ import { LitElement, html } from "lit"; import { unsafeHTML } from 'lit/directives/unsafe-html.js'; -import("../utils.js").then((utils) => { - // Custom widget for producer description, original contains some unsafe html +import("@helpers/utils.js").then((utils) => { customElements.define( "custom-safe-html-value", class extends LitElement { diff --git a/src/components/search-firstnationsled.js b/src/components/widgets/search-firstnationsled.js similarity index 91% rename from src/components/search-firstnationsled.js rename to src/components/widgets/search-firstnationsled.js index 9e2f84a..f2feb5c 100644 --- a/src/components/search-firstnationsled.js +++ b/src/components/widgets/search-firstnationsled.js @@ -1,6 +1,6 @@ -import { LitElement, css, html } from "lit"; +import { LitElement, html } from "lit"; -import("../utils.js").then((utils) => { +import("@helpers/utils.js").then((utils) => { // Custom widget for filtering First Nations Led customElements.define( "custom-search-firstnationsled", diff --git a/src/components/social-links.js b/src/components/widgets/social-links.js similarity index 92% rename from src/components/social-links.js rename to src/components/widgets/social-links.js index cb4db68..edd6f76 100644 --- a/src/components/social-links.js +++ b/src/components/widgets/social-links.js @@ -1,6 +1,6 @@ -import makeExpand from '../helpers/expand.js'; +import makeExpand from '@helpers/expand.js'; -import("../utils.js").then((utils) => { +import("@helpers/utils.js").then((utils) => { import(/* @vite-ignore */ utils.coreVersion()).then((core) => { const expand = makeExpand(core, utils); // Custom widget for social media links diff --git a/src/utils.js b/src/helpers/utils.js similarity index 100% rename from src/utils.js rename to src/helpers/utils.js diff --git a/src/index.js b/src/index.js index acea4ac..8a60d89 100644 --- a/src/index.js +++ b/src/index.js @@ -1,16 +1,12 @@ import "materialize-css/dist/js/materialize.min.js"; - -import('./utils.js').then(utils => { - import(/* @vite-ignore */utils.coreVersion()).then(async (core) => { - await import("./components/safe-html-value.js"); - await import("./components/safe-html-value-short.js"); - await import("./components/multiple-badge-list.js"); - await import("./components/badge-firstnationsled.js"); - await import("./components/search-firstnationsled.js"); - await import("./components/multiple-badge.js"); - await import("./components/multiple-badge-small.js"); - await import("./components/social-links.js"); - await import("./components/partials/wholesale-buy.js"); - await import("./solid-ofn-rpp.js"); - }); -}); \ No newline at end of file +import "@widgets/badge-firstnationsled.js"; +import "@widgets/display-firstnationsled.js"; +import "@widgets/multiple-badge-list.js"; +import "@widgets/multiple-badge-small.js"; +import "@widgets/multiple-badge.js"; +import "@widgets/safe-html-value-short.js"; +import "@widgets/safe-html-value.js"; +import "@widgets/search-firstnationsled.js"; +import "@widgets/social-links.js"; +import "@partials/wholesale-buy.js"; +import "@components/main.js"; diff --git a/vite.config.js b/vite.config.js index 313e7e7..6ae274b 100644 --- a/vite.config.js +++ b/vite.config.js @@ -25,4 +25,13 @@ export default defineConfig({ }, }), ], + resolve: { + alias: { + "@components": "/src/components", + "@helpers": "/src/helpers", + "@partials": "/src/components/partials", + "@styles": "/src/styles", + "@widgets": "/src/components/widgets", + }, + }, }); -- GitLab