@hubspot/cms-component-library 0.3.12 → 0.3.13

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.
Files changed (29) hide show
  1. package/components/componentLibrary/Accordion/AccordionTitle/StyleFields.tsx +1 -1
  2. package/components/componentLibrary/Button/index.module.scss +12 -4
  3. package/components/componentLibrary/Button/llm.txt +12 -4
  4. package/components/componentLibrary/Button/stories/ButtonDecorator.module.scss +12 -4
  5. package/components/componentLibrary/Card/index.module.scss +4 -2
  6. package/components/componentLibrary/Card/llm.txt +3 -1
  7. package/components/componentLibrary/Card/stories/CardDecorator.module.scss +12 -4
  8. package/components/componentLibrary/Form/PlaceholderForm.module.css +74 -0
  9. package/components/componentLibrary/Form/PlaceholderForm.tsx +31 -0
  10. package/components/componentLibrary/Form/StyleFields.tsx +2 -1
  11. package/components/componentLibrary/Form/index.tsx +24 -2
  12. package/components/componentLibrary/Form/islands/FormIsland.tsx +3 -1
  13. package/components/componentLibrary/Form/islands/LegacyFormIsland.tsx +10 -3
  14. package/components/componentLibrary/Form/islands/legacyForm.module.scss +270 -0
  15. package/components/componentLibrary/Form/islands/v4Form.module.css +59 -57
  16. package/components/componentLibrary/Form/types.ts +7 -2
  17. package/components/componentLibrary/Image/index.module.scss +3 -1
  18. package/components/componentLibrary/Image/llm.txt +3 -1
  19. package/components/componentLibrary/Image/stories/ImageDecorator.module.scss +3 -1
  20. package/components/componentLibrary/Text/ContentFields.tsx +1 -0
  21. package/components/componentLibrary/Video/TrackHSVideoAnalytics.tsx +445 -0
  22. package/components/componentLibrary/Video/hooks/usePageMeta.tsx +25 -0
  23. package/components/componentLibrary/Video/hooks/useQueryParam.tsx +12 -0
  24. package/components/componentLibrary/Video/hooks/useUserToken.tsx +56 -0
  25. package/components/componentLibrary/Video/islands/HSVideoIsland.tsx +4 -0
  26. package/components/componentLibrary/Video/types.ts +22 -0
  27. package/components/componentLibrary/Video/utils/videoAnalytics.ts +146 -0
  28. package/package.json +1 -1
  29. package/components/componentLibrary/Form/islands/legacyForm.module.css +0 -251
@@ -10,7 +10,7 @@ const StyleFields = ({
10
10
  <ChoiceField
11
11
  label={iconLabel}
12
12
  name={iconName}
13
- display="buttons"
13
+ display="select"
14
14
  choices={[
15
15
  ['caret', 'Caret'],
16
16
  ['chevron', 'Chevron'],
@@ -9,7 +9,9 @@
9
9
  color: var(--hs-button-color);
10
10
  padding: 12px 24px;
11
11
  border-radius: var(--hs-button-borderRadius);
12
- border: var(--hs-button-border);
12
+ border-style: var(--hs-button-borderStyle);
13
+ border-width: var(--hs-button-borderWidth);
14
+ border-color: var(--hs-button-borderColor);
13
15
  font-size: var(--hs-button-fontSize);
14
16
  font-family: var(--hs-button-fontFamily);
15
17
  font-style: var(--hs-button-fontStyle);
@@ -25,13 +27,17 @@
25
27
  &:hover {
26
28
  background-color: var(--hs-button-backgroundColor-hover, var(--hs-button-backgroundColor));
27
29
  color: var(--hs-button-color-hover, var(--hs-button-color));
28
- border: var(--hs-button-border-hover, var(--hs-button-border));
30
+ border-style: var(--hs-button-borderStyle-hover, var(--hs-button-borderStyle));
31
+ border-width: var(--hs-button-borderWidth-hover, var(--hs-button-borderWidth));
32
+ border-color: var(--hs-button-borderColor-hover, var(--hs-button-borderColor));
29
33
  }
30
34
 
31
35
  &:focus-visible {
32
36
  background-color: var(--hs-button-backgroundColor-hover, var(--hs-button-backgroundColor));
33
37
  color: var(--hs-button-color-hover, var(--hs-button-color));
34
- border: var(--hs-button-border-hover, var(--hs-button-border));
38
+ border-style: var(--hs-button-borderStyle-hover, var(--hs-button-borderStyle));
39
+ border-width: var(--hs-button-borderWidth-hover, var(--hs-button-borderWidth));
40
+ border-color: var(--hs-button-borderColor-hover, var(--hs-button-borderColor));
35
41
  outline: 2px solid Highlight;
36
42
  outline-offset: 2px;
37
43
  }
@@ -39,7 +45,9 @@
39
45
  &:active {
40
46
  background-color: var(--hs-button-backgroundColor-active, var(--hs-button-backgroundColor));
41
47
  color: var(--hs-button-color-active, var(--hs-button-color));
42
- border: var(--hs-button-border-active, var(--hs-button-border));
48
+ border-style: var(--hs-button-borderStyle-active, var(--hs-button-borderStyle));
49
+ border-width: var(--hs-button-borderWidth-active, var(--hs-button-borderWidth));
50
+ border-color: var(--hs-button-borderColor-active, var(--hs-button-borderColor));
43
51
  }
44
52
 
45
53
  &:disabled {
@@ -284,7 +284,9 @@ The Button component is themed via `--hs-button-*` CSS variables, which are prov
284
284
  - `--hs-button-backgroundColor`: Background color
285
285
  - `--hs-button-color`: Text color
286
286
  - `--hs-button-borderRadius`: Border radius
287
- - `--hs-button-border`: Border shorthand
287
+ - `--hs-button-borderStyle`: Border style
288
+ - `--hs-button-borderWidth`: Border width
289
+ - `--hs-button-borderColor`: Border color
288
290
  - `--hs-button-fontSize`: Font size
289
291
  - `--hs-button-fontFamily`: Font family
290
292
  - `--hs-button-fontStyle`: Font style
@@ -294,17 +296,23 @@ The Button component is themed via `--hs-button-*` CSS variables, which are prov
294
296
  **Hover States (from theme):**
295
297
  - `--hs-button-backgroundColor-hover`: Hover background (falls back to base)
296
298
  - `--hs-button-color-hover`: Hover text color (falls back to base)
297
- - `--hs-button-border-hover`: Hover border (falls back to base)
299
+ - `--hs-button-borderStyle-hover`: Hover border style (falls back to base)
300
+ - `--hs-button-borderWidth-hover`: Hover border width (falls back to base)
301
+ - `--hs-button-borderColor-hover`: Hover border color (falls back to base)
298
302
 
299
303
  **Focus States (from theme):**
300
304
  - `--hs-button-backgroundColor-focus`: Focus background (falls back to base)
301
305
  - `--hs-button-color-focus`: Focus text color (falls back to base)
302
- - `--hs-button-border-focus`: Focus border (falls back to base)
306
+ - `--hs-button-borderStyle-focus`: Focus border style (falls back to base)
307
+ - `--hs-button-borderWidth-focus`: Focus border width (falls back to base)
308
+ - `--hs-button-borderColor-focus`: Focus border color (falls back to base)
303
309
 
304
310
  **Active States (from theme):**
305
311
  - `--hs-button-backgroundColor-active`: Active background (falls back to base)
306
312
  - `--hs-button-color-active`: Active text color (falls back to base)
307
- - `--hs-button-border-active`: Active border (falls back to base)
313
+ - `--hs-button-borderStyle-active`: Active border style (falls back to base)
314
+ - `--hs-button-borderWidth-active`: Active border width (falls back to base)
315
+ - `--hs-button-borderColor-active`: Active border color (falls back to base)
308
316
 
309
317
  ### Hardcoded Layout Values
310
318
 
@@ -3,7 +3,9 @@
3
3
  --hs-button-backgroundColor: #0066cc;
4
4
  --hs-button-color: #ffffff;
5
5
  --hs-button-borderRadius: 4px;
6
- --hs-button-border: 1px solid transparent;
6
+ --hs-button-borderStyle: solid;
7
+ --hs-button-borderWidth: 1px;
8
+ --hs-button-borderColor: transparent;
7
9
  --hs-button-fontSize: 14px;
8
10
  --hs-button-fontFamily: inherit;
9
11
  --hs-button-fontStyle: normal;
@@ -11,11 +13,17 @@
11
13
  --hs-button-textDecoration: none;
12
14
  --hs-button-backgroundColor-hover: #0052a3;
13
15
  --hs-button-color-hover: #ffffff;
14
- --hs-button-border-hover: 1px solid transparent;
16
+ --hs-button-borderStyle-hover: solid;
17
+ --hs-button-borderWidth-hover: 1px;
18
+ --hs-button-borderColor-hover: transparent;
15
19
  --hs-button-backgroundColor-focus: #0066cc;
16
20
  --hs-button-color-focus: #ffffff;
17
- --hs-button-border-focus: 1px solid transparent;
21
+ --hs-button-borderStyle-focus: solid;
22
+ --hs-button-borderWidth-focus: 1px;
23
+ --hs-button-borderColor-focus: transparent;
18
24
  --hs-button-backgroundColor-active: #004080;
19
25
  --hs-button-color-active: #ffffff;
20
- --hs-button-border-active: 1px solid transparent;
26
+ --hs-button-borderStyle-active: solid;
27
+ --hs-button-borderWidth-active: 1px;
28
+ --hs-button-borderColor-active: transparent;
21
29
  }
@@ -1,6 +1,6 @@
1
1
  .card {
2
2
  --hs-section-color: var(--hs-card-color); // overrides card-based typography settings
3
-
3
+
4
4
  display: flex;
5
5
  flex-direction: column;
6
6
  box-sizing: border-box;
@@ -8,5 +8,7 @@
8
8
  border-radius: var(--hs-card-borderRadius, 8px);
9
9
  background-color: var(--hs-card-backgroundColor, #ffffff);
10
10
  color: var(--hs-card-color, inherit);
11
- border: var(--hs-card-border, none);
11
+ border-style: var(--hs-card-borderStyle, none);
12
+ border-width: var(--hs-card-borderWidth, 0);
13
+ border-color: var(--hs-card-borderColor, transparent);
12
14
  }
@@ -137,7 +137,9 @@ FeatureCardModule.fields = (
137
137
  - `--hs-card-borderRadius`: Border radius
138
138
  - `--hs-card-backgroundColor`: Background color
139
139
  - `--hs-card-color`: Text color
140
- - `--hs-card-border`: Border style
140
+ - `--hs-card-borderStyle`: Border style (e.g. `solid`, `none`)
141
+ - `--hs-card-borderWidth`: Border width (e.g. `1px`)
142
+ - `--hs-card-borderColor`: Border color
141
143
 
142
144
 
143
145
  ## Accessibility
@@ -4,27 +4,35 @@
4
4
  --hs-card-borderRadius: 10px;
5
5
  --hs-card-backgroundColor: rgb(255, 255, 255);
6
6
  --hs-card-color: rgb(28, 28, 31);
7
- --hs-card-border: 1px solid #e0e0e0;
7
+ --hs-card-borderStyle: solid;
8
+ --hs-card-borderWidth: 1px;
9
+ --hs-card-borderColor: #e0e0e0;
8
10
  }
9
11
 
10
12
  :global([data-card-variant='card2']) {
11
13
  --hs-card-borderRadius: 10px;
12
14
  --hs-card-backgroundColor: rgb(249, 249, 249);
13
15
  --hs-card-color: rgb(28, 28, 31);
14
- --hs-card-border: 1px solid #e0e0e0;
16
+ --hs-card-borderStyle: solid;
17
+ --hs-card-borderWidth: 1px;
18
+ --hs-card-borderColor: #e0e0e0;
15
19
  }
16
20
 
17
21
  :global([data-card-variant='card3']) {
18
22
  --hs-card-borderRadius: 10px;
19
23
  --hs-card-backgroundColor: rgb(28, 28, 31);
20
24
  --hs-card-color: rgb(255,255,255);
21
- --hs-card-border: 1px solid #e0e0e0;
25
+ --hs-card-borderStyle: solid;
26
+ --hs-card-borderWidth: 1px;
27
+ --hs-card-borderColor: #e0e0e0;
22
28
  }
23
29
 
24
30
  :global([data-card-variant='card4']) {
25
31
  --hs-card-borderRadius: 10px;
26
32
  --hs-card-backgroundColor: rgb(36, 36, 36);
27
33
  --hs-card-color: rgb(255,255,255);
28
- --hs-card-border: 1px solid #e0e0e0;
34
+ --hs-card-borderStyle: solid;
35
+ --hs-card-borderWidth: 1px;
36
+ --hs-card-borderColor: #e0e0e0;
29
37
  }
30
38
  }
@@ -0,0 +1,74 @@
1
+ .placeholderForm {
2
+ padding: 32px;
3
+ border-radius: var(--hs-form-borderRadius, 8px);
4
+ background-color: var(--hs-form-backgroundColor, rgba(255, 255, 255, 1));
5
+ border-style: var(--hs-form-borderStyle, solid);
6
+ border-width: var(--hs-form-borderWidth, 1px);
7
+ border-color: var(--hs-form-borderColor, #E0E0E0);
8
+ }
9
+
10
+ .field {
11
+ margin-block-end: 24px;
12
+ }
13
+
14
+ .field:last-of-type {
15
+ margin-block-end: 0;
16
+ }
17
+
18
+ .label {
19
+ display: block;
20
+ margin-block-end: 8px;
21
+ color: var(--hs-form-label-color, #141414);
22
+ font-size: var(--hs-form-label-fontSize, 16px);
23
+ font-family: var(--hs-form-label-fontFamily, inherit);
24
+ font-style: var(--hs-form-label-fontStyle, normal);
25
+ font-weight: var(--hs-form-label-fontWeight, 600);
26
+ text-decoration: var(--hs-form-label-textDecoration, none);
27
+ }
28
+
29
+ .input {
30
+ width: 100%;
31
+ padding-block: 12px;
32
+ padding-inline: 16px;
33
+ border-radius: var(--hs-form-field-borderRadius, 8px);
34
+ background-color: var(--hs-form-field-backgroundColor, rgba(249, 249, 249, 1));
35
+ border-style: var(--hs-form-field-borderStyle, solid);
36
+ border-width: var(--hs-form-field-borderWidth, 1px);
37
+ border-color: var(--hs-form-field-borderColor, #E0E0E0);
38
+ color: var(--hs-form-input-color, #141414);
39
+ font-size: var(--hs-form-input-fontSize, 16px);
40
+ font-family: var(--hs-form-input-fontFamily, inherit);
41
+ font-style: var(--hs-form-input-fontStyle, normal);
42
+ font-weight: var(--hs-form-input-fontWeight, 400);
43
+ text-decoration: var(--hs-form-input-textDecoration, none);
44
+ box-sizing: border-box;
45
+ }
46
+
47
+ .input::placeholder {
48
+ color: var(--hs-form-placeholder-color, rgba(113, 113, 113, 1));
49
+ }
50
+
51
+ .input:focus {
52
+ background-color: var(--hs-form-field-backgroundColor-focus, var(--hs-form-field-backgroundColor, rgba(249, 249, 249, 1)));
53
+ border-style: var(--hs-form-field-borderStyle-focus, var(--hs-form-field-borderStyle, solid));
54
+ border-width: var(--hs-form-field-borderWidth-focus, var(--hs-form-field-borderWidth, 1px));
55
+ border-color: var(--hs-form-field-borderColor-focus, var(--hs-form-field-borderColor, #E0E0E0));
56
+ outline: none;
57
+ }
58
+
59
+ .submitButton {
60
+ display: inline-block;
61
+ width: 100%;
62
+ margin-block-start: 24px;
63
+ padding-block: 12px;
64
+ padding-inline: 24px;
65
+ border-radius: var(--hs-form-borderRadius, 8px);
66
+ border: none;
67
+ background-color: var(--hs-form-input-color, #141414);
68
+ color: var(--hs-form-backgroundColor, #ffffff);
69
+ font-size: var(--hs-form-label-fontSize, 16px);
70
+ font-family: var(--hs-form-label-fontFamily, inherit);
71
+ font-weight: 600;
72
+ cursor: default;
73
+ text-align: center;
74
+ }
@@ -0,0 +1,31 @@
1
+ import styles from './PlaceholderForm.module.css';
2
+
3
+ const PlaceholderForm = () => {
4
+ return (
5
+ <div className={styles.placeholderForm}>
6
+ <form>
7
+ <div className={styles.field}>
8
+ <label className={styles.label}>First name</label>
9
+ <div>
10
+ <input className={styles.input} type="text" disabled />
11
+ </div>
12
+ </div>
13
+ <div className={styles.field}>
14
+ <label className={styles.label}>Last name</label>
15
+ <div>
16
+ <input className={styles.input} type="text" disabled />
17
+ </div>
18
+ </div>
19
+ <div className={styles.field}>
20
+ <label className={styles.label}>Email</label>
21
+ <div>
22
+ <input className={styles.input} type="text" disabled />
23
+ </div>
24
+ </div>
25
+ <button type="button" disabled className={styles.submitButton}>Get free widget</button>
26
+ </form>
27
+ </div>
28
+ );
29
+ };
30
+
31
+ export default PlaceholderForm;
@@ -4,7 +4,7 @@ import { StyleFieldsProps } from './types.js';
4
4
  const StyleFields = ({
5
5
  formVariantLabel = 'Form variant',
6
6
  formVariantName = 'formVariant',
7
- formVariantDefault = { variant_name: 'form1' },
7
+ formVariantDefault = { variantName: 'form1' },
8
8
  }: StyleFieldsProps) => {
9
9
  return (
10
10
  <VariantSelectionField
@@ -12,6 +12,7 @@ const StyleFields = ({
12
12
  name={formVariantName}
13
13
  variantDefinitionName="form"
14
14
  default={formVariantDefault}
15
+ required={true}
15
16
  />
16
17
  );
17
18
  };
@@ -3,14 +3,16 @@ import FormIsland from './islands/FormIsland.js?island';
3
3
  // @ts-expect-error -- ?island not typed
4
4
  import LegacyFormIsland from './islands/LegacyFormIsland.js?island';
5
5
  import { FormProps } from './types.js';
6
- import { Island } from '@hubspot/cms-components';
6
+ import { Island, useEditorVariableChecks } from '@hubspot/cms-components';
7
7
  import ContentFields from './ContentFields.js';
8
8
  import StyleFields from './StyleFields.js';
9
+ import PlaceholderForm from './PlaceholderForm.js';
9
10
 
10
11
  const FormComponent = ({
11
12
  formField,
12
13
  formId,
13
14
  formVersion,
15
+ variant = 'form1',
14
16
  ...rest
15
17
  }: FormProps) => {
16
18
  const resolvedFormId = formField != null ? formField.form_id : formId;
@@ -18,8 +20,28 @@ const FormComponent = ({
18
20
  formField != null ? formField.embed_version : formVersion;
19
21
  const isV4 = resolvedVersion === 'v4';
20
22
  const FormModule = isV4 ? FormIsland : LegacyFormIsland;
23
+ const editorChecks = useEditorVariableChecks();
24
+ const hasFormData = !!resolvedFormId;
21
25
 
22
- return <Island module={FormModule} formId={resolvedFormId} {...rest} />;
26
+ if (!hasFormData && !editorChecks.is_in_editor) return null;
27
+
28
+ if (!hasFormData) {
29
+ return (
30
+ <div data-form-variant={variant} data-button-variant="primaryButton">
31
+ <PlaceholderForm />
32
+ </div>
33
+ );
34
+ }
35
+
36
+ return (
37
+ <Island
38
+ module={FormModule}
39
+ data-form-variant={variant}
40
+ formId={resolvedFormId}
41
+ variant={variant}
42
+ {...rest}
43
+ />
44
+ );
23
45
  };
24
46
 
25
47
  type FormComponentType = typeof FormComponent & {
@@ -9,7 +9,7 @@ const getScriptSrc = (portalId: number, env: string) => {
9
9
  return `https://${host}/forms/embed/developer/${portalId}.js`;
10
10
  };
11
11
 
12
- const FormIsland = ({ formId }: FormProps) => {
12
+ const FormIsland = ({ formId, variant }: FormProps) => {
13
13
  const portalId = getHubID();
14
14
  const resolvedEnv = getHSEnv();
15
15
 
@@ -49,6 +49,8 @@ const FormIsland = ({ formId }: FormProps) => {
49
49
  data-form-id={formId}
50
50
  data-portal-id={portalId}
51
51
  data-env={resolvedEnv}
52
+ data-form-variant={variant}
53
+ data-button-variant="primaryButton"
52
54
  />
53
55
  );
54
56
  };
@@ -1,7 +1,7 @@
1
1
  import { useEffect, useId } from 'react';
2
2
  import { FormProps } from '../types.js';
3
3
  import { getHubID, getHSEnv } from '@hubspot/cms-components';
4
- import styles from './legacyForm.module.css';
4
+ import styles from './legacyForm.module.scss';
5
5
 
6
6
  declare global {
7
7
  interface Window {
@@ -23,7 +23,7 @@ const getScriptSrc = (env: string) => {
23
23
  return `//${host}/forms/embed/v2.js`;
24
24
  };
25
25
 
26
- const LegacyFormIsland = ({ formId }: FormProps) => {
26
+ const LegacyFormIsland = ({ formId, variant }: FormProps) => {
27
27
  const portalId = getHubID();
28
28
  const resolvedEnv = getHSEnv();
29
29
  const rawId = useId();
@@ -72,7 +72,14 @@ const LegacyFormIsland = ({ formId }: FormProps) => {
72
72
  return null;
73
73
  }
74
74
 
75
- return <div id={containerId} className={styles.legacyFormStyles} />;
75
+ return (
76
+ <div
77
+ id={containerId}
78
+ className={styles.legacyFormStyles}
79
+ data-form-variant={variant}
80
+ data-button-variant="primaryButton"
81
+ />
82
+ );
76
83
  };
77
84
 
78
85
  export default LegacyFormIsland;