@hubspot/cms-component-library 0.3.1 → 0.3.3
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/components/componentLibrary/Accordion/AccordionItem/index.module.scss +4 -0
- package/components/componentLibrary/Accordion/AccordionTitle/ContentFields.tsx +1 -0
- package/components/componentLibrary/Accordion/AccordionTitle/icons.tsx +19 -0
- package/components/componentLibrary/Accordion/AccordionTitle/index.module.scss +4 -0
- package/components/componentLibrary/Accordion/AccordionTitle/index.tsx +3 -1
- package/components/componentLibrary/Accordion/AccordionTitle/types.ts +1 -1
- package/components/componentLibrary/Accordion/llm.txt +7 -6
- package/components/componentLibrary/Accordion/stories/Accordion.stories.tsx +21 -0
- package/components/componentLibrary/Divider/StyleFields.tsx +72 -14
- package/components/componentLibrary/Divider/index.tsx +31 -16
- package/components/componentLibrary/Divider/llm.txt +97 -103
- package/components/componentLibrary/Divider/stories/Divider.stories.tsx +30 -19
- package/components/componentLibrary/Divider/types.ts +31 -20
- package/components/componentLibrary/Icon/StyleFields.tsx +69 -0
- package/components/componentLibrary/Icon/index.module.scss +11 -0
- package/components/componentLibrary/Icon/index.tsx +31 -4
- package/components/componentLibrary/Icon/llm.txt +50 -10
- package/components/componentLibrary/Icon/types.ts +29 -0
- package/components/componentLibrary/Text/ContentFields.tsx +66 -0
- package/components/componentLibrary/Text/index.module.scss +3 -0
- package/components/componentLibrary/Text/index.tsx +27 -0
- package/components/componentLibrary/Text/llm.txt +170 -0
- package/components/componentLibrary/Text/types.ts +16 -0
- package/package.json +4 -4
- package/components/componentLibrary/Divider/ContentFields.tsx +0 -63
|
@@ -57,3 +57,22 @@ export const MinusIcon = () => {
|
|
|
57
57
|
</svg>
|
|
58
58
|
);
|
|
59
59
|
};
|
|
60
|
+
|
|
61
|
+
export const CaretIcon = () => {
|
|
62
|
+
return (
|
|
63
|
+
<svg
|
|
64
|
+
className={cx(
|
|
65
|
+
styles.accordionIcon,
|
|
66
|
+
styles.accordionIconCaret,
|
|
67
|
+
'accordionIconCaret'
|
|
68
|
+
)}
|
|
69
|
+
viewBox="0 0 24 24"
|
|
70
|
+
fill="currentColor"
|
|
71
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
72
|
+
aria-hidden="true"
|
|
73
|
+
role="img"
|
|
74
|
+
>
|
|
75
|
+
<path d="M11.2445 16.5296C11.717 16.9121 12.4107 16.8859 12.8495 16.4471L17.6495 11.6471C17.9945 11.3021 18.0957 10.7884 17.9082 10.3384C17.7207 9.88836 17.2857 9.59961 16.802 9.59961H7.20195C6.7182 9.59961 6.27945 9.89211 6.09195 10.3421C5.90445 10.7921 6.00945 11.3059 6.35445 11.6471L11.1545 16.4471L11.2445 16.5296Z" />
|
|
76
|
+
</svg>
|
|
77
|
+
);
|
|
78
|
+
};
|
|
@@ -2,7 +2,7 @@ import styles from './index.module.scss';
|
|
|
2
2
|
import ContentFields from './ContentFields.js';
|
|
3
3
|
import cx from '../../utils/classname.js';
|
|
4
4
|
import { AccordionTitleProps } from './types.js';
|
|
5
|
-
import { ChevronIcon, PlusIcon, MinusIcon } from './icons.js';
|
|
5
|
+
import { ChevronIcon, PlusIcon, MinusIcon, CaretIcon } from './icons.js';
|
|
6
6
|
|
|
7
7
|
const AccordionTitleComponent = ({
|
|
8
8
|
icon = 'chevron',
|
|
@@ -24,6 +24,8 @@ const AccordionTitleComponent = ({
|
|
|
24
24
|
);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
if (icon === 'caret') return <CaretIcon />;
|
|
28
|
+
|
|
27
29
|
return null;
|
|
28
30
|
};
|
|
29
31
|
|
|
@@ -104,10 +104,10 @@ Accordion/
|
|
|
104
104
|
**Props:**
|
|
105
105
|
```tsx
|
|
106
106
|
{
|
|
107
|
-
icon?: 'chevron' | 'plus';
|
|
108
|
-
className?: string;
|
|
109
|
-
style?: React.CSSProperties;
|
|
110
|
-
children?: React.ReactNode;
|
|
107
|
+
icon?: 'chevron' | 'plus' | 'caret'; // Icon type (default: 'chevron')
|
|
108
|
+
className?: string; // Additional CSS classes
|
|
109
|
+
style?: React.CSSProperties; // Inline styles
|
|
110
|
+
children?: React.ReactNode; // Title text content
|
|
111
111
|
}
|
|
112
112
|
```
|
|
113
113
|
|
|
@@ -243,7 +243,7 @@ Configurable props for title text and icon:
|
|
|
243
243
|
|
|
244
244
|
**Fields:**
|
|
245
245
|
- `title`: TextField for accordion title text
|
|
246
|
-
- `icon`: ChoiceField for selecting icon type (chevron, plus)
|
|
246
|
+
- `icon`: ChoiceField for selecting icon type (caret, chevron, plus)
|
|
247
247
|
|
|
248
248
|
#### AccordionContent.ContentFields
|
|
249
249
|
|
|
@@ -397,6 +397,7 @@ The Accordion component uses CSS variables for theming and customization. Variab
|
|
|
397
397
|
- `.accordionIconChevron`: Chevron-specific sizing (rotates 180° when open)
|
|
398
398
|
- `.accordionIconPlus`: Plus icon (hidden when open)
|
|
399
399
|
- `.accordionIconMinus`: Minus icon (shown when open)
|
|
400
|
+
- `.accordionIconCaret`: Caret icon (rotates 180° when open)
|
|
400
401
|
|
|
401
402
|
**AccordionContent (`AccordionContent/index.module.scss`):**
|
|
402
403
|
- `.accordionContent`: Content area with padding and typography
|
|
@@ -420,7 +421,7 @@ The Accordion component follows accessibility best practices:
|
|
|
420
421
|
|
|
421
422
|
## Best Practices
|
|
422
423
|
|
|
423
|
-
- **Choose appropriate icons**: Use `chevron` for subtle indication, `plus` for clearer expand/collapse semantics (common in FAQs)
|
|
424
|
+
- **Choose appropriate icons**: Use `caret` for a compact filled triangle indicator, `chevron` for subtle indication, `plus` for clearer expand/collapse semantics (common in FAQs)
|
|
424
425
|
- **Consistent variants**: Apply the same variant to all items within an accordion for visual consistency
|
|
425
426
|
- **Gap selection**: Use any valid CSS length value (e.g., '8px', '16px', '24px', '48px') for spacing between items
|
|
426
427
|
- **Dynamic rendering**: Always provide unique `key` props when mapping arrays to AccordionItems
|
|
@@ -106,6 +106,27 @@ export const IconOptions: Story = {
|
|
|
106
106
|
</AccordionItem>
|
|
107
107
|
</Accordion>
|
|
108
108
|
</SBContainer>
|
|
109
|
+
|
|
110
|
+
<SBContainer addBackground>
|
|
111
|
+
<h4>Caret Icon</h4>
|
|
112
|
+
<Accordion gap="16px">
|
|
113
|
+
<AccordionItem>
|
|
114
|
+
<AccordionTitle icon="caret">Caret Icon</AccordionTitle>
|
|
115
|
+
<AccordionContent>
|
|
116
|
+
<p>
|
|
117
|
+
The caret icon provides a simple visual cue for the expanded
|
|
118
|
+
state.
|
|
119
|
+
</p>
|
|
120
|
+
</AccordionContent>
|
|
121
|
+
</AccordionItem>
|
|
122
|
+
<AccordionItem>
|
|
123
|
+
<AccordionTitle icon="caret">Another caret item</AccordionTitle>
|
|
124
|
+
<AccordionContent>
|
|
125
|
+
<p>This is just some caret cake.</p>
|
|
126
|
+
</AccordionContent>
|
|
127
|
+
</AccordionItem>
|
|
128
|
+
</Accordion>
|
|
129
|
+
</SBContainer>
|
|
109
130
|
</SBContainer>
|
|
110
131
|
),
|
|
111
132
|
};
|
|
@@ -1,25 +1,83 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
AlignmentField,
|
|
3
|
+
ChoiceField,
|
|
4
|
+
ColorField,
|
|
5
|
+
NumberField,
|
|
6
|
+
} from '@hubspot/cms-components/fields';
|
|
2
7
|
import { StyleFieldsProps } from './types.js';
|
|
3
8
|
|
|
4
9
|
const StyleFields = ({
|
|
5
|
-
|
|
10
|
+
hideFields = [],
|
|
11
|
+
borderStyleLabel = 'Line type',
|
|
6
12
|
borderStyleName = 'borderStyle',
|
|
7
13
|
borderStyleDefault = 'solid',
|
|
14
|
+
thicknessLabel = 'Line thickness',
|
|
15
|
+
thicknessName = 'thickness',
|
|
16
|
+
thicknessDefault = 1,
|
|
17
|
+
lengthLabel = 'Line length',
|
|
18
|
+
lengthName = 'length',
|
|
19
|
+
lengthDefault = 100,
|
|
20
|
+
alignmentLabel = 'Line alignment',
|
|
21
|
+
alignmentName = 'alignment',
|
|
22
|
+
alignmentDefault = { horizontal_align: 'CENTER', vertical_align: 'MIDDLE' },
|
|
23
|
+
alignmentDirection = 'HORIZONTAL',
|
|
24
|
+
colorLabel = 'Line color',
|
|
25
|
+
colorName = 'color',
|
|
26
|
+
colorDefault = { color: '#000000', opacity: 100 },
|
|
8
27
|
}: StyleFieldsProps) => {
|
|
9
28
|
return (
|
|
10
29
|
<>
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
[
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
30
|
+
{!hideFields.includes('borderStyle') && (
|
|
31
|
+
<ChoiceField
|
|
32
|
+
label={borderStyleLabel}
|
|
33
|
+
name={borderStyleName}
|
|
34
|
+
required={true}
|
|
35
|
+
choices={[
|
|
36
|
+
['solid', 'Solid'],
|
|
37
|
+
['dotted', 'Dotted'],
|
|
38
|
+
['dashed', 'Dashed'],
|
|
39
|
+
['double', 'Double'],
|
|
40
|
+
]}
|
|
41
|
+
default={borderStyleDefault}
|
|
42
|
+
/>
|
|
43
|
+
)}
|
|
44
|
+
{!hideFields.includes('color') && (
|
|
45
|
+
<ColorField
|
|
46
|
+
label={colorLabel}
|
|
47
|
+
name={colorName}
|
|
48
|
+
default={colorDefault}
|
|
49
|
+
showOpacity={false}
|
|
50
|
+
/>
|
|
51
|
+
)}
|
|
52
|
+
{!hideFields.includes('thickness') && (
|
|
53
|
+
<NumberField
|
|
54
|
+
label={thicknessLabel}
|
|
55
|
+
name={thicknessName}
|
|
56
|
+
required={true}
|
|
57
|
+
suffix="px"
|
|
58
|
+
min={1}
|
|
59
|
+
default={thicknessDefault}
|
|
60
|
+
/>
|
|
61
|
+
)}
|
|
62
|
+
{!hideFields.includes('length') && (
|
|
63
|
+
<NumberField
|
|
64
|
+
label={lengthLabel}
|
|
65
|
+
name={lengthName}
|
|
66
|
+
required={true}
|
|
67
|
+
suffix="%"
|
|
68
|
+
min={1}
|
|
69
|
+
max={100}
|
|
70
|
+
default={lengthDefault}
|
|
71
|
+
/>
|
|
72
|
+
)}
|
|
73
|
+
{!hideFields.includes('alignment') && (
|
|
74
|
+
<AlignmentField
|
|
75
|
+
label={alignmentLabel}
|
|
76
|
+
name={alignmentName}
|
|
77
|
+
alignmentDirection={alignmentDirection}
|
|
78
|
+
default={alignmentDefault}
|
|
79
|
+
/>
|
|
80
|
+
)}
|
|
23
81
|
</>
|
|
24
82
|
);
|
|
25
83
|
};
|
|
@@ -1,30 +1,46 @@
|
|
|
1
1
|
import styles from './index.module.scss';
|
|
2
2
|
import cx from '../utils/classname.js';
|
|
3
3
|
import type { CSSVariables } from '../utils/types.js';
|
|
4
|
-
import {
|
|
5
|
-
import ContentFields from './ContentFields.js';
|
|
4
|
+
import { DividerOrientation, DividerProps } from './types.js';
|
|
6
5
|
import StyleFields from './StyleFields.js';
|
|
7
6
|
|
|
8
|
-
const getAlignmentCSSVar = (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
const getAlignmentCSSVar = (
|
|
8
|
+
alignment: DividerProps['alignment'],
|
|
9
|
+
orientation: DividerOrientation
|
|
10
|
+
): string => {
|
|
11
|
+
if (!alignment) return 'stretch';
|
|
12
|
+
|
|
13
|
+
if (orientation === 'horizontal') {
|
|
14
|
+
switch (alignment.horizontal_align) {
|
|
15
|
+
case 'LEFT':
|
|
16
|
+
return 'flex-start';
|
|
17
|
+
case 'CENTER':
|
|
18
|
+
return 'center';
|
|
19
|
+
case 'RIGHT':
|
|
20
|
+
return 'flex-end';
|
|
21
|
+
}
|
|
22
|
+
} else {
|
|
23
|
+
switch (alignment.vertical_align) {
|
|
24
|
+
case 'TOP':
|
|
25
|
+
return 'flex-start';
|
|
26
|
+
case 'MIDDLE':
|
|
27
|
+
return 'center';
|
|
28
|
+
case 'BOTTOM':
|
|
29
|
+
return 'flex-end';
|
|
30
|
+
}
|
|
18
31
|
}
|
|
32
|
+
|
|
33
|
+
return 'stretch';
|
|
19
34
|
};
|
|
20
35
|
|
|
21
36
|
const DividerComponent = ({
|
|
22
37
|
orientation = 'horizontal',
|
|
23
|
-
alignment
|
|
38
|
+
alignment,
|
|
24
39
|
spacing,
|
|
25
40
|
borderStyle = 'solid',
|
|
26
41
|
length = 100,
|
|
27
42
|
thickness = 1,
|
|
43
|
+
color,
|
|
28
44
|
variant = 'primary', // !todo: not used atm but keeping for when we need to add variant system.
|
|
29
45
|
className = '',
|
|
30
46
|
style = {},
|
|
@@ -37,8 +53,9 @@ const DividerComponent = ({
|
|
|
37
53
|
const combinedClasses = cx(defaultClasses, className);
|
|
38
54
|
|
|
39
55
|
const cssVariables: CSSVariables = {
|
|
40
|
-
'--hscl-divider-alignment': getAlignmentCSSVar(alignment),
|
|
56
|
+
'--hscl-divider-alignment': getAlignmentCSSVar(alignment, orientation),
|
|
41
57
|
'--hscl-divider-borderStyle': borderStyle,
|
|
58
|
+
'--hscl-divider-borderColor': color?.rgba ?? color?.color,
|
|
42
59
|
[`--hscl-divider-margin${
|
|
43
60
|
orientation === 'horizontal' ? 'Block' : 'Inline'
|
|
44
61
|
}`]: spacing,
|
|
@@ -63,12 +80,10 @@ const DividerComponent = ({
|
|
|
63
80
|
|
|
64
81
|
// Create compound component with proper typing
|
|
65
82
|
type DividerComponentType = typeof DividerComponent & {
|
|
66
|
-
ContentFields: typeof ContentFields;
|
|
67
83
|
StyleFields: typeof StyleFields;
|
|
68
84
|
};
|
|
69
85
|
|
|
70
86
|
const Divider = DividerComponent as DividerComponentType;
|
|
71
|
-
Divider.ContentFields = ContentFields;
|
|
72
87
|
Divider.StyleFields = StyleFields;
|
|
73
88
|
|
|
74
89
|
export default Divider;
|
|
@@ -9,7 +9,7 @@ import Divider from '@hubspot/cms-component-library/Divider';
|
|
|
9
9
|
|
|
10
10
|
## Purpose
|
|
11
11
|
|
|
12
|
-
The Divider component provides a consistent way to create visual separators in HubSpot CMS projects. It renders semantic HTML elements (`<hr>` for horizontal, `<div role="separator">` for vertical) with flexible styling options. Developers should use this component when they need to visually separate content sections, whether between stacked content (horizontal) or side-by-side content (vertical). The component supports customizable
|
|
12
|
+
The Divider component provides a consistent way to create visual separators in HubSpot CMS projects. It renders semantic HTML elements (`<hr>` for horizontal, `<div role="separator">` for vertical) with flexible styling options. Developers should use this component when they need to visually separate content sections, whether between stacked content (horizontal) or side-by-side content (vertical). The component supports customizable line type, thickness, length, alignment, color, and spacing through props and CSS variables.
|
|
13
13
|
|
|
14
14
|
## Component Structure
|
|
15
15
|
|
|
@@ -17,7 +17,6 @@ The Divider component provides a consistent way to create visual separators in H
|
|
|
17
17
|
Divider/
|
|
18
18
|
├── index.tsx # Main component with render logic
|
|
19
19
|
├── types.ts # TypeScript type definitions
|
|
20
|
-
├── ContentFields.tsx # HubSpot field definitions for content
|
|
21
20
|
├── StyleFields.tsx # HubSpot field definitions for styling
|
|
22
21
|
├── index.module.scss # CSS module with design tokens
|
|
23
22
|
└── stories/
|
|
@@ -35,15 +34,19 @@ Divider/
|
|
|
35
34
|
**Props:**
|
|
36
35
|
```tsx
|
|
37
36
|
{
|
|
38
|
-
orientation?: 'horizontal' | 'vertical';
|
|
39
|
-
alignment?:
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
37
|
+
orientation?: 'horizontal' | 'vertical'; // Divider orientation (default: 'horizontal')
|
|
38
|
+
alignment?: { // Alignment within parent container
|
|
39
|
+
horizontal_align?: 'LEFT' | 'CENTER' | 'RIGHT';
|
|
40
|
+
vertical_align?: 'TOP' | 'MIDDLE' | 'BOTTOM';
|
|
41
|
+
};
|
|
42
|
+
spacing?: string; // Margin spacing in pixel format (e.g., '16px', '24px')
|
|
43
|
+
borderStyle?: 'solid' | 'dotted' | 'dashed' | 'double'; // Border line style (default: 'solid')
|
|
44
|
+
length?: number; // Length as percentage (1-100) of available space (default: 100)
|
|
45
|
+
thickness?: number; // Border thickness in pixels (default: 1)
|
|
46
|
+
color?: { rgba?: string; color?: string; opacity?: number }; // Line color (from ColorField or rgba value)
|
|
47
|
+
variant?: 'primary' | 'secondary' | 'tertiary'; // Visual style variant (default: 'primary')
|
|
48
|
+
className?: string; // Additional CSS classes
|
|
49
|
+
style?: React.CSSProperties; // Inline styles (including CSS variables)
|
|
47
50
|
}
|
|
48
51
|
```
|
|
49
52
|
|
|
@@ -52,10 +55,18 @@ Divider/
|
|
|
52
55
|
- `orientation="vertical"`: Renders as `<div role="separator">` with left border
|
|
53
56
|
|
|
54
57
|
**Alignment Behavior:**
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
|
|
59
|
+
When no `alignment` is passed, the divider stretches to fill the available space (default).
|
|
60
|
+
|
|
61
|
+
For horizontal dividers, use `horizontal_align`:
|
|
62
|
+
- `'LEFT'`: Aligns to the left (`flex-start`)
|
|
63
|
+
- `'CENTER'`: Centers within the container
|
|
64
|
+
- `'RIGHT'`: Aligns to the right (`flex-end`)
|
|
65
|
+
|
|
66
|
+
For vertical dividers, use `vertical_align`:
|
|
67
|
+
- `'TOP'`: Aligns to the top (`flex-start`)
|
|
68
|
+
- `'MIDDLE'`: Centers vertically
|
|
69
|
+
- `'BOTTOM'`: Aligns to the bottom (`flex-end`)
|
|
59
70
|
|
|
60
71
|
## Usage Examples
|
|
61
72
|
|
|
@@ -64,7 +75,7 @@ Divider/
|
|
|
64
75
|
```tsx
|
|
65
76
|
import Divider from '@hubspot/cms-component-library/Divider';
|
|
66
77
|
|
|
67
|
-
// Default horizontal divider
|
|
78
|
+
// Default horizontal divider (full width, stretch)
|
|
68
79
|
<Divider />
|
|
69
80
|
```
|
|
70
81
|
|
|
@@ -78,66 +89,41 @@ import Divider from '@hubspot/cms-component-library/Divider';
|
|
|
78
89
|
### Horizontal Divider with Custom Spacing
|
|
79
90
|
|
|
80
91
|
```tsx
|
|
81
|
-
|
|
82
|
-
<Divider
|
|
83
|
-
orientation="horizontal"
|
|
84
|
-
spacing="32px"
|
|
85
|
-
/>
|
|
92
|
+
<Divider spacing="32px" />
|
|
86
93
|
```
|
|
87
94
|
|
|
88
|
-
###
|
|
95
|
+
### Short Centered Divider
|
|
89
96
|
|
|
90
97
|
```tsx
|
|
91
|
-
|
|
92
|
-
<Divider
|
|
93
|
-
orientation="vertical"
|
|
94
|
-
length={80}
|
|
95
|
-
alignment="center"
|
|
96
|
-
/>
|
|
98
|
+
<Divider length={50} alignment={{ horizontal_align: 'CENTER' }} spacing="16px" />
|
|
97
99
|
```
|
|
98
100
|
|
|
99
|
-
### Customized Divider
|
|
101
|
+
### Customized Divider
|
|
100
102
|
|
|
101
103
|
```tsx
|
|
102
104
|
<Divider
|
|
103
|
-
orientation="horizontal"
|
|
104
105
|
borderStyle="dashed"
|
|
105
106
|
thickness={2}
|
|
106
107
|
length={75}
|
|
107
|
-
alignment=
|
|
108
|
+
alignment={{ horizontal_align: 'CENTER' }}
|
|
108
109
|
spacing="24px"
|
|
109
110
|
/>
|
|
110
111
|
```
|
|
111
112
|
|
|
112
|
-
###
|
|
113
|
-
|
|
114
|
-
```tsx
|
|
115
|
-
<Divider
|
|
116
|
-
orientation="horizontal"
|
|
117
|
-
thickness={4}
|
|
118
|
-
borderStyle="solid"
|
|
119
|
-
/>
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
### Dotted Divider
|
|
113
|
+
### Colored Divider
|
|
123
114
|
|
|
124
115
|
```tsx
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
borderStyle="dotted"
|
|
128
|
-
thickness={2}
|
|
129
|
-
/>
|
|
116
|
+
// color.rgba is populated by the ColorField in a module context
|
|
117
|
+
<Divider color={{ rgba: 'rgba(59, 130, 246, 1)' }} thickness={2} />
|
|
130
118
|
```
|
|
131
119
|
|
|
132
|
-
###
|
|
120
|
+
### Vertical Divider with Alignment
|
|
133
121
|
|
|
134
122
|
```tsx
|
|
135
|
-
// Decorative short divider, centered
|
|
136
123
|
<Divider
|
|
137
|
-
orientation="
|
|
124
|
+
orientation="vertical"
|
|
138
125
|
length={50}
|
|
139
|
-
alignment=
|
|
140
|
-
spacing="16px"
|
|
126
|
+
alignment={{ vertical_align: 'MIDDLE' }}
|
|
141
127
|
/>
|
|
142
128
|
```
|
|
143
129
|
|
|
@@ -158,51 +144,53 @@ import Divider from '@hubspot/cms-component-library/Divider';
|
|
|
158
144
|
|
|
159
145
|
### Field Definitions
|
|
160
146
|
|
|
161
|
-
The Divider component
|
|
147
|
+
All Divider fields are style fields. The Divider component exposes only `StyleFields` — there are no content fields.
|
|
162
148
|
|
|
163
|
-
####
|
|
149
|
+
#### StyleFields
|
|
164
150
|
|
|
165
|
-
|
|
151
|
+
All configurable style props for the divider:
|
|
166
152
|
|
|
167
153
|
```tsx
|
|
168
|
-
<Divider.
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
alignmentName="alignment"
|
|
174
|
-
alignmentDefault="stretch"
|
|
175
|
-
lengthLabel="Divider Length"
|
|
176
|
-
lengthName="length"
|
|
177
|
-
lengthDefault={100}
|
|
178
|
-
thicknessLabel="Divider Thickness"
|
|
154
|
+
<Divider.StyleFields
|
|
155
|
+
borderStyleLabel="Line type"
|
|
156
|
+
borderStyleName="borderStyle"
|
|
157
|
+
borderStyleDefault="solid"
|
|
158
|
+
thicknessLabel="Line thickness"
|
|
179
159
|
thicknessName="thickness"
|
|
180
160
|
thicknessDefault={1}
|
|
161
|
+
lengthLabel="Line length"
|
|
162
|
+
lengthName="length"
|
|
163
|
+
lengthDefault={100}
|
|
164
|
+
alignmentLabel="Line alignment"
|
|
165
|
+
alignmentName="alignment"
|
|
166
|
+
alignmentDefault={{ horizontal_align: 'CENTER', vertical_align: 'MIDDLE' }}
|
|
167
|
+
alignmentDirection="HORIZONTAL"
|
|
168
|
+
colorLabel="Line color"
|
|
169
|
+
colorName="color"
|
|
170
|
+
colorDefault={{ color: '#000000', opacity: 100 }}
|
|
181
171
|
/>
|
|
182
172
|
```
|
|
183
173
|
|
|
184
174
|
**Fields:**
|
|
185
|
-
- `
|
|
186
|
-
- `
|
|
187
|
-
- `length`: NumberField for length percentage (1
|
|
188
|
-
- `
|
|
175
|
+
- `borderStyle`: ChoiceField for line type (solid, dotted, dashed, double)
|
|
176
|
+
- `thickness`: NumberField for thickness in pixels (minimum: 1, suffix: px)
|
|
177
|
+
- `length`: NumberField for length as a percentage (1–100, suffix: %)
|
|
178
|
+
- `alignment`: AlignmentField for alignment within the container
|
|
179
|
+
- `color`: ColorField for line color (opacity hidden — color only)
|
|
189
180
|
|
|
190
|
-
|
|
181
|
+
**Developer-only props (not user-facing):**
|
|
182
|
+
- `alignmentDirection`: Controls whether the AlignmentField shows horizontal or vertical options. Accepts `'HORIZONTAL'` (default) or `'VERTICAL'`. Set this based on how the divider will be used — developers consuming the component set this, not end users.
|
|
183
|
+
- `hideFields`: An array of field names to opt out of rendering. All fields are shown by default (opt-out). Accepts an array of `StyleFieldName` values: `'borderStyle' | 'color' | 'thickness' | 'length' | 'alignment'`.
|
|
191
184
|
|
|
192
|
-
|
|
185
|
+
**Hiding fields example:**
|
|
193
186
|
|
|
194
187
|
```tsx
|
|
195
|
-
<
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
borderStyleDefault="solid"
|
|
199
|
-
/>
|
|
188
|
+
<FieldGroup label="Style" name="style" tab="STYLE">
|
|
189
|
+
<Divider.StyleFields hideFields={['alignment', 'length']} />
|
|
190
|
+
</FieldGroup>
|
|
200
191
|
```
|
|
201
192
|
|
|
202
|
-
**
|
|
203
|
-
- `borderStyle`: ChoiceField for selecting border style (solid, dotted, dashed, double)
|
|
204
|
-
|
|
205
|
-
**Note:** The `spacing` prop must be set directly on the Divider component, as there is no field definition for it in StyleFields or ContentFields.
|
|
193
|
+
**Note:** The `orientation` and `spacing` props must be set directly on the Divider component — there are no field definitions for them.
|
|
206
194
|
|
|
207
195
|
### Module Usage Example
|
|
208
196
|
|
|
@@ -210,13 +198,15 @@ Configurable props for divider border style:
|
|
|
210
198
|
import Divider from '@hubspot/cms-component-library/Divider';
|
|
211
199
|
|
|
212
200
|
export default function SectionDividerModule({ fieldValues }) {
|
|
201
|
+
const { borderStyle, thickness, length, alignment, color } = fieldValues.style;
|
|
202
|
+
|
|
213
203
|
return (
|
|
214
204
|
<Divider
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
205
|
+
borderStyle={borderStyle}
|
|
206
|
+
thickness={thickness}
|
|
207
|
+
length={length}
|
|
208
|
+
alignment={alignment}
|
|
209
|
+
color={color}
|
|
220
210
|
spacing="24px"
|
|
221
211
|
/>
|
|
222
212
|
);
|
|
@@ -231,7 +221,6 @@ import Divider from '@hubspot/cms-component-library/Divider';
|
|
|
231
221
|
|
|
232
222
|
export const fields = (
|
|
233
223
|
<ModuleFields>
|
|
234
|
-
<Divider.ContentFields />
|
|
235
224
|
<FieldGroup label="Style" name="style" tab="STYLE">
|
|
236
225
|
<Divider.StyleFields />
|
|
237
226
|
</FieldGroup>
|
|
@@ -239,24 +228,28 @@ export const fields = (
|
|
|
239
228
|
);
|
|
240
229
|
```
|
|
241
230
|
|
|
231
|
+
For a vertical divider module, pass `alignmentDirection` to expose vertical alignment options:
|
|
232
|
+
|
|
233
|
+
```tsx
|
|
234
|
+
<FieldGroup label="Style" name="style" tab="STYLE">
|
|
235
|
+
<Divider.StyleFields alignmentDirection="VERTICAL" />
|
|
236
|
+
</FieldGroup>
|
|
237
|
+
```
|
|
238
|
+
|
|
242
239
|
## Styling
|
|
243
240
|
|
|
244
241
|
### CSS Variables
|
|
245
242
|
|
|
246
243
|
The Divider component uses CSS variables for theming and customization:
|
|
247
244
|
|
|
248
|
-
**Base Styles:**
|
|
249
245
|
- `--hscl-divider-borderColor`: Border color (default: currentColor)
|
|
250
246
|
- `--hscl-divider-borderStyle`: Border style (default: solid)
|
|
251
|
-
- `--hscl-divider-
|
|
252
|
-
- `--hscl-divider-thickness`: Border thickness as pixel value (default: 1px)
|
|
247
|
+
- `--hscl-divider-borderWidth`: Border thickness as pixel value (default: 1px)
|
|
253
248
|
- `--hscl-divider-alignment`: Flex alignment value (default: stretch)
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
- `--hscl-divider-
|
|
257
|
-
|
|
258
|
-
- Vertical: Applied as `margin-inline` (left and right)
|
|
259
|
-
|
|
249
|
+
- `--hscl-divider-width`: Width for horizontal dividers (default: 100%)
|
|
250
|
+
- `--hscl-divider-height`: Height for vertical dividers (default: 100%)
|
|
251
|
+
- `--hscl-divider-marginBlock`: Top/bottom margin for horizontal dividers (default: 16px)
|
|
252
|
+
- `--hscl-divider-marginInline`: Left/right margin for vertical dividers (default: 16px)
|
|
260
253
|
|
|
261
254
|
## Accessibility
|
|
262
255
|
|
|
@@ -266,7 +259,6 @@ The Divider component follows accessibility best practices:
|
|
|
266
259
|
- Horizontal: Uses native `<hr>` element, recognized by screen readers as thematic break
|
|
267
260
|
- Vertical: Uses `<div role="separator">` for proper ARIA semantics
|
|
268
261
|
- **Keyboard Navigation**: Does not interfere with keyboard navigation as it's non-interactive
|
|
269
|
-
- **Visual Separation**: Provides clear visual boundaries between content sections
|
|
270
262
|
- **Screen Reader Support**: Properly announced by assistive technologies as content separators
|
|
271
263
|
|
|
272
264
|
## Best Practices
|
|
@@ -275,16 +267,18 @@ The Divider component follows accessibility best practices:
|
|
|
275
267
|
- Use `horizontal` for separating stacked content sections (most common)
|
|
276
268
|
- Use `vertical` for separating side-by-side content within a Flex or Grid layout
|
|
277
269
|
- **Alignment considerations**:
|
|
278
|
-
-
|
|
279
|
-
- Use `
|
|
280
|
-
- Use `
|
|
270
|
+
- Omit `alignment` for full-width/height stretch behavior (default)
|
|
271
|
+
- Use `{ horizontal_align: 'CENTER' }` for decorative short horizontal dividers
|
|
272
|
+
- Use `{ vertical_align: 'MIDDLE' }` for centered vertical dividers
|
|
273
|
+
- Set `alignmentDirection` on `StyleFields` to match the intended orientation so users see the right alignment options
|
|
281
274
|
- **Spacing guidelines**:
|
|
282
275
|
- Use `spacing` prop to control margin around the divider
|
|
283
276
|
- For horizontal dividers, spacing controls top/bottom margin
|
|
284
277
|
- For vertical dividers, spacing controls left/right margin
|
|
285
|
-
- **Length as percentage**: The `length` prop accepts 1
|
|
286
|
-
- **Thickness control**: Use the `thickness` prop for border thickness (in pixels)
|
|
287
|
-
- **
|
|
278
|
+
- **Length as percentage**: The `length` prop accepts 1–100 as a percentage, not pixel values
|
|
279
|
+
- **Thickness control**: Use the `thickness` prop for border thickness (in pixels). Double border style requires at least 3px
|
|
280
|
+
- **Color**: The `color` prop is populated from the `ColorField` in a module context. In non-module usage, pass `{ rgba: 'rgba(...)' }` directly
|
|
281
|
+
- **Line type**: Choose appropriate border style for visual hierarchy:
|
|
288
282
|
- `solid`: Default, clear separation
|
|
289
283
|
- `dashed`: Less prominent, informal
|
|
290
284
|
- `dotted`: Subtle, minimal separation
|