wineater-bot 4.0.0 → 4.1.0

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.
@@ -2,17 +2,21 @@ import { wineaterApi } from "../api/api";
2
2
  import type { CurrencyCode, LanguageCode } from "../i18n/i18n";
3
3
  import type { StoreConfig } from "./types";
4
4
  import { deserializeStoreConfig } from "./deserialize";
5
+ import type { ProjectUiConfig } from "../ui-config/types";
6
+ import { getProjectUiConfig } from "../ui-config/get-config";
5
7
 
6
8
  export type AppState = {
7
9
  storeConfig: StoreConfig | null;
8
10
  currentLanguage: LanguageCode;
9
11
  isConfigLoaded: boolean;
12
+ uiConfig: ProjectUiConfig;
10
13
  };
11
14
 
12
15
  let state = $state<AppState>({
13
16
  storeConfig: null,
14
17
  currentLanguage: 'en',
15
18
  isConfigLoaded: false,
19
+ uiConfig: null,
16
20
  });
17
21
 
18
22
  export const appStore = {
@@ -64,6 +68,7 @@ export const appStore = {
64
68
  // fallback to store default language
65
69
  this.setStoreLanguage(state.storeConfig.lang as LanguageCode);
66
70
  }
71
+ this.setUiConfig(getProjectUiConfig(state.storeConfig.id));
67
72
 
68
73
  state.isConfigLoaded = true;
69
74
  } catch (error) {
@@ -74,4 +79,10 @@ export const appStore = {
74
79
  isInitialized(): boolean {
75
80
  return state.isConfigLoaded;
76
81
  },
82
+ getUiConfig(): ProjectUiConfig {
83
+ return state.uiConfig;
84
+ },
85
+ setUiConfig(uiConfig: ProjectUiConfig) {
86
+ state.uiConfig = uiConfig;
87
+ }
77
88
  }
@@ -0,0 +1,22 @@
1
+ import { projectConfigs } from "./projects-config";
2
+ import { UiConfig } from "./types";
3
+
4
+ export function getProjectUiConfig(projectId: string): UiConfig {
5
+ const defaultConfig = {
6
+ logoUrl: null,
7
+ brandColor: "#7B2BEB",
8
+ wineaterColor: "#7B2BEB",
9
+ customCss: `
10
+ @import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,200..800&display=swap');
11
+ :root { --wineater-font-primary: 'Bricolage Grotesque', serif; }
12
+ `
13
+ };
14
+
15
+ const projectConfig = projectConfigs[projectId] || {};
16
+
17
+ // Merge default config with project-specific config if available
18
+ return {
19
+ ...defaultConfig,
20
+ ...projectConfig,
21
+ }
22
+ }
@@ -0,0 +1,62 @@
1
+ import type { ProjectUiConfig } from "./types";
2
+
3
+ export const projectConfigs: Record<string, ProjectUiConfig> = {
4
+ "0": {
5
+ logoUrl: null,
6
+ brandColor: "#7B2BEB",
7
+ },
8
+ "25": {
9
+ logoUrl: null,
10
+ brandColor: "#7B2BEB",
11
+ buttonUppercase: true,
12
+ customCss: `
13
+ @import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap');
14
+ :root { --wineater-font-primary: 'Roboto', sans-serif; }
15
+ #wr-Custom {
16
+ .wr-Search-input {
17
+ border-color: #7c7c7c;
18
+ color: #7c7c7c;
19
+ }
20
+ .wr-Search-input::placeholder { color: #000000; }
21
+ .wr-Search-button {
22
+ background: #000000;
23
+ }
24
+ .wr-Search-button:hover {
25
+ background: #E3BE8D;
26
+ opacity: 1;
27
+ }
28
+
29
+ .wr-WineTile-params {
30
+ color: #7c7c7c;
31
+ }
32
+
33
+ .wr-WineTilePopup-reason {
34
+ color: #000000;
35
+ }
36
+
37
+ .wr-WineTilePopup-tag {
38
+ color: #000000;
39
+ background: rgba(239,239,239,0.7);
40
+ border-color: transparent;
41
+ }
42
+
43
+ .wr-WineTile-action {
44
+ color: #000000;
45
+ border-color: #000000;
46
+ background: transparent;
47
+ }
48
+
49
+ .wr-WineTile-action:hover {
50
+ background: #000000;
51
+ color: #ffffff;
52
+ box-shadow: none;
53
+ }
54
+ }
55
+ `,
56
+ translations: {
57
+ fr: {
58
+ "wineDetails.buy": "voir plus"
59
+ }
60
+ }
61
+ }
62
+ };
@@ -0,0 +1,13 @@
1
+ import { LanguageCode } from "../i18n/i18n";
2
+
3
+ export type ProjectId = string;
4
+ export type ProjectUiConfig = {
5
+ logoUrl: string | null;
6
+ brandColor: string;
7
+ customCss?: string | null;
8
+ buttonUppercase?: boolean;
9
+ translations?: Partial<Record<LanguageCode, Record<string, string>>>;
10
+ }
11
+ export type UiConfig = ProjectUiConfig & {
12
+ wineaterColor: string;
13
+ }
@@ -0,0 +1,12 @@
1
+ export function generateInlineStyle(cssString: string | null): string {
2
+ if (!cssString) {
3
+ return '';
4
+ }
5
+ const styleId = "custom-ui-config-style";
6
+ if (document.getElementById(styleId)) return;
7
+ const style = document.createElement('style');
8
+ style.id = styleId;
9
+ style.innerHTML = cssString;
10
+ document.head.appendChild(style);
11
+ return styleId;
12
+ }