@hubspot/cms-component-library 0.3.10 → 0.3.12

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 (30) hide show
  1. package/components/componentLibrary/Accordion/AccordionContent/index.module.scss +3 -5
  2. package/components/componentLibrary/Accordion/AccordionItem/StyleFields.tsx +6 -14
  3. package/components/componentLibrary/Accordion/AccordionItem/index.module.scss +7 -5
  4. package/components/componentLibrary/Accordion/AccordionItem/index.tsx +6 -15
  5. package/components/componentLibrary/Accordion/AccordionItem/types.ts +5 -5
  6. package/components/componentLibrary/Accordion/AccordionTitle/index.module.scss +6 -6
  7. package/components/componentLibrary/Accordion/llm.txt +15 -15
  8. package/components/componentLibrary/Accordion/stories/Accordion.stories.tsx +3 -3
  9. package/components/componentLibrary/Accordion/stories/AccordionDecorator.module.scss +38 -0
  10. package/components/componentLibrary/Accordion/stories/AccordionDecorator.tsx +7 -35
  11. package/components/componentLibrary/Button/index.module.scss +4 -4
  12. package/components/componentLibrary/Card/StyleFields.tsx +1 -1
  13. package/components/componentLibrary/Card/index.module.scss +2 -4
  14. package/components/componentLibrary/Card/index.tsx +1 -1
  15. package/components/componentLibrary/Card/llm.txt +3 -3
  16. package/components/componentLibrary/Card/stories/Card.stories.tsx +5 -5
  17. package/components/componentLibrary/Card/stories/CardDecorator.module.scss +4 -4
  18. package/components/componentLibrary/Card/types.ts +4 -4
  19. package/components/componentLibrary/Form/StyleFields.tsx +1 -1
  20. package/components/componentLibrary/Form/llm.txt +2 -2
  21. package/components/componentLibrary/Link/index.module.scss +3 -1
  22. package/components/componentLibrary/Text/index.module.scss +40 -1
  23. package/components/componentLibrary/Text/llm.txt +4 -2
  24. package/components/componentLibrary/Video/ContentFields.tsx +1 -0
  25. package/components/componentLibrary/Video/StyleFields.tsx +42 -0
  26. package/components/componentLibrary/Video/index.tsx +11 -2
  27. package/components/componentLibrary/Video/islands/EmbedVideoIsland.tsx +239 -0
  28. package/components/componentLibrary/Video/islands/index.module.scss +94 -0
  29. package/components/componentLibrary/_patterns/css-patterns.md +34 -17
  30. package/package.json +1 -1
@@ -1,9 +1,7 @@
1
1
  .accordionContent {
2
- padding-block: var(--hscl-accordion-body-paddingBlock, 16px);
3
- padding-inline: var(--hscl-accordion-body-paddingInline, 20px);
4
- color: var(--hscl-accordion-body-color, inherit);
5
- font-size: var(--hscl-accordion-body-fontSize, 16px);
6
- line-height: var(--hscl-accordion-body-lineHeight, 1.5);
2
+ padding-block: 16px;
3
+ padding-inline: 20px;
4
+ color: inherit;
7
5
 
8
6
  :last-child {
9
7
  margin-block-end: 0;
@@ -1,24 +1,16 @@
1
- import { ChoiceField } from '@hubspot/cms-components/fields';
1
+ import { VariantSelectionField } from '@hubspot/cms-components/fields';
2
2
  import type { StyleFieldsProps } from './types.js';
3
3
 
4
4
  const StyleFields = ({
5
- variantLabel = 'Variant',
6
- variantName = 'variant',
7
- variantDefault = 'variant1',
5
+ variantLabel = 'Accordion variant',
6
+ variantName = 'accordionVariant',
7
+ variantDefault = { variant_name: 'card1' },
8
8
  }: StyleFieldsProps) => {
9
9
  return (
10
- <ChoiceField
10
+ <VariantSelectionField
11
11
  label={variantLabel}
12
12
  name={variantName}
13
- helpText="The style variant for the accordion item"
14
- display="select"
15
- choices={[
16
- ['variant1', 'Variant 1'],
17
- ['variant2', 'Variant 2'],
18
- ['variant3', 'Variant 3'],
19
- ['variant4', 'Variant 4'],
20
- ]}
21
- required={false}
13
+ variantDefinitionName="card"
22
14
  default={variantDefault}
23
15
  />
24
16
  );
@@ -1,9 +1,11 @@
1
1
  .accordionItem {
2
- border: var(--hscl-accordion-borderWidth, 1px) solid
3
- var(--hscl-accordion-borderColor, #e0e0e0);
4
- border-radius: var(--hscl-accordion-borderRadius, 4px);
5
- background-color: var(--hscl-accordion-backgroundColor, transparent);
6
- color: var(--hscl-accordion-color, inherit);
2
+ --hs-section-color: var(--hs-card-color);
3
+
4
+ border: var(--hs-card-borderWidth, 1px) solid
5
+ var(--hs-card-borderColor, #e0e0e0);
6
+ border-radius: var(--hs-card-borderRadius, 4px);
7
+ background-color: var(--hs-card-backgroundColor, transparent);
8
+ color: var(--hs-card-color, inherit);
7
9
  overflow: hidden;
8
10
  }
9
11
 
@@ -1,31 +1,22 @@
1
1
  import styles from './index.module.scss';
2
2
  import StyleFields from './StyleFields.js';
3
3
  import cx from '../../utils/classname.js';
4
- import { mapVariantToCssVars } from '../../utils/cssVars.js';
5
- import { CSSVariables } from '../../utils/types.js';
6
4
  import { AccordionItemProps } from './types.js';
7
5
 
8
6
  const AccordionItemComponent = ({
9
- variant = 'variant1',
7
+ variant = 'card1',
10
8
  className = '',
11
9
  style = {},
12
10
  children,
13
11
  }: AccordionItemProps) => {
14
12
  const combinedClasses = cx(styles.accordionItem, className);
15
13
 
16
- const cssVariables: CSSVariables = variant
17
- ? mapVariantToCssVars('--hscl-accordion', variant, [
18
- 'borderColor',
19
- 'borderRadius',
20
- 'borderWidth',
21
- 'backgroundColor',
22
- 'color',
23
- 'icon-fill',
24
- ])
25
- : {};
26
-
27
14
  return (
28
- <details className={combinedClasses} style={{ ...cssVariables, ...style }}>
15
+ <details
16
+ className={combinedClasses}
17
+ style={style}
18
+ data-card-variant={variant}
19
+ >
29
20
  {children}
30
21
  </details>
31
22
  );
@@ -3,10 +3,10 @@ import type { AccordionTitleProps } from '../AccordionTitle/types.js';
3
3
  import type { AccordionContentProps } from '../AccordionContent/types.js';
4
4
 
5
5
  export type AccordionVariant =
6
- | 'variant1'
7
- | 'variant2'
8
- | 'variant3'
9
- | 'variant4';
6
+ | 'card1'
7
+ | 'card2'
8
+ | 'card3'
9
+ | 'card4';
10
10
 
11
11
  type AccordionItemChildren =
12
12
  | ReactElement<AccordionTitleProps>
@@ -22,5 +22,5 @@ export type AccordionItemProps = {
22
22
  export type StyleFieldsProps = {
23
23
  variantLabel?: string;
24
24
  variantName?: string;
25
- variantDefault?: AccordionVariant;
25
+ variantDefault?: { variantName?: string; variant_name?: string };
26
26
  };
@@ -1,9 +1,9 @@
1
1
  .accordionTitle {
2
2
  display: flex;
3
3
  align-items: center;
4
- padding-block: var(--hscl-accordion-title-paddingBlock, 16px);
5
- padding-inline: var(--hscl-accordion-title-paddingInline, 20px);
6
- background-color: var(--hscl-accordion-title-backgroundColor, transparent);
4
+ padding-block: 16px;
5
+ padding-inline: 20px;
6
+ background-color: transparent;
7
7
  cursor: pointer;
8
8
  list-style: none;
9
9
 
@@ -13,9 +13,9 @@
13
13
  }
14
14
 
15
15
  .accordionTitleText {
16
- font-size: var(--hscl-accordion-title-fontSize, 24px);
17
- font-weight: var(--hscl-accordion-title-fontWeight, 600);
18
- margin-inline-end: var(--hscl-accordion-title-marginInlineEnd, 16px);
16
+ font-size: 24px;
17
+ font-weight: 600;
18
+ margin-inline-end: 16px;
19
19
  flex: 1;
20
20
  }
21
21
 
@@ -89,7 +89,7 @@ Accordion/
89
89
  **Props:**
90
90
  ```tsx
91
91
  {
92
- variant?: 'variant1' | 'variant2' | 'variant3' | 'variant4'; // Visual style variant (default: 'variant1')
92
+ variant?: 'card1' | 'card2' | 'card3' | 'card4'; // Visual style variant (default: 'card1')
93
93
  className?: string; // Additional CSS classes
94
94
  style?: React.CSSProperties; // Inline styles
95
95
  children: React.ReactNode; // Should contain AccordionTitle and AccordionContent
@@ -220,14 +220,14 @@ Configurable props for variant selection:
220
220
 
221
221
  ```tsx
222
222
  <AccordionItem.StyleFields
223
- variantName="variant"
224
- variantLabel="Variant"
225
- variantDefault="variant1"
223
+ variantName="accordionVariant"
224
+ variantLabel="Accordion variant"
225
+ variantDefault={{ variant_name: 'card1' }}
226
226
  />
227
227
  ```
228
228
 
229
229
  **Fields:**
230
- - `variant`: ChoiceField for selecting visual style (variant1, variant2, variant3, variant4)
230
+ - `accordionVariant`: VariantSelectionField for selecting visual style using the card variant definition (card1, card2, card3, card4)
231
231
 
232
232
  #### AccordionTitle.ContentFields
233
233
 
@@ -288,7 +288,7 @@ import { AccordionIconType } from '@hubspot/cms-component-library/Accordion/Acco
288
288
 
289
289
  type FAQModuleProps = {
290
290
  style?: {
291
- variant?: AccordionVariant;
291
+ accordionVariant?: { variantName: AccordionVariant };
292
292
  icon?: AccordionIconType;
293
293
  };
294
294
  accordionItems?: Array<{
@@ -301,7 +301,7 @@ export const Component = ({
301
301
  style,
302
302
  accordionItems = [],
303
303
  }: FAQModuleProps) => {
304
- const variant = style?.variant;
304
+ const variant = style?.accordionVariant?.variantName;
305
305
  const icon = style?.icon;
306
306
 
307
307
  return (
@@ -371,18 +371,18 @@ export const fields = (
371
371
 
372
372
  ### CSS Variables
373
373
 
374
- The Accordion component uses CSS variables for theming and customization. Variables are organized by variant for consistent styling across the component.
374
+ The Accordion component uses CSS variables for theming and customization. Variant styles are applied via `data-accordion-variant` data attribute selectors (following the same pattern as Card), using the card variant definition from `VariantSelectionField`.
375
375
 
376
- **Per-Variant Variables (replace `{variant}` with variant1, variant2, variant3, or variant4):**
376
+ **Base Variables (applied per variant via `[data-accordion-variant]` selectors):**
377
377
 
378
378
  | Variable | Description | Default |
379
379
  |----------|-------------|---------|
380
- | `--hscl-accordion-{variant}-borderColor` | Border color | `#e0e0e0` |
381
- | `--hscl-accordion-{variant}-borderRadius` | Border radius | `4px` |
382
- | `--hscl-accordion-{variant}-borderThickness` | Border width | `1px` |
383
- | `--hscl-accordion-{variant}-backgroundColor` | Background color | `transparent` |
384
- | `--hscl-accordion-{variant}-textColor` | Text color | `#33475b` |
385
- | `--hscl-accordion-{variant}-icon-fillColor` | Icon fill color | `#33475b` |
380
+ | `--hscl-accordion-borderColor` | Border color | `#e0e0e0` |
381
+ | `--hscl-accordion-borderRadius` | Border radius | `4px` |
382
+ | `--hscl-accordion-borderWidth` | Border width | `1px` |
383
+ | `--hscl-accordion-backgroundColor` | Background color | `transparent` |
384
+ | `--hscl-accordion-color` | Text color | `#33475b` |
385
+ | `--hscl-accordion-icon-fill` | Icon fill color | `#33475b` |
386
386
 
387
387
  **Title-Specific Variables:**
388
388
 
@@ -153,7 +153,7 @@ export const Variants: Story = {
153
153
  <SBContainer addBackground>
154
154
  <h4>Variant 2</h4>
155
155
  <Accordion>
156
- <AccordionItem variant="variant2">
156
+ <AccordionItem variant="card2">
157
157
  <AccordionTitle>Soft background styling</AccordionTitle>
158
158
  <AccordionContent>
159
159
  <p>
@@ -167,7 +167,7 @@ export const Variants: Story = {
167
167
  <SBContainer addBackground>
168
168
  <h4>Variant 3</h4>
169
169
  <Accordion>
170
- <AccordionItem variant="variant3">
170
+ <AccordionItem variant="card3">
171
171
  <AccordionTitle>Bold accent styling</AccordionTitle>
172
172
  <AccordionContent>
173
173
  <p>Accent-colored border with sharp corners for emphasis.</p>
@@ -179,7 +179,7 @@ export const Variants: Story = {
179
179
  <SBContainer addBackground>
180
180
  <h4>Variant 4</h4>
181
181
  <Accordion>
182
- <AccordionItem variant="variant4">
182
+ <AccordionItem variant="card4">
183
183
  <AccordionTitle>Rounded card styling</AccordionTitle>
184
184
  <AccordionContent>
185
185
  <p>
@@ -0,0 +1,38 @@
1
+ .accordionContainer {
2
+ /* Accordion Variant Styles */
3
+ :global([data-accordion-variant='card1']) {
4
+ --hscl-accordion-borderColor: #e0e0e0;
5
+ --hscl-accordion-borderRadius: 4px;
6
+ --hscl-accordion-borderWidth: 1px;
7
+ --hscl-accordion-backgroundColor: transparent;
8
+ --hscl-accordion-color: #33475b;
9
+ --hscl-accordion-icon-fill: #33475b;
10
+ }
11
+
12
+ :global([data-accordion-variant='card2']) {
13
+ --hscl-accordion-borderColor: #cbd6e2;
14
+ --hscl-accordion-borderRadius: 8px;
15
+ --hscl-accordion-borderWidth: 1px;
16
+ --hscl-accordion-backgroundColor: #f5f8fa;
17
+ --hscl-accordion-color: #33475b;
18
+ --hscl-accordion-icon-fill: #516f90;
19
+ }
20
+
21
+ :global([data-accordion-variant='card3']) {
22
+ --hscl-accordion-borderColor: #ff7a59;
23
+ --hscl-accordion-borderRadius: 0;
24
+ --hscl-accordion-borderWidth: 2px;
25
+ --hscl-accordion-backgroundColor: transparent;
26
+ --hscl-accordion-color: #33475b;
27
+ --hscl-accordion-icon-fill: #ff7a59;
28
+ }
29
+
30
+ :global([data-accordion-variant='card4']) {
31
+ --hscl-accordion-borderColor: #33475b;
32
+ --hscl-accordion-borderRadius: 12px;
33
+ --hscl-accordion-borderWidth: 1px;
34
+ --hscl-accordion-backgroundColor: #eaf0f6;
35
+ --hscl-accordion-color: #33475b;
36
+ --hscl-accordion-icon-fill: #33475b;
37
+ }
38
+ }
@@ -1,41 +1,13 @@
1
1
  import type { Decorator } from '@storybook/react';
2
- import type { CSSVariables } from '../../utils/types.js';
3
-
4
- const defaultAccordionStyles: CSSVariables = {
5
- '--hscl-listItem-color-primary': '#33475b',
6
- '--hscl-listItem-color-secondary': '#516f90',
7
-
8
- '--hscl-accordion-variant1-borderColor': '#e0e0e0',
9
- '--hscl-accordion-variant1-borderRadius': '4px',
10
- '--hscl-accordion-variant1-borderWidth': '1px',
11
- '--hscl-accordion-variant1-backgroundColor': 'transparent',
12
- '--hscl-accordion-variant1-color': '#33475b',
13
- '--hscl-accordion-variant1-icon-fill': '#33475b',
14
-
15
- '--hscl-accordion-variant2-borderColor': '#cbd6e2',
16
- '--hscl-accordion-variant2-borderRadius': '8px',
17
- '--hscl-accordion-variant2-borderWidth': '1px',
18
- '--hscl-accordion-variant2-backgroundColor': '#f5f8fa',
19
- '--hscl-accordion-variant2-color': '#33475b',
20
- '--hscl-accordion-variant2-icon-fill': '#516f90',
21
-
22
- '--hscl-accordion-variant3-borderColor': '#ff7a59',
23
- '--hscl-accordion-variant3-borderRadius': '0',
24
- '--hscl-accordion-variant3-borderWidth': '2px',
25
- '--hscl-accordion-variant3-backgroundColor': 'transparent',
26
- '--hscl-accordion-variant3-color': '#33475b',
27
- '--hscl-accordion-variant3-icon-fill': '#ff7a59',
28
-
29
- '--hscl-accordion-variant4-borderColor': '#33475b',
30
- '--hscl-accordion-variant4-borderRadius': '12px',
31
- '--hscl-accordion-variant4-borderWidth': '1px',
32
- '--hscl-accordion-variant4-backgroundColor': '#eaf0f6',
33
- '--hscl-accordion-variant4-color': '#33475b',
34
- '--hscl-accordion-variant4-icon-fill': '#33475b',
35
- };
2
+ import styles from './AccordionDecorator.module.scss';
36
3
 
37
4
  export const withAccordionStyles: Decorator = Story => (
38
- <div style={defaultAccordionStyles}>
5
+ <div className={styles.accordionContainer}>
39
6
  <Story />
40
7
  </div>
41
8
  );
9
+
10
+ /**
11
+ * Export styles so stories can apply variant classes to AccordionItems
12
+ */
13
+ export { styles as accordionStyles };
@@ -29,10 +29,10 @@
29
29
  }
30
30
 
31
31
  &:focus-visible {
32
- background-color: var(--hs-button-backgroundColor-focus, var(--hs-button-backgroundColor));
33
- color: var(--hs-button-color-focus, var(--hs-button-color));
34
- border: var(--hs-button-border-focus, var(--hs-button-border));
35
- outline: 2px solid;
32
+ background-color: var(--hs-button-backgroundColor-hover, var(--hs-button-backgroundColor));
33
+ color: var(--hs-button-color-hover, var(--hs-button-color));
34
+ border: var(--hs-button-border-hover, var(--hs-button-border));
35
+ outline: 2px solid Highlight;
36
36
  outline-offset: 2px;
37
37
  }
38
38
 
@@ -4,7 +4,7 @@ import { StyleFieldsProps } from './types.js';
4
4
  const StyleFields = ({
5
5
  cardVariantLabel = 'Card variant',
6
6
  cardVariantName = 'cardVariant',
7
- cardVariantDefault = { variantName: 'cardStyle1' },
7
+ cardVariantDefault = { variant_name: 'card1' },
8
8
  }: StyleFieldsProps) => {
9
9
  return (
10
10
  <VariantSelectionField
@@ -1,4 +1,6 @@
1
1
  .card {
2
+ --hs-section-color: var(--hs-card-color); // overrides card-based typography settings
3
+
2
4
  display: flex;
3
5
  flex-direction: column;
4
6
  box-sizing: border-box;
@@ -7,8 +9,4 @@
7
9
  background-color: var(--hs-card-backgroundColor, #ffffff);
8
10
  color: var(--hs-card-color, inherit);
9
11
  border: var(--hs-card-border, none);
10
-
11
- h1,h2,h3,h4,h5,h6,p,span {
12
- color: inherit;
13
- }
14
12
  }
@@ -4,7 +4,7 @@ import { CardProps } from './types.js';
4
4
  import StyleFields from './StyleFields.js';
5
5
 
6
6
  const CardComponent = ({
7
- variant = 'cardStyle1',
7
+ variant = 'card1',
8
8
  as: Component = 'div',
9
9
  className = '',
10
10
  style = {},
@@ -34,7 +34,7 @@ Card/
34
34
  **Props:**
35
35
  ```tsx
36
36
  {
37
- variant?: 'cardStyle1' | 'cardStyle2' | 'cardStyle3' | 'cardStyle4'; // Theme variant (default: 'cardStyle1')
37
+ variant?: 'card1' | 'card2' | 'card3' | 'card4'; // Theme variant (default: 'card1')
38
38
  as?: 'div' | 'article' | 'section'; // HTML element to render (default: 'div')
39
39
  children?: React.ReactNode; // Card content
40
40
  className?: string; // Additional CSS classes
@@ -58,7 +58,7 @@ import Card from '@hubspot/cms-component-library/Card';
58
58
  ### Semantic Article Card
59
59
 
60
60
  ```tsx
61
- <Card as="article" variant="cardStyle3">
61
+ <Card as="article" variant="card3">
62
62
  <h3>Blog Post Title</h3>
63
63
  <p>Article content goes here...</p>
64
64
  </Card>
@@ -97,7 +97,7 @@ Configurable props for customizing field labels, names, and defaults:
97
97
  <Card.StyleFields
98
98
  cardVariantLabel="Card variant"
99
99
  cardVariantName="cardVariant"
100
- cardVariantDefault={{ variant_name: 'cardStyle1' }}
100
+ cardVariantDefault={{ variant_name: 'card1' }}
101
101
  />
102
102
  ```
103
103
 
@@ -43,7 +43,7 @@ type Story = StoryObj<typeof meta>;
43
43
 
44
44
  export const Default: Story = {
45
45
  args: {
46
- variant: 'cardStyle1',
46
+ variant: 'card1',
47
47
  },
48
48
  render: args => (
49
49
  <Card {...args}>
@@ -60,7 +60,7 @@ export const Variants: Story = {
60
60
  <SBContainer flex direction="column" gap="large">
61
61
  <SBContainer addBackground>
62
62
  <h4>Card Style 1 (Light)</h4>
63
- <Card variant="cardStyle1">
63
+ <Card variant="card1">
64
64
  <CardHeading>Card Style 1</CardHeading>
65
65
  <CardDivider />
66
66
  <CardContent>Light background with dark text.</CardContent>
@@ -69,7 +69,7 @@ export const Variants: Story = {
69
69
 
70
70
  <SBContainer addBackground>
71
71
  <h4>Card Style 2 (Subtle)</h4>
72
- <Card variant="cardStyle2">
72
+ <Card variant="card2">
73
73
  <CardHeading>Card Style 2</CardHeading>
74
74
  <CardDivider />
75
75
  <CardContent>Subtle background with dark text.</CardContent>
@@ -78,7 +78,7 @@ export const Variants: Story = {
78
78
 
79
79
  <SBContainer addBackground>
80
80
  <h4>Card Style 3 (Dark)</h4>
81
- <Card variant="cardStyle3">
81
+ <Card variant="card3">
82
82
  <CardHeading>Card Style 3</CardHeading>
83
83
  <CardDivider />
84
84
  <CardContent>Dark background with light text.</CardContent>
@@ -87,7 +87,7 @@ export const Variants: Story = {
87
87
 
88
88
  <SBContainer addBackground>
89
89
  <h4>Card Style 4 (Darker)</h4>
90
- <Card variant="cardStyle4">
90
+ <Card variant="card4">
91
91
  <CardHeading>Card Style 4</CardHeading>
92
92
  <CardDivider />
93
93
  <CardContent>Darker background with light text.</CardContent>
@@ -1,27 +1,27 @@
1
1
  .cardContainer {
2
2
  /* card Variant Styles */
3
- :global([data-card-variant='cardStyle1']) {
3
+ :global([data-card-variant='card1']) {
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
7
  --hs-card-border: 1px solid #e0e0e0;
8
8
  }
9
9
 
10
- :global([data-card-variant='cardStyle2']) {
10
+ :global([data-card-variant='card2']) {
11
11
  --hs-card-borderRadius: 10px;
12
12
  --hs-card-backgroundColor: rgb(249, 249, 249);
13
13
  --hs-card-color: rgb(28, 28, 31);
14
14
  --hs-card-border: 1px solid #e0e0e0;
15
15
  }
16
16
 
17
- :global([data-card-variant='cardStyle3']) {
17
+ :global([data-card-variant='card3']) {
18
18
  --hs-card-borderRadius: 10px;
19
19
  --hs-card-backgroundColor: rgb(28, 28, 31);
20
20
  --hs-card-color: rgb(255,255,255);
21
21
  --hs-card-border: 1px solid #e0e0e0;
22
22
  }
23
23
 
24
- :global([data-card-variant='cardStyle4']) {
24
+ :global([data-card-variant='card4']) {
25
25
  --hs-card-borderRadius: 10px;
26
26
  --hs-card-backgroundColor: rgb(36, 36, 36);
27
27
  --hs-card-color: rgb(255,255,255);
@@ -1,8 +1,8 @@
1
1
  export type CardVariant =
2
- | 'cardStyle1'
3
- | 'cardStyle2'
4
- | 'cardStyle3'
5
- | 'cardStyle4';
2
+ | 'card1'
3
+ | 'card2'
4
+ | 'card3'
5
+ | 'card4';
6
6
 
7
7
  export type CardAs = 'div' | 'article' | 'section';
8
8
 
@@ -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: 'primaryForm' },
7
+ formVariantDefault = { variant_name: 'form1' },
8
8
  }: StyleFieldsProps) => {
9
9
  return (
10
10
  <VariantSelectionField
@@ -123,7 +123,7 @@ Configurable props for variant selection:
123
123
  <Form.StyleFields
124
124
  formVariantLabel="Form variant"
125
125
  formVariantName="formVariant"
126
- formVariantDefault={{ variant_name: 'primaryForm' }}
126
+ formVariantDefault={{ variant_name: 'form1' }}
127
127
  />
128
128
  ```
129
129
 
@@ -135,7 +135,7 @@ Configurable props for variant selection:
135
135
  {
136
136
  formVariantLabel?: string; // Label shown in the editor (default: "Form variant")
137
137
  formVariantName?: string; // Field name (default: "formVariant")
138
- formVariantDefault?: { variant_name: string }; // Default variant (default: { variant_name: 'primaryForm' })
138
+ formVariantDefault?: { variant_name: string }; // Default variant (default: { variant_name: 'form1' })
139
139
  }
140
140
  ```
141
141
 
@@ -10,7 +10,9 @@
10
10
  }
11
11
 
12
12
  &:focus-visible {
13
- outline: 2px solid currentColor;
13
+ color: var(--hs-link-color-hover);
14
+ text-decoration: var(--hs-link-textDecoration-hover);
15
+ outline: 2px solid Highlight;
14
16
  outline-offset: 2px;
15
17
  }
16
18
 
@@ -1,3 +1,42 @@
1
1
  .text {
2
- color: var(--hscl-text-color, currentColor);
2
+ color: var(--hs-section-color, currentColor);
3
+
4
+ p,
5
+ h1,
6
+ h2,
7
+ h3,
8
+ h4,
9
+ h5,
10
+ h6,
11
+ ul,
12
+ ol,
13
+ blockquote {
14
+ margin-block: 0 2rem;
15
+ }
16
+
17
+ *:last-child {
18
+ margin-block-end: 0
19
+ }
20
+
21
+ a {
22
+ color: var(--hs-section-link-color);
23
+ }
24
+
25
+ a:hover {
26
+ color: var(--hs-section-link-color-hover);
27
+ }
28
+
29
+ a:focus-visible {
30
+ color: var(--hs-section-link-color-hover);
31
+ outline: 2px solid Highlight;
32
+ outline-offset: 2px;
33
+ }
34
+
35
+ blockquote {
36
+ padding: 24px;
37
+ border-radius: 4px;
38
+ border-left: 3px solid var(--hs-section-blockquote-accentColor);
39
+ background-color: var(--hs-section-blockquote-backgroundColor);
40
+ color: var(--hs-section-blockquote-color);
41
+ }
3
42
  }
@@ -147,8 +147,10 @@ export default function ArticleModule() {
147
147
 
148
148
  ### CSS Variables
149
149
 
150
- **Base Styles:**
151
- - `--hscl-text-color`: Text color applied to the rendered rich text content (default: `currentColor`)
150
+ By default, the Text component inherits styles from the HubSpot theme's section settings (e.g. `--hs-section-color`, `--hs-section-link-color`). The `--hscl-` variables below are overrides — use them when the component is placed in a context (like a Card) that requires different styling than the section defaults.
151
+
152
+ **Overrides:**
153
+ - `--hscl-text-color`: Text color (falls back to `--hs-section-color`, then `currentColor`)
152
154
 
153
155
  ## Accessibility
154
156
 
@@ -80,6 +80,7 @@ const ContentFields = ({
80
80
  <ImageField
81
81
  name={oembedThumbnailName}
82
82
  label={oembedThumbnailLabel}
83
+ id="oembedThumbnail"
83
84
  default={oembedThumbnailDefault}
84
85
  responsive={true}
85
86
  resizable={false}
@@ -12,6 +12,48 @@ const StyleFields = ({
12
12
  name={playButtonColorName}
13
13
  default={playButtonColorDefault}
14
14
  showOpacity={false}
15
+ visibilityRules="ADVANCED"
16
+ advancedVisibility={{
17
+ boolean_operator: 'OR',
18
+ criteria: [],
19
+ children: [
20
+ {
21
+ boolean_operator: 'AND',
22
+ criteria: [
23
+ {
24
+ controlling_field: 'videoType',
25
+ operator: 'EQUAL',
26
+ controlling_value_regex: 'hubspot_video',
27
+ },
28
+ ],
29
+ },
30
+ {
31
+ boolean_operator: 'AND',
32
+ criteria: [
33
+ {
34
+ controlling_field: 'videoType',
35
+ operator: 'EQUAL',
36
+ controlling_value_regex: 'embed',
37
+ },
38
+ {
39
+ controlling_field: 'embedVideo',
40
+ operator: 'MATCHES_REGEX',
41
+ controlling_value_regex: '(?=.*"source_type":"oembed")',
42
+ },
43
+ {
44
+ controlling_field: 'embedVideo',
45
+ operator: 'MATCHES_REGEX',
46
+ controlling_value_regex: '(?=.*"oembed_url":"(?!")+)',
47
+ },
48
+ {
49
+ controlling_field: 'oembedThumbnail',
50
+ operator: 'MATCHES_REGEX',
51
+ controlling_value_regex: '(?=.*"src":"(?!")+)',
52
+ },
53
+ ],
54
+ },
55
+ ],
56
+ }}
15
57
  />
16
58
  );
17
59
  };
@@ -2,6 +2,8 @@ import { Island } from '@hubspot/cms-components';
2
2
  import ContentFields from './ContentFields.js';
3
3
  import StyleFields from './StyleFields.js';
4
4
  // @ts-expect-error -- ?island not typed
5
+ import EmbedVideoIsland from './islands/EmbedVideoIsland.js?island';
6
+ // @ts-expect-error -- ?island not typed
5
7
  import HSVideoIsland from './islands/HSVideoIsland.js?island';
6
8
  import { VideoProps } from './types.js';
7
9
 
@@ -9,6 +11,7 @@ const VideoComponent = ({
9
11
  videoType,
10
12
  hubspotVideoParams,
11
13
  embedVideoParams,
14
+ oembedThumbnail,
12
15
  playButtonColor,
13
16
  video,
14
17
  }: VideoProps) => {
@@ -28,8 +31,14 @@ const VideoComponent = ({
28
31
  videoType === 'embed' &&
29
32
  Boolean(embedVideoParams?.oembed_url || embedVideoParams?.embed_html)
30
33
  ) {
31
- // TODO: implement embed video
32
- return <div />;
34
+ return (
35
+ <Island
36
+ module={EmbedVideoIsland}
37
+ embedVideoParams={embedVideoParams}
38
+ oembedThumbnail={oembedThumbnail}
39
+ playButtonColor={playButtonColor}
40
+ />
41
+ );
33
42
  }
34
43
 
35
44
  return null;
@@ -0,0 +1,239 @@
1
+ import { useEffect, useMemo, useRef, useState } from 'react';
2
+ import { CSSVariables } from '../../utils/types.js';
3
+ import { EmbedVideoIslandProps, EmbedVideoParams } from '../types.js';
4
+ import styles from './index.module.scss';
5
+
6
+ const toPx = (value: number | string | undefined) => {
7
+ if (typeof value === 'number') {
8
+ return `${value.toString()}px`;
9
+ } else if (typeof value === 'string') {
10
+ const parsed = parseFloat(value);
11
+ return isNaN(parsed) ? undefined : `${parsed}px`;
12
+ }
13
+
14
+ return undefined;
15
+ };
16
+
17
+ const getSizeStyles = (
18
+ embedVideoParams: EmbedVideoParams,
19
+ oembedData: EmbedVideoParams['oembed_response']
20
+ ) => {
21
+ const responseWidth = oembedData?.width;
22
+ const responseHeight = oembedData?.height;
23
+ switch (embedVideoParams.size_type) {
24
+ case 'exact':
25
+ return {
26
+ width: toPx(embedVideoParams.width ?? responseWidth),
27
+ height: toPx(embedVideoParams.height ?? responseHeight),
28
+ };
29
+ case 'auto_full_width':
30
+ return {};
31
+ default:
32
+ return {
33
+ maxWidth: toPx(embedVideoParams.max_width ?? responseWidth),
34
+ maxHeight: toPx(embedVideoParams.max_height ?? responseHeight),
35
+ };
36
+ }
37
+ };
38
+
39
+ const CustomThumbnailPlayIcon = () => (
40
+ <svg viewBox="0 0 135.39 149.4">
41
+ <path
42
+ d="M371.2,398.69l-127.79,71c-1.47.83-2.74.93-3.8.28a3.69,3.69,0,0,1-1.59-3.46V324.88a3.73,3.73,0,0,1,1.59-3.47,3.66,3.66,0,0,1,3.8.29l127.79,71c1.47.84,2.21,1.82,2.21,3S372.67,397.85,371.2,398.69Z"
43
+ transform="translate(-238.02 -321)"
44
+ ></path>
45
+ </svg>
46
+ );
47
+
48
+ const OEmbedContainer = ({
49
+ embedVideoParams,
50
+ oEmbedThumbnail,
51
+ oEmbedPlayButtonColor,
52
+ }: {
53
+ embedVideoParams: EmbedVideoParams;
54
+ oEmbedThumbnail?: { src: string; alt?: string };
55
+ oEmbedPlayButtonColor?: { color?: string };
56
+ }) => {
57
+ const {
58
+ size_type: sizeType,
59
+ oembed_url: oembedUrl,
60
+ oembed_response: oembedResponse,
61
+ supported_oembed_types: supportedOembedTypes,
62
+ } = embedVideoParams;
63
+
64
+ const [oembedData, setOembedData] =
65
+ useState<EmbedVideoParams['oembed_response']>(oembedResponse);
66
+ const [hasPlayed, setHasPlayed] = useState(false);
67
+ const iframeWrapperRef = useRef<HTMLDivElement>(null);
68
+ const iframeRef = useRef<HTMLIFrameElement | null>(null);
69
+
70
+ const isSupportedOEmbedType = supportedOembedTypes.includes(
71
+ oembedData?.type || ''
72
+ );
73
+ const sizeStyles = useMemo(
74
+ () => getSizeStyles(embedVideoParams, oembedData),
75
+ [embedVideoParams, oembedData]
76
+ );
77
+
78
+ const cssVariables: CSSVariables = {
79
+ ...(oEmbedPlayButtonColor?.color && {
80
+ '--hscl-video-playButton-color': oEmbedPlayButtonColor.color,
81
+ }),
82
+ };
83
+
84
+ useEffect(() => {
85
+ if (oembedData || !oembedUrl) {
86
+ return;
87
+ }
88
+
89
+ const fetchOEmbed = async () => {
90
+ try {
91
+ const query = new URLSearchParams({
92
+ url: oembedUrl,
93
+ autoplay: '0',
94
+ });
95
+ const response = await fetch(`/_hcms/oembed?${query}`);
96
+ if (!response.ok) {
97
+ console.error('Server reached, error retrieving oEmbed response.');
98
+ return;
99
+ }
100
+ setOembedData(await response.json());
101
+ } catch {
102
+ console.error(
103
+ 'Could not reach the server. Failed to retrieve oEmbed response.'
104
+ );
105
+ }
106
+ };
107
+ fetchOEmbed();
108
+ }, [oembedUrl]);
109
+
110
+ useEffect(() => {
111
+ if (!oembedData) {
112
+ return;
113
+ }
114
+
115
+ const el = document.createElement('div');
116
+ el.innerHTML = oembedData.html;
117
+ const iframe = el.firstChild as HTMLIFrameElement;
118
+ iframe.setAttribute('class', styles['oembed_container_iframe']);
119
+ iframe.setAttribute('title', oembedData.title || '');
120
+ iframeRef.current = iframe;
121
+ if (!oEmbedThumbnail?.src) {
122
+ // if there is a custom thumbnail, iframe will be appended on click
123
+ iframeWrapperRef.current?.appendChild(iframe);
124
+ Object.assign(iframe.style, sizeStyles);
125
+ }
126
+ }, [oembedData, oEmbedThumbnail?.src]);
127
+
128
+ return (
129
+ <div
130
+ className={`${styles.oembed_container} ${
131
+ sizeType === 'auto_full_width' ? 'oembed_container--full-size' : ''
132
+ }`}
133
+ style={sizeStyles}
134
+ >
135
+ {oEmbedThumbnail?.src && (
136
+ <button
137
+ className={styles['oembed_custom-thumbnail']}
138
+ style={{
139
+ ...sizeStyles,
140
+ backgroundImage: `url(${oEmbedThumbnail.src})`,
141
+ display: hasPlayed ? 'none' : undefined,
142
+ }}
143
+ onClick={() => {
144
+ const iframe = iframeRef.current;
145
+ if (iframe) {
146
+ const iframeSrc = new URL(iframe.src);
147
+ iframeSrc.searchParams.append('autoplay', '1');
148
+ iframe.src = iframeSrc.toString();
149
+ Object.assign(iframe.style, sizeStyles);
150
+ iframeWrapperRef.current?.appendChild(iframe);
151
+ setHasPlayed(true);
152
+ }
153
+ }}
154
+ >
155
+ <span className={styles['oembed-info']}>
156
+ {[
157
+ 'Video player',
158
+ oEmbedThumbnail.alt ?? '',
159
+ 'Click to play video',
160
+ ].join(' - ')}
161
+ </span>
162
+ <div
163
+ className={styles['oembed_custom-thumbnail_icon']}
164
+ style={cssVariables}
165
+ >
166
+ <CustomThumbnailPlayIcon />
167
+ </div>
168
+ </button>
169
+ )}
170
+ {isSupportedOEmbedType && oembedData && (
171
+ <div ref={iframeWrapperRef} className={styles.iframe_wrapper} />
172
+ )}
173
+ </div>
174
+ );
175
+ };
176
+
177
+ const EmbedHTMLContainer = ({ embedHtml }: { embedHtml: string }) => {
178
+ const embedContainerRef = useRef<HTMLDivElement>(null);
179
+ const iframeWrapperRef = useRef<HTMLDivElement>(null);
180
+
181
+ useEffect(() => {
182
+ const container = embedContainerRef.current;
183
+ const iframe = iframeWrapperRef.current?.querySelector('iframe');
184
+
185
+ if (!container || !iframe) {
186
+ return;
187
+ }
188
+
189
+ const maxHeight = iframe.getAttribute('height');
190
+ const maxWidth = iframe.getAttribute('width');
191
+ if (maxHeight !== null) {
192
+ container.style.maxHeight = toPx(maxHeight);
193
+ } else {
194
+ iframe.style.height = '100%';
195
+ }
196
+ if (maxWidth !== null) {
197
+ container.style.maxWidth = toPx(maxWidth);
198
+ } else {
199
+ iframe.style.width = '100%';
200
+ }
201
+ }, []);
202
+
203
+ return (
204
+ <div ref={embedContainerRef} className={styles.embed_container}>
205
+ <div
206
+ ref={iframeWrapperRef}
207
+ className={styles.iframe_wrapper}
208
+ dangerouslySetInnerHTML={{ __html: embedHtml }}
209
+ />
210
+ </div>
211
+ );
212
+ };
213
+
214
+ const EmbedVideoIsland = ({
215
+ embedVideoParams,
216
+ oembedThumbnail,
217
+ playButtonColor,
218
+ }: EmbedVideoIslandProps) => {
219
+ if (
220
+ embedVideoParams.source_type === 'oembed' &&
221
+ embedVideoParams.oembed_url
222
+ ) {
223
+ return (
224
+ <OEmbedContainer
225
+ embedVideoParams={embedVideoParams}
226
+ oEmbedThumbnail={oembedThumbnail}
227
+ oEmbedPlayButtonColor={playButtonColor}
228
+ />
229
+ );
230
+ }
231
+
232
+ if (embedVideoParams.source_type === 'html' && embedVideoParams.embed_html) {
233
+ return <EmbedHTMLContainer embedHtml={embedVideoParams.embed_html} />;
234
+ }
235
+
236
+ return null;
237
+ };
238
+
239
+ export default EmbedVideoIsland;
@@ -0,0 +1,94 @@
1
+ .oembed_container {
2
+ display: inline-block;
3
+ position: relative;
4
+ width: 100%;
5
+ height: 100%;
6
+ }
7
+
8
+ .oembed_container_iframe {
9
+ height: 100%;
10
+ left: 0;
11
+ margin: 0 auto;
12
+ position: absolute;
13
+ right: 0;
14
+ top: 0;
15
+ width: 100%;
16
+ }
17
+
18
+ .oembed_custom-thumbnail,
19
+ .oembed_custom-thumbnail:hover,
20
+ .oembed_custom-thumbnail:focus,
21
+ .oembed_custom-thumbnail:active {
22
+ align-items: center;
23
+ appearance: none;
24
+ background-color: transparent;
25
+ background-position: center center;
26
+ background-repeat: no-repeat;
27
+ background-size: cover;
28
+ border-radius: 0;
29
+ border: none;
30
+ display: flex;
31
+ height: 100%;
32
+ justify-content: center;
33
+ left: 0;
34
+ margin: 0;
35
+ padding: 0;
36
+ position: absolute;
37
+ top: 0;
38
+ width: 100%;
39
+ z-index: 1;
40
+ }
41
+
42
+ .oembed_custom-thumbnail_icon {
43
+ align-items: center;
44
+ cursor: pointer;
45
+ display: flex;
46
+ justify-content: center;
47
+ width: 100%;
48
+
49
+ svg {
50
+ display: block;
51
+ height: auto;
52
+ width: 12%;
53
+ fill: var(--hscl-video-playButton-color, #ffffff);
54
+ }
55
+ }
56
+
57
+ /* SVGs in IE11 require the max-width to be set to non in order to display scaling properly */
58
+ _:-ms-fullscreen,
59
+ :root .oembed_custom-thumbnail_icon svg {
60
+ max-width: none;
61
+ fill: var(--hscl-video-playButton-color, #ffffff);
62
+ }
63
+
64
+ .oembed-info {
65
+ height: 1px;
66
+ left: -10000px;
67
+ overflow: hidden;
68
+ position: absolute;
69
+ top: auto;
70
+ width: 1px;
71
+ }
72
+
73
+ .iframe_wrapper {
74
+ height: 0;
75
+ padding-bottom: 56.25%;
76
+ padding-top: 25px;
77
+ position: relative;
78
+ }
79
+
80
+ .embed_container {
81
+ display: inline-block;
82
+ height: 100%;
83
+ position: relative;
84
+ width: 100%;
85
+ }
86
+
87
+ .embed_container iframe {
88
+ left: 0;
89
+ max-height: 100%;
90
+ max-width: 100%;
91
+ position: absolute;
92
+ right: 0;
93
+ top: 0;
94
+ }
@@ -136,8 +136,11 @@ render: () => {
136
136
  property: var(--hscl-componentName-property-hover);
137
137
  }
138
138
 
139
- &:focus {
140
- property: var(--hscl-componentName-property-focus);
139
+ // Focus-visible reuses hover styles + browser default outline
140
+ &:focus-visible {
141
+ property: var(--hscl-componentName-property-hover);
142
+ outline: 2px solid Highlight;
143
+ outline-offset: 2px;
141
144
  }
142
145
 
143
146
  &:disabled {
@@ -186,9 +189,11 @@ Use `&` for pseudo-classes and nested selectors:
186
189
  background-color: var(--hscl-button-backgroundColor-hover);
187
190
  }
188
191
 
189
- &:focus {
190
- outline: var(--hscl-button-outlineWidth-focus) solid
191
- var(--hscl-button-outlineColor-focus);
192
+ &:focus-visible {
193
+ background-color: var(--hscl-button-backgroundColor-hover);
194
+ color: var(--hscl-button-color-hover);
195
+ outline: 2px solid Highlight;
196
+ outline-offset: 2px;
192
197
  }
193
198
 
194
199
  &:disabled {
@@ -244,9 +249,11 @@ Use `&` for pseudo-classes and nested selectors:
244
249
  background-color: var(--hscl-button-backgroundColor-hover);
245
250
  }
246
251
 
247
- &:focus {
248
- outline: var(--hscl-button-outlineWidth-focus) solid
249
- var(--hscl-button-outlineColor-focus);
252
+ &:focus-visible {
253
+ background-color: var(--hscl-button-backgroundColor-hover);
254
+ color: var(--hscl-button-color-hover);
255
+ outline: 2px solid Highlight;
256
+ outline-offset: 2px;
250
257
  }
251
258
 
252
259
  &:disabled {
@@ -286,10 +293,12 @@ All interactive components should style **hover, focus, active** states:
286
293
  color: var(--hscl-button-color-hover, var(--hscl-button-color));
287
294
  }
288
295
 
289
- // Focus-visible - keyboard navigation only (not mouse clicks)
296
+ // Focus-visible - reuses hover styles + browser default outline
290
297
  &:focus-visible {
291
- outline: var(--hscl-button-outlineWidth-focus, 2px) solid var(--hscl-button-outlineColor-focus, currentColor);
292
- outline-offset: var(--hscl-button-outlineOffset-focus, 2px);
298
+ background-color: var(--hscl-button-backgroundColor-hover, var(--hscl-button-backgroundColor));
299
+ color: var(--hscl-button-color-hover, var(--hscl-button-color));
300
+ outline: 2px solid Highlight;
301
+ outline-offset: 2px;
293
302
  }
294
303
 
295
304
  // Active - pressed/clicked state
@@ -322,11 +331,17 @@ All interactive components should style **hover, focus, active** states:
322
331
  background-color: var(--hscl-button-backgroundColor-hover);
323
332
  ```
324
333
 
325
- 3. **Use `currentColor` for focus outlines**
326
- - Adapts to component's text color automatically
327
- - Ensures sufficient contrast in most cases
334
+ 3. **Reuse hover styles for focus, rely on browser default outline**
335
+ - Focus-visible should apply the same visual treatment as hover (background, color, border)
336
+ - Use `outline: 2px solid initial` for the browser's default focus ring color
337
+ - No need for separate focus-specific CSS variables
328
338
  ```scss
329
- outline: var(--hscl-button-outlineColor-focus, currentColor);
339
+ &:focus-visible {
340
+ background-color: var(--hscl-button-backgroundColor-hover, var(--hscl-button-backgroundColor));
341
+ color: var(--hscl-button-color-hover, var(--hscl-button-color));
342
+ outline: 2px solid Highlight;
343
+ outline-offset: 2px;
344
+ }
330
345
  ```
331
346
 
332
347
  4. **Respect reduced motion preferences**
@@ -360,8 +375,10 @@ See these components for implementation examples:
360
375
  property: var(--hscl-componentName-property-hover);
361
376
  }
362
377
 
363
- &:focus {
364
- property: var(--hscl-componentName-property-focus);
378
+ &:focus-visible {
379
+ property: var(--hscl-componentName-property-hover);
380
+ outline: 2px solid Highlight;
381
+ outline-offset: 2px;
365
382
  }
366
383
  }
367
384
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/cms-component-library",
3
- "version": "0.3.10",
3
+ "version": "0.3.12",
4
4
  "description": "HubSpot CMS React component library for building CMS modules",
5
5
  "license": "Apache-2.0",
6
6
  "exports": {