@hubspot/cms-component-library 0.3.0 → 0.3.2
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/Button/index.tsx +1 -1
- 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/Flex/index.module.scss +4 -6
- package/components/componentLibrary/Flex/llm.txt +5 -7
- package/components/componentLibrary/Flex/types.ts +0 -4
- package/components/componentLibrary/Icon/StyleFields.tsx +69 -0
- package/components/componentLibrary/Icon/index.module.scss +2 -2
- package/components/componentLibrary/Icon/index.tsx +6 -2
- package/components/componentLibrary/Icon/llm.txt +7 -6
- package/components/componentLibrary/Icon/stories/Icon.stories.tsx +11 -11
- package/components/componentLibrary/Icon/stories/IconDecorator.module.scss +1 -2
- package/components/componentLibrary/Icon/types.ts +26 -1
- 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/components/componentLibrary/_patterns/css-patterns.md +7 -18
- package/package.json +4 -4
- package/components/componentLibrary/Divider/ContentFields.tsx +0 -63
- package/components/componentLibrary/Heading/ContentFields.tsx +0 -37
- package/components/componentLibrary/Heading/StyleFields.tsx +0 -40
- package/components/componentLibrary/Heading/index.module.scss +0 -11
- package/components/componentLibrary/Heading/index.tsx +0 -52
- package/components/componentLibrary/Heading/llm.txt +0 -175
- package/components/componentLibrary/Heading/stories/Heading.stories.tsx +0 -88
- package/components/componentLibrary/Heading/stories/HeadingDecorator.module.scss +0 -47
- package/components/componentLibrary/Heading/stories/HeadingDecorator.tsx +0 -8
- package/components/componentLibrary/Heading/types.ts +0 -35
|
@@ -1,45 +1,56 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AlignmentFieldDefaults,
|
|
3
|
+
ColorFieldDefaults,
|
|
4
|
+
} from '@hubspot/cms-components/fields';
|
|
1
5
|
import type { CSSVariables } from '../utils/types.js';
|
|
2
6
|
|
|
3
|
-
|
|
7
|
+
type AlignmentValue = typeof AlignmentFieldDefaults;
|
|
8
|
+
type ColorValue = typeof ColorFieldDefaults;
|
|
4
9
|
|
|
5
|
-
export type
|
|
10
|
+
export type DividerOrientation = 'horizontal' | 'vertical';
|
|
6
11
|
|
|
7
12
|
export type DividerBorderStyle = 'solid' | 'dotted' | 'dashed' | 'double';
|
|
8
13
|
|
|
14
|
+
export type DividerAlignmentDirection = 'HORIZONTAL' | 'VERTICAL';
|
|
15
|
+
|
|
9
16
|
type PixelValue = `${number}px`;
|
|
10
17
|
|
|
11
18
|
export type DividerProps = {
|
|
12
19
|
orientation?: DividerOrientation;
|
|
13
|
-
alignment?:
|
|
20
|
+
alignment?: AlignmentValue;
|
|
14
21
|
spacing?: PixelValue;
|
|
15
22
|
borderStyle?: DividerBorderStyle;
|
|
16
23
|
length?: number;
|
|
17
24
|
thickness?: number;
|
|
25
|
+
color?: ColorValue;
|
|
18
26
|
variant?: 'primary' | 'secondary' | 'tertiary';
|
|
19
27
|
className?: string;
|
|
20
28
|
style?: CSSVariables;
|
|
21
29
|
};
|
|
22
30
|
|
|
23
|
-
export type
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
alignmentDefault?: string;
|
|
30
|
-
lengthLabel?: string;
|
|
31
|
-
lengthName?: string;
|
|
32
|
-
lengthDefault?: number;
|
|
33
|
-
thicknessLabel?: string;
|
|
34
|
-
thicknessName?: string;
|
|
35
|
-
thicknessDefault?: number;
|
|
36
|
-
};
|
|
31
|
+
export type StyleFieldName =
|
|
32
|
+
| 'borderStyle'
|
|
33
|
+
| 'color'
|
|
34
|
+
| 'thickness'
|
|
35
|
+
| 'length'
|
|
36
|
+
| 'alignment';
|
|
37
37
|
|
|
38
38
|
export type StyleFieldsProps = {
|
|
39
|
-
|
|
40
|
-
spacingName?: string;
|
|
41
|
-
spacingDefault?: string;
|
|
39
|
+
hideFields?: StyleFieldName[];
|
|
42
40
|
borderStyleLabel?: string;
|
|
43
41
|
borderStyleName?: string;
|
|
44
42
|
borderStyleDefault?: string;
|
|
43
|
+
thicknessLabel?: string;
|
|
44
|
+
thicknessName?: string;
|
|
45
|
+
thicknessDefault?: number;
|
|
46
|
+
lengthLabel?: string;
|
|
47
|
+
lengthName?: string;
|
|
48
|
+
lengthDefault?: number;
|
|
49
|
+
alignmentLabel?: string;
|
|
50
|
+
alignmentName?: string;
|
|
51
|
+
alignmentDefault?: AlignmentValue;
|
|
52
|
+
alignmentDirection?: DividerAlignmentDirection;
|
|
53
|
+
colorLabel?: string;
|
|
54
|
+
colorName?: string;
|
|
55
|
+
colorDefault?: ColorValue;
|
|
45
56
|
};
|
|
@@ -9,12 +9,10 @@
|
|
|
9
9
|
align-items: var(--hscl-flex-alignItems, stretch);
|
|
10
10
|
align-content: var(--hscl-flex-alignContent, stretch);
|
|
11
11
|
gap: var(--hscl-flex-gap, 0);
|
|
12
|
-
padding: var(--hscl-flex-
|
|
13
|
-
padding-
|
|
14
|
-
|
|
15
|
-
margin: var(--hscl-flex-
|
|
16
|
-
margin-inline: var(--hscl-flex-marginInline);
|
|
17
|
-
margin-block: var(--hscl-flex-marginBlock);
|
|
12
|
+
padding-inline: var(--hscl-flex-paddingInline, 0);
|
|
13
|
+
padding-block: var(--hscl-flex-paddingBlock, 0);
|
|
14
|
+
margin-inline: var(--hscl-flex-marginInline, 0);
|
|
15
|
+
margin-block: var(--hscl-flex-marginBlock, 0);
|
|
18
16
|
max-width: var(--hscl-flex-maxWidth, 100%);
|
|
19
17
|
max-height: var(--hscl-flex-maxHeight, auto);
|
|
20
18
|
}
|
|
@@ -47,7 +47,7 @@ Flex/
|
|
|
47
47
|
maxHeight?: string; // Maximum height constraint
|
|
48
48
|
inline?: boolean; // Use inline-flex instead of flex (default: false)
|
|
49
49
|
className?: string; // Additional CSS classes
|
|
50
|
-
style?:
|
|
50
|
+
style?: CSSVariables; // Inline styles and CSS variable overrides
|
|
51
51
|
children?: React.ReactNode; // Child elements
|
|
52
52
|
}
|
|
53
53
|
```
|
|
@@ -169,12 +169,10 @@ The Flex component uses CSS variables for all styling properties:
|
|
|
169
169
|
- `--hscl-flex-alignItems`: Cross axis alignment (default: 'stretch')
|
|
170
170
|
- `--hscl-flex-alignContent`: Multi-line alignment (default: 'stretch')
|
|
171
171
|
- `--hscl-flex-gap`: Gap between items
|
|
172
|
-
- `--hscl-flex-
|
|
173
|
-
- `--hscl-flex-
|
|
174
|
-
- `--hscl-flex-
|
|
175
|
-
- `--hscl-flex-
|
|
176
|
-
- `--hscl-flex-marginInline`: Horizontal margin
|
|
177
|
-
- `--hscl-flex-marginBlock`: Vertical margin
|
|
172
|
+
- `--hscl-flex-paddingInline`: Horizontal padding (default: 0)
|
|
173
|
+
- `--hscl-flex-paddingBlock`: Vertical padding (default: 0)
|
|
174
|
+
- `--hscl-flex-marginInline`: Horizontal margin (default: 0)
|
|
175
|
+
- `--hscl-flex-marginBlock`: Vertical margin (default: 0)
|
|
178
176
|
- `--hscl-flex-maxWidth`: Maximum width (default: 100%)
|
|
179
177
|
- `--hscl-flex-maxHeight`: Maximum height (default: auto)
|
|
180
178
|
|
|
@@ -48,12 +48,8 @@ export type FlexProps = {
|
|
|
48
48
|
alignItems?: FlexAlignItems;
|
|
49
49
|
alignContent?: FlexAlignContent;
|
|
50
50
|
gap?: string;
|
|
51
|
-
rowGap?: string;
|
|
52
|
-
columnGap?: string;
|
|
53
|
-
padding?: string;
|
|
54
51
|
paddingInline?: string;
|
|
55
52
|
paddingBlock?: string;
|
|
56
|
-
margin?: string;
|
|
57
53
|
marginInline?: string;
|
|
58
54
|
marginBlock?: string;
|
|
59
55
|
inline?: boolean;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { ColorField, ChoiceField } from '@hubspot/cms-components/fields';
|
|
2
|
+
import type { StyleFieldsProps } from './types.js';
|
|
3
|
+
|
|
4
|
+
const StyleFields = ({
|
|
5
|
+
hideFields = [],
|
|
6
|
+
iconColorLabel = 'Icon color',
|
|
7
|
+
iconColorName = 'iconColor',
|
|
8
|
+
iconColorDefault = { color: '#A8A8A8', opacity: 100 },
|
|
9
|
+
iconBackgroundColorLabel = 'Background color',
|
|
10
|
+
iconBackgroundColorName = 'iconBackgroundColor',
|
|
11
|
+
iconBackgroundColorDefault = { color: '#2C2C2C', opacity: 100 },
|
|
12
|
+
iconShapeLabel = 'Icon shape',
|
|
13
|
+
iconShapeName = 'iconShape',
|
|
14
|
+
iconShapeDefault = '0px',
|
|
15
|
+
iconSizeLabel = 'Icon size',
|
|
16
|
+
iconSizeName = 'iconSize',
|
|
17
|
+
iconSizeDefault = '16',
|
|
18
|
+
}: StyleFieldsProps) => {
|
|
19
|
+
return (
|
|
20
|
+
<>
|
|
21
|
+
{!hideFields.includes('iconColor') && (
|
|
22
|
+
<ColorField
|
|
23
|
+
label={iconColorLabel}
|
|
24
|
+
name={iconColorName}
|
|
25
|
+
default={iconColorDefault}
|
|
26
|
+
showOpacity={false}
|
|
27
|
+
/>
|
|
28
|
+
)}
|
|
29
|
+
{!hideFields.includes('iconBackgroundColor') && (
|
|
30
|
+
<ColorField
|
|
31
|
+
label={iconBackgroundColorLabel}
|
|
32
|
+
name={iconBackgroundColorName}
|
|
33
|
+
default={iconBackgroundColorDefault}
|
|
34
|
+
showOpacity={false}
|
|
35
|
+
/>
|
|
36
|
+
)}
|
|
37
|
+
{!hideFields.includes('iconShape') && (
|
|
38
|
+
<ChoiceField
|
|
39
|
+
label={iconShapeLabel}
|
|
40
|
+
name={iconShapeName}
|
|
41
|
+
display="buttons"
|
|
42
|
+
preset="icon_shape"
|
|
43
|
+
choices={[
|
|
44
|
+
['0px', 'Square'],
|
|
45
|
+
['8px', 'Rounded'],
|
|
46
|
+
['100%', 'Circle'],
|
|
47
|
+
]}
|
|
48
|
+
default={iconShapeDefault}
|
|
49
|
+
required={true}
|
|
50
|
+
/>
|
|
51
|
+
)}
|
|
52
|
+
{!hideFields.includes('iconSize') && (
|
|
53
|
+
<ChoiceField
|
|
54
|
+
label={iconSizeLabel}
|
|
55
|
+
name={iconSizeName}
|
|
56
|
+
choices={[
|
|
57
|
+
['16', 'Small (16x16 px)'],
|
|
58
|
+
['24', 'Medium (24x24 px)'],
|
|
59
|
+
['32', 'Large (32x32 px)'],
|
|
60
|
+
]}
|
|
61
|
+
default={iconSizeDefault}
|
|
62
|
+
required={true}
|
|
63
|
+
/>
|
|
64
|
+
)}
|
|
65
|
+
</>
|
|
66
|
+
);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export default StyleFields;
|
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
justify-content: center;
|
|
5
5
|
fill: var(--hscl-icon-fill);
|
|
6
6
|
stroke: var(--hscl-icon-stroke);
|
|
7
|
-
width: var(--hscl-icon-
|
|
8
|
-
height: var(--hscl-icon-
|
|
7
|
+
width: var(--hscl-icon-size);
|
|
8
|
+
height: var(--hscl-icon-size);
|
|
9
9
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import styles from './index.module.scss';
|
|
2
2
|
import { Icon as CMSIcon } from '@hubspot/cms-components';
|
|
3
3
|
import ContentFields from './ContentFields.js';
|
|
4
|
+
import StyleFields from './StyleFields.js';
|
|
4
5
|
import cx from '../utils/classname.js';
|
|
5
6
|
import type { CSSVariables } from '../utils/types.js';
|
|
6
7
|
import { IconProps } from './types.js';
|
|
@@ -8,7 +9,7 @@ import { IconProps } from './types.js';
|
|
|
8
9
|
const IconComponent = ({
|
|
9
10
|
fieldPath,
|
|
10
11
|
showIcon = true,
|
|
11
|
-
|
|
12
|
+
size = 12,
|
|
12
13
|
className = '',
|
|
13
14
|
style = {},
|
|
14
15
|
purpose = 'DECORATIVE',
|
|
@@ -21,13 +22,14 @@ const IconComponent = ({
|
|
|
21
22
|
const combinedClasses = cx(defaultClasses, className);
|
|
22
23
|
|
|
23
24
|
const cssVariables: CSSVariables = {
|
|
25
|
+
'--hscl-icon-size': `${size}px`,
|
|
24
26
|
...(fill && { '--hscl-icon-fill': fill }),
|
|
25
27
|
};
|
|
26
28
|
|
|
27
29
|
return (
|
|
28
30
|
<CMSIcon
|
|
29
31
|
fieldPath={fieldPath}
|
|
30
|
-
height={
|
|
32
|
+
height={size}
|
|
31
33
|
className={combinedClasses}
|
|
32
34
|
style={{ ...cssVariables, ...style }}
|
|
33
35
|
purpose={purpose}
|
|
@@ -38,9 +40,11 @@ const IconComponent = ({
|
|
|
38
40
|
|
|
39
41
|
type IconComponentType = typeof IconComponent & {
|
|
40
42
|
ContentFields: typeof ContentFields;
|
|
43
|
+
StyleFields: typeof StyleFields;
|
|
41
44
|
};
|
|
42
45
|
|
|
43
46
|
const Icon = IconComponent as IconComponentType;
|
|
44
47
|
Icon.ContentFields = ContentFields;
|
|
48
|
+
Icon.StyleFields = StyleFields;
|
|
45
49
|
|
|
46
50
|
export default Icon;
|
|
@@ -35,7 +35,7 @@ Icon/
|
|
|
35
35
|
```tsx
|
|
36
36
|
{
|
|
37
37
|
fieldPath?: string; // Path to icon in HubSpot fields
|
|
38
|
-
|
|
38
|
+
size?: number; // Icon size in pixels, sets both width and height (default: 12)
|
|
39
39
|
fill?: string; // Icon fill color (overrides CSS variable)
|
|
40
40
|
className?: string; // Additional CSS classes
|
|
41
41
|
style?: React.CSSProperties; // Inline styles (including CSS variables)
|
|
@@ -54,7 +54,7 @@ import Icon from '@hubspot/cms-component-library/Icon';
|
|
|
54
54
|
|
|
55
55
|
<Icon
|
|
56
56
|
fieldPath="icon"
|
|
57
|
-
|
|
57
|
+
size={24}
|
|
58
58
|
/>
|
|
59
59
|
```
|
|
60
60
|
|
|
@@ -63,7 +63,7 @@ import Icon from '@hubspot/cms-component-library/Icon';
|
|
|
63
63
|
```tsx
|
|
64
64
|
<Icon
|
|
65
65
|
fieldPath="icon"
|
|
66
|
-
|
|
66
|
+
size={24}
|
|
67
67
|
purpose="SEMANTIC"
|
|
68
68
|
title="Download file"
|
|
69
69
|
/>
|
|
@@ -74,7 +74,7 @@ import Icon from '@hubspot/cms-component-library/Icon';
|
|
|
74
74
|
```tsx
|
|
75
75
|
<Icon
|
|
76
76
|
fieldPath="icon"
|
|
77
|
-
|
|
77
|
+
size={32}
|
|
78
78
|
fill="#FF7A59"
|
|
79
79
|
/>
|
|
80
80
|
```
|
|
@@ -84,7 +84,7 @@ import Icon from '@hubspot/cms-component-library/Icon';
|
|
|
84
84
|
```tsx
|
|
85
85
|
<Icon
|
|
86
86
|
fieldPath="icon"
|
|
87
|
-
|
|
87
|
+
size={20}
|
|
88
88
|
showIcon={shouldShowIcon}
|
|
89
89
|
/>
|
|
90
90
|
```
|
|
@@ -128,7 +128,7 @@ export default function IconModule({ fieldValues }) {
|
|
|
128
128
|
return (
|
|
129
129
|
<Icon
|
|
130
130
|
fieldPath="icon"
|
|
131
|
-
|
|
131
|
+
size={fieldValues.iconSize || 24}
|
|
132
132
|
showIcon={fieldValues.showIcon}
|
|
133
133
|
purpose="DECORATIVE"
|
|
134
134
|
/>
|
|
@@ -159,6 +159,7 @@ The Icon component uses CSS variables for theming and customization:
|
|
|
159
159
|
|
|
160
160
|
**Base Styles:**
|
|
161
161
|
- `--hscl-icon-fill`: Icon fill color (default: currentColor)
|
|
162
|
+
- `--hscl-icon-size`: Icon width and height (set automatically from the `size` prop)
|
|
162
163
|
|
|
163
164
|
|
|
164
165
|
## Accessibility
|
|
@@ -25,7 +25,7 @@ type Story = StoryObj<typeof meta>;
|
|
|
25
25
|
export const Default: Story = {
|
|
26
26
|
args: {
|
|
27
27
|
fieldPath: 'icon',
|
|
28
|
-
|
|
28
|
+
size: 24,
|
|
29
29
|
showIcon: true,
|
|
30
30
|
purpose: 'DECORATIVE',
|
|
31
31
|
},
|
|
@@ -37,27 +37,27 @@ export const IconSizes: Story = {
|
|
|
37
37
|
<SBContainer flex direction="row" gap="large" alignItems="center">
|
|
38
38
|
<SBContainer addBackground flex alignItems="center">
|
|
39
39
|
<h4>12px (default)</h4>
|
|
40
|
-
<Icon fieldPath="icon"
|
|
40
|
+
<Icon fieldPath="icon" size={12} />
|
|
41
41
|
</SBContainer>
|
|
42
42
|
|
|
43
43
|
<SBContainer addBackground flex alignItems="center">
|
|
44
44
|
<h4>16px</h4>
|
|
45
|
-
<Icon fieldPath="icon"
|
|
45
|
+
<Icon fieldPath="icon" size={16} />
|
|
46
46
|
</SBContainer>
|
|
47
47
|
|
|
48
48
|
<SBContainer addBackground flex alignItems="center">
|
|
49
49
|
<h4>24px</h4>
|
|
50
|
-
<Icon fieldPath="icon"
|
|
50
|
+
<Icon fieldPath="icon" size={24} />
|
|
51
51
|
</SBContainer>
|
|
52
52
|
|
|
53
53
|
<SBContainer addBackground flex alignItems="center">
|
|
54
54
|
<h4>32px</h4>
|
|
55
|
-
<Icon fieldPath="icon"
|
|
55
|
+
<Icon fieldPath="icon" size={32} />
|
|
56
56
|
</SBContainer>
|
|
57
57
|
|
|
58
58
|
<SBContainer addBackground flex alignItems="center">
|
|
59
59
|
<h4>48px</h4>
|
|
60
|
-
<Icon fieldPath="icon"
|
|
60
|
+
<Icon fieldPath="icon" size={48} />
|
|
61
61
|
</SBContainer>
|
|
62
62
|
</SBContainer>
|
|
63
63
|
),
|
|
@@ -69,34 +69,34 @@ export const Colors: Story = {
|
|
|
69
69
|
<SBContainer flex direction="row" gap="large" alignItems="center">
|
|
70
70
|
<SBContainer addBackground flex alignItems="center">
|
|
71
71
|
<h4>Default (currentColor)</h4>
|
|
72
|
-
<Icon fieldPath="icon"
|
|
72
|
+
<Icon fieldPath="icon" size={32} />
|
|
73
73
|
</SBContainer>
|
|
74
74
|
|
|
75
75
|
<SBContainer addBackground flex alignItems="center">
|
|
76
76
|
<h4>Blue Fill</h4>
|
|
77
77
|
<div className={styles.blueFill}>
|
|
78
|
-
<Icon fieldPath="icon"
|
|
78
|
+
<Icon fieldPath="icon" size={32} />
|
|
79
79
|
</div>
|
|
80
80
|
</SBContainer>
|
|
81
81
|
|
|
82
82
|
<SBContainer addBackground flex alignItems="center">
|
|
83
83
|
<h4>Red Fill</h4>
|
|
84
84
|
<div className={styles.redFill}>
|
|
85
|
-
<Icon fieldPath="icon"
|
|
85
|
+
<Icon fieldPath="icon" size={32} />
|
|
86
86
|
</div>
|
|
87
87
|
</SBContainer>
|
|
88
88
|
|
|
89
89
|
<SBContainer addBackground flex alignItems="center">
|
|
90
90
|
<h4>Green Fill</h4>
|
|
91
91
|
<div className={styles.greenFill}>
|
|
92
|
-
<Icon fieldPath="icon"
|
|
92
|
+
<Icon fieldPath="icon" size={32} />
|
|
93
93
|
</div>
|
|
94
94
|
</SBContainer>
|
|
95
95
|
|
|
96
96
|
<SBContainer addBackground flex alignItems="center">
|
|
97
97
|
<h4>Custom Stroke</h4>
|
|
98
98
|
<div className={styles.customStroke}>
|
|
99
|
-
<Icon fieldPath="icon"
|
|
99
|
+
<Icon fieldPath="icon" size={32} />
|
|
100
100
|
</div>
|
|
101
101
|
</SBContainer>
|
|
102
102
|
</SBContainer>
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
IconFieldDefaults,
|
|
3
3
|
BooleanFieldDefaults,
|
|
4
|
+
ColorFieldDefaults,
|
|
4
5
|
} from '@hubspot/cms-components/fields';
|
|
5
6
|
|
|
7
|
+
type ColorFieldValue = typeof ColorFieldDefaults;
|
|
8
|
+
|
|
6
9
|
export type IconPurpose = 'SEMANTIC' | 'DECORATIVE';
|
|
7
10
|
|
|
8
11
|
export type IconProps = {
|
|
9
12
|
fieldPath?: string;
|
|
10
|
-
|
|
13
|
+
size?: number;
|
|
11
14
|
fill?: string;
|
|
12
15
|
className?: string;
|
|
13
16
|
style?: React.CSSProperties;
|
|
@@ -36,3 +39,25 @@ export type IconContentFieldsWithToggleProps =
|
|
|
36
39
|
export type ContentFieldsProps =
|
|
37
40
|
| IconContentFieldsWithToggleProps
|
|
38
41
|
| IconContentFieldsWithoutToggleProps;
|
|
42
|
+
|
|
43
|
+
export type StyleFieldName =
|
|
44
|
+
| 'iconColor'
|
|
45
|
+
| 'iconBackgroundColor'
|
|
46
|
+
| 'iconShape'
|
|
47
|
+
| 'iconSize';
|
|
48
|
+
|
|
49
|
+
export type StyleFieldsProps = {
|
|
50
|
+
hideFields?: StyleFieldName[];
|
|
51
|
+
iconColorLabel?: string;
|
|
52
|
+
iconColorName?: string;
|
|
53
|
+
iconColorDefault?: ColorFieldValue;
|
|
54
|
+
iconBackgroundColorLabel?: string;
|
|
55
|
+
iconBackgroundColorName?: string;
|
|
56
|
+
iconBackgroundColorDefault?: ColorFieldValue;
|
|
57
|
+
iconShapeLabel?: string;
|
|
58
|
+
iconShapeName?: string;
|
|
59
|
+
iconShapeDefault?: string;
|
|
60
|
+
iconSizeLabel?: string;
|
|
61
|
+
iconSizeName?: string;
|
|
62
|
+
iconSizeDefault?: string;
|
|
63
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RichTextField,
|
|
3
|
+
RichTextFieldType,
|
|
4
|
+
} from '@hubspot/cms-components/fields';
|
|
5
|
+
import type { ContentFieldsProps } from './types.js';
|
|
6
|
+
|
|
7
|
+
// To do: These are placeholders - we can refine and add more after some UX feedback and further discussion
|
|
8
|
+
|
|
9
|
+
const headingEnabledFeatures: RichTextFieldType['enabledFeatures'] = [
|
|
10
|
+
'block',
|
|
11
|
+
'alignment',
|
|
12
|
+
'indents',
|
|
13
|
+
'lists',
|
|
14
|
+
'standard_emphasis',
|
|
15
|
+
'advanced_emphasis',
|
|
16
|
+
'link',
|
|
17
|
+
'personalize',
|
|
18
|
+
'nonbreaking_space',
|
|
19
|
+
'source_code',
|
|
20
|
+
'visual_blocks',
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
const bodyContentEnabledFeatures: RichTextFieldType['enabledFeatures'] = [
|
|
24
|
+
'block',
|
|
25
|
+
'alignment',
|
|
26
|
+
'indents',
|
|
27
|
+
'lists',
|
|
28
|
+
'standard_emphasis',
|
|
29
|
+
'advanced_emphasis',
|
|
30
|
+
'link',
|
|
31
|
+
'image',
|
|
32
|
+
'emoji',
|
|
33
|
+
'table',
|
|
34
|
+
'personalize',
|
|
35
|
+
'cta',
|
|
36
|
+
'embed',
|
|
37
|
+
'video',
|
|
38
|
+
'charmap',
|
|
39
|
+
'anchor',
|
|
40
|
+
'nonbreaking_space',
|
|
41
|
+
'source_code',
|
|
42
|
+
'visual_blocks',
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
const featureSetMap = {
|
|
46
|
+
bodyContent: bodyContentEnabledFeatures,
|
|
47
|
+
heading: headingEnabledFeatures,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const ContentFields = ({
|
|
51
|
+
textLabel = 'Text',
|
|
52
|
+
textName = 'text',
|
|
53
|
+
textDefault = '<p>Text goes here.</p>',
|
|
54
|
+
textFeatureSet = 'bodyContent',
|
|
55
|
+
}: ContentFieldsProps) => {
|
|
56
|
+
return (
|
|
57
|
+
<RichTextField
|
|
58
|
+
label={textLabel}
|
|
59
|
+
name={textName}
|
|
60
|
+
default={textDefault}
|
|
61
|
+
enabledFeatures={featureSetMap[textFeatureSet]}
|
|
62
|
+
/>
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export default ContentFields;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { RichText } from '@hubspot/cms-components';
|
|
2
|
+
import styles from './index.module.scss';
|
|
3
|
+
import ContentFields from './ContentFields.js';
|
|
4
|
+
import cx from '../utils/classname.js';
|
|
5
|
+
import { TextProps } from './types.js';
|
|
6
|
+
|
|
7
|
+
const TextComponent = ({
|
|
8
|
+
fieldPath,
|
|
9
|
+
className = '',
|
|
10
|
+
style = {},
|
|
11
|
+
}: TextProps) => {
|
|
12
|
+
const defaultClasses = styles.text;
|
|
13
|
+
const combinedClasses = cx(defaultClasses, className);
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<RichText fieldPath={fieldPath} className={combinedClasses} style={style} />
|
|
17
|
+
);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
type TextComponentType = typeof TextComponent & {
|
|
21
|
+
ContentFields: typeof ContentFields;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const Text = TextComponent as TextComponentType;
|
|
25
|
+
Text.ContentFields = ContentFields;
|
|
26
|
+
|
|
27
|
+
export default Text;
|