@cognigy/chat-components-vue 0.3.1 → 0.4.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.
package/dist/index.d.ts CHANGED
@@ -28,7 +28,7 @@ export { useLiveRegion } from './composables/useLiveRegion';
28
28
  export { DownloadIcon, CloseIcon, VideoPlayIcon, AudioPlayIcon, AudioPauseIcon, ArrowBackIcon, LinkIcon } from './assets/svg';
29
29
  export { match, getChannelPayload } from './utils/matcher';
30
30
  export { sanitizeHTMLWithConfig, sanitizeContent } from './utils/sanitize';
31
- export { configColorsToCssVariables, themeFontToCssVariable } from './utils/theme';
31
+ export { configColorsToCssVariables, themeFontToCssVariable, themeFontSizeToCssVariable } from './utils/theme';
32
32
  export { getWebchatButtonLabel, interpolateString, getRandomId, moveFocusToMessageFocusTarget, replaceUrlsWithHTMLanchorElem, getBackgroundImage, getFileName, getFileExtension, getSizeLabel, isImageAttachment, VALID_IMAGE_MIME_TYPES } from './utils/helpers';
33
33
  export type { ChatConfig, ChatSettings, ChatTheme, MessageProps, MessageSender, MessagePlugin, MessagePluginOptions, MessageContext, MessageParams, IMessage, IStreamingMessage, IWebchatButton, IWebchatQuickReply, IWebchatTemplateAttachment, IWebchatAttachmentElement, IWebchatAudioAttachment, IWebchatImageAttachment, IWebchatVideoAttachment, IUploadFileAttachmentData, IDatePickerData, IWebchatChannelPayload, } from './types';
34
34
  export type { TagVariant } from './components/common/Typography.vue';
@@ -189,6 +189,8 @@ export interface ChatTheme {
189
189
  textDark?: string;
190
190
  textLight?: string;
191
191
  fontFamily?: string;
192
+ /** Base font size for text scaling. All text sizes scale proportionally from this value. Default: '14px' */
193
+ fontSize?: string;
192
194
  }
193
195
  /**
194
196
  * Message sender callback type.
@@ -27,3 +27,15 @@ export declare function configColorsToCssVariables(colors?: ChatSettings['colors
27
27
  * @returns A record with the --cc-font-family CSS variable, or empty object
28
28
  */
29
29
  export declare function themeFontToCssVariable(theme?: ChatTheme): Record<string, string>;
30
+ /**
31
+ * Maps a ChatTheme's fontSize to the --cc-font-size CSS variable.
32
+ * Consumers can set this to scale all text proportionally.
33
+ *
34
+ * Components should reference font-size as:
35
+ * font-size: var(--cc-font-size, 14px); (for 14px base)
36
+ * font-size: calc(var(--cc-font-size, 14px) * 1.2857); (for 18px base)
37
+ *
38
+ * @param theme - The ChatTheme object
39
+ * @returns A record with the --cc-font-size CSS variable, or empty object
40
+ */
41
+ export declare function themeFontSizeToCssVariable(theme?: ChatTheme): Record<string, string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cognigy/chat-components-vue",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "description": "Vue 3 version of @cognigy/chat-components",
6
6
  "license": "MIT",
@@ -30,7 +30,7 @@ import {
30
30
  type Component,
31
31
  } from "vue";
32
32
  import { match } from "../utils/matcher";
33
- import {configColorsToCssVariables, themeFontToCssVariable} from "../utils/theme";
33
+ import {configColorsToCssVariables, themeFontToCssVariable, themeFontSizeToCssVariable} from "../utils/theme";
34
34
  import { provideMessageContext } from "../composables/useMessageContext";
35
35
  import { getMessageId, isMessagePlugin } from "../types";
36
36
  import type { MessageProps, MessageContext } from "../types";
@@ -157,6 +157,7 @@ const cssVariableStyle = computed(() => {
157
157
  return {
158
158
  ...configColorsToCssVariables(props.config?.settings?.colors),
159
159
  ...themeFontToCssVariable(props.theme),
160
+ ...themeFontSizeToCssVariable(props.theme),
160
161
  }
161
162
  });
162
163
  </script>
@@ -72,6 +72,7 @@ const bubbleStyle = computed((): CSSProperties => {
72
72
  margin-block-end: 12px;
73
73
  word-break: break-word;
74
74
  white-space: pre-wrap;
75
+ font-size: var(--cc-font-size, 14px);
75
76
  box-shadow: var(--cc-message-shadow, rgba(151, 124, 156, 0.1) 0px 5px 9px 0px,
76
77
  rgba(203, 195, 212, 0.1) 0px 5px 16px 0px,
77
78
  rgba(216, 212, 221, 0.1) 0px 8px 20px 0px);
@@ -6,15 +6,16 @@
6
6
  aria-live="assertive"
7
7
  >
8
8
  <div :class="styles.eventPillTextWrapper">
9
- <div :class="styles.eventText">
9
+ <Typography variant="title2-semibold" component="div">
10
10
  {{ text }}
11
- </div>
11
+ </Typography>
12
12
  </div>
13
13
  </div>
14
14
  </template>
15
15
 
16
16
  <script setup lang="ts">
17
17
  import { computed, useCssModule } from 'vue'
18
+ import Typography from './Typography.vue'
18
19
 
19
20
  /**
20
21
  * ChatEvent - Display chat event notifications
@@ -64,6 +65,7 @@ const eventClasses = computed(() => {
64
65
  gap: 10px;
65
66
  margin-inline: auto;
66
67
  margin-block-start: 40px;
68
+ font-family: var(--cc-font-family, 'Figtree', sans-serif);
67
69
  }
68
70
 
69
71
  .eventPillTextWrapper {
@@ -75,13 +77,4 @@ const eventClasses = computed(() => {
75
77
  rgba(203, 195, 212, 0.1) 0px 5px 16px 0px,
76
78
  rgba(216, 212, 221, 0.1) 0px 8px 20px 0px);
77
79
  }
78
-
79
- .eventText {
80
- /* Typography variant: title2-semibold equivalent */
81
- font-family: 'Figtree', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
82
- font-size: 14px;
83
- font-weight: 600;
84
- line-height: 1.4;
85
- margin: 0;
86
- }
87
80
  </style>
@@ -107,79 +107,79 @@ const componentStyle = computed(() => {
107
107
 
108
108
  <style module>
109
109
  .h1-semibold {
110
- font-size: 2.125rem; /* 34px */
110
+ font-size: calc(var(--cc-font-size, 14px) * 2.4286); /* 34px at 14px base */
111
111
  font-style: normal;
112
112
  font-weight: 600;
113
- line-height: 2.55rem; /* 40.8px */
113
+ line-height: calc(var(--cc-font-size, 14px) * 2.9143); /* 40.8px at 14px base */
114
114
  }
115
115
 
116
116
  .h2-regular {
117
- font-size: 1.125rem; /* 18px */
117
+ font-size: calc(var(--cc-font-size, 14px) * 1.2857); /* 18px at 14px base */
118
118
  font-style: normal;
119
119
  font-weight: 400;
120
- line-height: 1.4625rem; /* 23.4px */
120
+ line-height: calc(var(--cc-font-size, 14px) * 1.6714); /* 23.4px at 14px base */
121
121
  }
122
122
 
123
123
  .h2-semibold {
124
- font-size: 1.125rem; /* 18px */
124
+ font-size: calc(var(--cc-font-size, 14px) * 1.2857); /* 18px at 14px base */
125
125
  font-style: normal;
126
126
  font-weight: 600;
127
- line-height: 1.4625rem; /* 23.4px */
127
+ line-height: calc(var(--cc-font-size, 14px) * 1.6714); /* 23.4px at 14px base */
128
128
  }
129
129
 
130
130
  .title1-regular {
131
- font-size: 1rem; /* 16px */
131
+ font-size: calc(var(--cc-font-size, 14px) * 1.1429); /* 16px at 14px base */
132
132
  font-style: normal;
133
133
  font-weight: 400;
134
- line-height: 1.4rem; /* 22.4px */
134
+ line-height: calc(var(--cc-font-size, 14px) * 1.6); /* 22.4px at 14px base */
135
135
  }
136
136
 
137
137
  .title1-semibold {
138
- font-size: 1rem; /* 16px */
138
+ font-size: calc(var(--cc-font-size, 14px) * 1.1429); /* 16px at 14px base */
139
139
  font-style: normal;
140
140
  font-weight: 600;
141
- line-height: 1.4rem; /* 22.4px */
141
+ line-height: calc(var(--cc-font-size, 14px) * 1.6); /* 22.4px at 14px base */
142
142
  }
143
143
 
144
144
  .title2-regular {
145
- font-size: 0.75rem; /* 12px */
145
+ font-size: calc(var(--cc-font-size, 14px) * 0.8571); /* 12px at 14px base */
146
146
  font-style: normal;
147
147
  font-weight: 400;
148
- line-height: 1.05rem; /* 16.8px */
148
+ line-height: calc(var(--cc-font-size, 14px) * 1.2); /* 16.8px at 14px base */
149
149
  }
150
150
 
151
151
  .title2-semibold {
152
- font-size: 0.75rem; /* 12px */
152
+ font-size: calc(var(--cc-font-size, 14px) * 0.8571); /* 12px at 14px base */
153
153
  font-style: normal;
154
154
  font-weight: 600;
155
- line-height: 0.975rem; /* 15.6px */
155
+ line-height: calc(var(--cc-font-size, 14px) * 1.1143); /* 15.6px at 14px base */
156
156
  }
157
157
 
158
158
  .body-regular {
159
- font-size: 0.875rem; /* 14px */
159
+ font-size: var(--cc-font-size, 14px); /* 14px base */
160
160
  font-style: normal;
161
161
  font-weight: 400;
162
- line-height: 1.225rem; /* 19.6px */
162
+ line-height: calc(var(--cc-font-size, 14px) * 1.4); /* 19.6px at 14px base */
163
163
  }
164
164
 
165
165
  .body-semibold {
166
- font-size: 0.875rem; /* 14px */
166
+ font-size: var(--cc-font-size, 14px); /* 14px base */
167
167
  font-style: normal;
168
168
  font-weight: 600;
169
- line-height: 1.1375rem; /* 18.2px */
169
+ line-height: calc(var(--cc-font-size, 14px) * 1.3); /* 18.2px at 14px base */
170
170
  }
171
171
 
172
172
  .copy-medium {
173
- font-size: 0.75rem; /* 12px */
173
+ font-size: calc(var(--cc-font-size, 14px) * 0.8571); /* 12px at 14px base */
174
174
  font-style: normal;
175
175
  font-weight: 500;
176
- line-height: 1.05rem; /* 16.8px */
176
+ line-height: calc(var(--cc-font-size, 14px) * 1.2); /* 16.8px at 14px base */
177
177
  }
178
178
 
179
179
  .cta-semibold {
180
- font-size: 0.875rem; /* 14px */
180
+ font-size: var(--cc-font-size, 14px); /* 14px base */
181
181
  font-style: normal;
182
182
  font-weight: 600;
183
- line-height: 1.1375rem; /* 18.2px */
183
+ line-height: calc(var(--cc-font-size, 14px) * 1.3); /* 18.2px at 14px base */
184
184
  }
185
185
  </style>
@@ -189,7 +189,7 @@ const isReadonly = computed(() => {
189
189
  border: none;
190
190
  color: var(--cc-primary-contrast-color, white);
191
191
  cursor: pointer;
192
- font-size: 14px !important;
192
+ font-size: var(--cc-font-size, 14px) !important;
193
193
  font-weight: 600;
194
194
  line-height: 160% !important;
195
195
  min-width: 100%;
@@ -213,7 +213,7 @@ const isReadonly = computed(() => {
213
213
  /* Text styles - use CSS variable for customizable font color */
214
214
  .adaptivecardWrapper :global(.ac-textRun) {
215
215
  color: var(--cc-adaptive-card-text-color, #333) !important;
216
- font-size: 12px !important;
216
+ font-size: calc(var(--cc-font-size, 14px) * 0.8571) !important;
217
217
  line-height: 140%;
218
218
  }
219
219
 
@@ -233,7 +233,7 @@ const isReadonly = computed(() => {
233
233
  border-radius: 10px;
234
234
  border: 1px solid var(--cc-adaptive-card-input-border, #ccc);
235
235
  color: var(--cc-adaptive-card-input-color, #333) !important;
236
- font-size: 14px !important;
236
+ font-size: var(--cc-font-size, 14px) !important;
237
237
  gap: 10px;
238
238
  line-height: 140%;
239
239
  padding: 8px 12px 8px 12px;
@@ -244,7 +244,7 @@ const isReadonly = computed(() => {
244
244
  .adaptivecardWrapper :global(input),
245
245
  .adaptivecardWrapper :global(textarea),
246
246
  .adaptivecardWrapper :global(select) {
247
- font-size: 16px !important;
247
+ font-size: calc(var(--cc-font-size, 14px) * 1.1429) !important;
248
248
  }
249
249
  }
250
250
 
@@ -88,7 +88,7 @@ const selectedDate = computed(() => {
88
88
  border-radius: var(--cc-button-border-radius, 8px);
89
89
  background-color: var(--cc-primary-color, #1976d2);
90
90
  color: var(--cc-white, #ffffff);
91
- font-size: 14px;
91
+ font-size: var(--cc-font-size, 14px);
92
92
  font-weight: 600;
93
93
  cursor: pointer;
94
94
  transition: all 0.2s ease;
@@ -52,9 +52,9 @@
52
52
  :buttonListItemClassName="$style.buttonListItem"
53
53
  :config="config"
54
54
  :dataMessageId="dataMessageId"
55
- :onEmitAnalytics="onEmitAnalytics"
55
+ :on-emit-analytics="onEmitAnalytics"
56
56
  :templateTextId="slide.title ? titleId : undefined"
57
- :openXAppOverlay="openXAppOverlay"
57
+ :open-x-app-overlay="openXAppOverlay"
58
58
  />
59
59
  </div>
60
60
  </div>
@@ -341,7 +341,7 @@ onUnmounted(() => {
341
341
  margin-left: 15px;
342
342
  color: var(--cc-black-10, #1a1a1a);
343
343
  font-weight: 700;
344
- font-size: 16px;
344
+ font-size: calc(var(--cc-font-size, 14px) * 1.1429);
345
345
  }
346
346
 
347
347
  .iconsGroup {
@@ -43,8 +43,8 @@
43
43
  :containerClassName="$style.mainButtonWrapper"
44
44
  :config="config"
45
45
  :dataMessageId="dataMessageId"
46
- :openXAppOverlay="openXAppOverlay"
47
- :onEmitAnalytics="onEmitAnalytics"
46
+ :open-x-app-overlay="openXAppOverlay"
47
+ :on-emit-analytics="onEmitAnalytics"
48
48
  size="large"
49
49
  />
50
50
  </div>
@@ -160,4 +160,10 @@ onMounted(() => {
160
160
  .mainButtonWrapper {
161
161
  padding: 16px;
162
162
  }
163
+
164
+ .mainButtonWrapper button,
165
+ .mainButtonWrapper a {
166
+ width: 100%;
167
+ box-sizing: border-box;
168
+ }
163
169
  </style>
@@ -128,8 +128,8 @@
128
128
  "
129
129
  :config="config"
130
130
  :dataMessageId="dataMessageId"
131
- :openXAppOverlay="openXAppOverlay"
132
- :onEmitAnalytics="onEmitAnalytics"
131
+ :open-x-app-overlay="openXAppOverlay"
132
+ :on-emit-analytics="onEmitAnalytics"
133
133
  size="large"
134
134
  :variant="isHeaderElement ? 'primary' : 'secondary'"
135
135
  />
@@ -315,8 +315,7 @@ const handleKeyDown = (event: KeyboardEvent) => {
315
315
  }
316
316
 
317
317
  .itemSubtitle {
318
- margin-top: 0px;
319
- margin-bottom: 0px;
318
+ margin: 0;
320
319
  color: rgba(0, 0, 0, 0.54);
321
320
  white-space: pre-line;
322
321
  }
@@ -337,7 +336,7 @@ const handleKeyDown = (event: KeyboardEvent) => {
337
336
  }
338
337
 
339
338
  .listItemContent {
340
- padding: 16px 16px 12px 16px;
339
+ padding: 10px;
341
340
  overflow-wrap: break-word;
342
341
  display: flex;
343
342
  -webkit-box-pack: justify;
@@ -18,9 +18,9 @@
18
18
  :containerClassName="containerClassName"
19
19
  :containerStyle="containerStyle"
20
20
  :config="config"
21
- :onEmitAnalytics="onEmitAnalytics"
21
+ :on-emit-analytics="onEmitAnalytics"
22
22
  :templateTextId="webchatButtonTemplateTextId"
23
- :openXAppOverlay="openXAppOverlay"
23
+ :open-x-app-overlay="openXAppOverlay"
24
24
  showUrlIcon
25
25
  />
26
26
  </div>
@@ -287,7 +287,7 @@ onMounted(() => {
287
287
  border-top: none;
288
288
  border-radius: 0 0 var(--cc-bubble-border-radius, 15px) var(--cc-bubble-border-radius, 15px);
289
289
  cursor: pointer;
290
- font-size: 14px;
290
+ font-size: var(--cc-font-size, 14px);
291
291
  font-weight: 600;
292
292
  transition: background-color 0.2s ease;
293
293
  }
package/src/index.ts CHANGED
@@ -43,7 +43,7 @@ export { DownloadIcon, CloseIcon, VideoPlayIcon, AudioPlayIcon, AudioPauseIcon,
43
43
  // Utilities
44
44
  export { match, getChannelPayload } from './utils/matcher'
45
45
  export { sanitizeHTMLWithConfig, sanitizeContent } from './utils/sanitize'
46
- export { configColorsToCssVariables, themeFontToCssVariable } from './utils/theme'
46
+ export { configColorsToCssVariables, themeFontToCssVariable, themeFontSizeToCssVariable } from './utils/theme'
47
47
  export { getWebchatButtonLabel, interpolateString, getRandomId, moveFocusToMessageFocusTarget, replaceUrlsWithHTMLanchorElem, getBackgroundImage, getFileName, getFileExtension, getSizeLabel, isImageAttachment, VALID_IMAGE_MIME_TYPES } from './utils/helpers'
48
48
 
49
49
  // Types
@@ -251,6 +251,8 @@ export interface ChatTheme {
251
251
  textDark?: string
252
252
  textLight?: string
253
253
  fontFamily?: string
254
+ /** Base font size for text scaling. All text sizes scale proportionally from this value. Default: '14px' */
255
+ fontSize?: string
254
256
  }
255
257
 
256
258
  /**
@@ -97,3 +97,21 @@ export function themeFontToCssVariable(
97
97
  if (!theme?.fontFamily) return {}
98
98
  return { '--cc-font-family': theme.fontFamily }
99
99
  }
100
+
101
+ /**
102
+ * Maps a ChatTheme's fontSize to the --cc-font-size CSS variable.
103
+ * Consumers can set this to scale all text proportionally.
104
+ *
105
+ * Components should reference font-size as:
106
+ * font-size: var(--cc-font-size, 14px); (for 14px base)
107
+ * font-size: calc(var(--cc-font-size, 14px) * 1.2857); (for 18px base)
108
+ *
109
+ * @param theme - The ChatTheme object
110
+ * @returns A record with the --cc-font-size CSS variable, or empty object
111
+ */
112
+ export function themeFontSizeToCssVariable(
113
+ theme?: ChatTheme
114
+ ): Record<string, string> {
115
+ if (!theme?.fontSize) return {}
116
+ return { '--cc-font-size': theme.fontSize }
117
+ }