diff --git a/assets/scss/bootstrap.scss b/assets/scss/bootstrap.scss index 0fe2e19..618de76 100644 --- a/assets/scss/bootstrap.scss +++ b/assets/scss/bootstrap.scss @@ -37,6 +37,7 @@ @import "bootstrap/scss/modal"; @import "bootstrap/scss/accordion"; @import "bootstrap/scss/toasts"; +@import "bootstrap/scss/badge"; // 6. Optionally include utilities API last to generate classes based on the Sass map in `_utilities.scss` @import "bootstrap/scss/utilities/api"; diff --git a/assets/scss/style.scss b/assets/scss/style.scss index 10796ff..bc7cf67 100644 --- a/assets/scss/style.scss +++ b/assets/scss/style.scss @@ -1,6 +1,8 @@ @import "./variables"; @import "./bootstrap"; @import "./sweetalert-custom"; +@import 'animate.css'; + // * App @import "./layout"; diff --git a/classes/AppState.ts b/classes/AppState.ts index d634cc5..25bce88 100644 --- a/classes/AppState.ts +++ b/classes/AppState.ts @@ -4,9 +4,6 @@ export default class AppState { /** Json data as exported from zip and compliant with schemas */ private jsonData: TypeApp; - /** The selected brand */ - private selectedBrand: TypeBrand | null = null; - constructor(jsonData: TypeApp) { this.jsonData = jsonData; } @@ -47,7 +44,7 @@ export default class AppState { } return brandItem; }); - return ranges; + return ranges.sort((rangeA, rangeB) => rangeA.order - rangeB.order); } public range(slug:string): TypeRange|undefined { diff --git a/classes/ToolboxHelper.ts b/classes/ToolboxHelper.ts new file mode 100644 index 0000000..f7b84b1 --- /dev/null +++ b/classes/ToolboxHelper.ts @@ -0,0 +1,33 @@ +export default class ToolboxHelper { + /** + * Get the contrast for any color + * + * @param hexcolor An HTML Hex color + * @returns + */ + public static getContrastYIQ(hexcolor: string): "#000000"|"#FFFFFF" { + const r = parseInt(hexcolor.substring(1,3),16); + const g = parseInt(hexcolor.substring(3,5),16); + const b = parseInt(hexcolor.substring(5,7),16); + const yiq = ((r*299)+(g*587)+(b*114))/1000; + return (yiq >= 128) ? "#000000" : "#FFFFFF"; + } + + /** + * Convert HTML Hex color to RGBA + * + * @param hexcolor An HTML Hex color + * @param alpha The transparency to apply + * @returns + */ + public static toRGBA(hexcolor: string, alpha: number = 1): string { + const r = parseInt(hexcolor.substring(1,3),16); + const g = parseInt(hexcolor.substring(3,5),16); + const b = parseInt(hexcolor.substring(5,7),16); + return `rgba(${r}, ${g}, ${b}, ${alpha})`; + } + + public static randomInteger(min: number, max: number): number { + return Math.floor(Math.random() * (max - min + 1)) + min; + } +} diff --git a/index.d.ts b/index.d.ts index 1f589a6..ad237d8 100644 --- a/index.d.ts +++ b/index.d.ts @@ -29,9 +29,21 @@ type SettingsModel = { updated_at: string; }; +/** A font from Showroom Bo */ +type FontModel = { + /** The unique identifier for a font */ + id: number; + /** Nom de la marque */ + font_name: string; + /** Chemin vers fichier de la font, chemin tel que présent dans le zip*/ + font: string; + created_at: string; + updated_at: string; +}; + /** A brand from Showroom Bo */ type BrandModel = { - /** The unique identifier for a product */ + /** The unique identifier for a brand */ id: number; /** Nom de la marque */ name: string; @@ -56,8 +68,16 @@ type RangeModel = { slug: string; /** Logo de la gamme, chemin tel que présent dans le zip */ picture: string; + /** Couleur de la gamme */ + color: string; + /** Largeur de la gamme 1 colonne ou 2 colonnes (pleine largeur)e */ + width: number; + /** Ordre d'affichage de la gamme */ + order: number; /** Clé étrangère de la marque */ brand_id: number; + /** Clé étrangère de la police */ + font_id: number; created_at: string; updated_at: string; products: Array; diff --git a/nuxt.config.ts b/nuxt.config.ts index 5c03061..278b793 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -54,6 +54,7 @@ export default defineNuxtConfig({ // Global CSS: https://go.nuxtjs.dev/config-css css: ["~/assets/scss/style.scss", "@fortawesome/fontawesome-svg-core/styles.css"], plugins: [ + { src: "~/plugins/toolboxhelper.ts", mode: "client" }, { src: "~/plugins/boostrap.ts", mode: "client" }, { src: "~/plugins/fontawesome.ts", mode: "client" }, { src: "~/plugins/localStorage.ts", mode: "client" }, diff --git a/package-lock.json b/package-lock.json index edb4e2b..983ca16 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,6 +25,7 @@ "adm-zip": "^0.5.10", "ajv": "^8.12.0", "ajv-formats": "^2.1.1", + "animate.css": "^4.1.1", "bootstrap": "^5.3.2", "dompurify": "^3.0.6", "electron": "^28.1.1", @@ -5314,6 +5315,12 @@ } } }, + "node_modules/animate.css": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/animate.css/-/animate.css-4.1.1.tgz", + "integrity": "sha512-+mRmCTv6SbCmtYJCN4faJMNFVNN5EuCTTprDTAo7YzIGji2KADmakjVA3+8mVDkZ2Bf09vayB35lSQIex2+QaQ==", + "dev": true + }, "node_modules/ansi-colors": { "version": "4.1.3", "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", diff --git a/package.json b/package.json index 0795e29..56903c7 100755 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "adm-zip": "^0.5.10", "ajv": "^8.12.0", "ajv-formats": "^2.1.1", + "animate.css": "^4.1.1", "bootstrap": "^5.3.2", "dompurify": "^3.0.6", "electron": "^28.1.1", diff --git a/pages/brands/[slug].vue b/pages/brands/[slug].vue index f3efdd9..c84893b 100644 --- a/pages/brands/[slug].vue +++ b/pages/brands/[slug].vue @@ -1,8 +1,15 @@