@hubspot/cms-component-library 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,11 +1,21 @@
|
|
|
1
|
-
import { ChoiceField } from '@hubspot/cms-components/fields';
|
|
1
|
+
import { ChoiceField, Visibility } from '@hubspot/cms-components/fields';
|
|
2
2
|
import { StyleFieldsProps } from './types.js';
|
|
3
3
|
|
|
4
4
|
const StyleFields = ({
|
|
5
5
|
buttonVariantLabel = 'Button variant',
|
|
6
6
|
buttonVariantName = 'buttonVariant',
|
|
7
7
|
buttonVariantDefault = 'primary',
|
|
8
|
+
buttonIconPositionLabel = 'Icon position',
|
|
9
|
+
buttonIconPositionName = 'buttonIconPosition',
|
|
10
|
+
buttonIconPositionDefault = 'right',
|
|
8
11
|
}: StyleFieldsProps) => {
|
|
12
|
+
// iconComponentShowIcon is the hardcoded id in @components/componentLibrary/Icon/ContentFields.tsx
|
|
13
|
+
const iconPositionVisibility: Visibility = {
|
|
14
|
+
operator: 'EQUAL',
|
|
15
|
+
controlling_field: 'iconComponentShowIcon',
|
|
16
|
+
controlling_value_regex: 'true',
|
|
17
|
+
};
|
|
18
|
+
|
|
9
19
|
return (
|
|
10
20
|
<>
|
|
11
21
|
<ChoiceField
|
|
@@ -18,6 +28,16 @@ const StyleFields = ({
|
|
|
18
28
|
]}
|
|
19
29
|
default={buttonVariantDefault}
|
|
20
30
|
/>
|
|
31
|
+
<ChoiceField
|
|
32
|
+
label={buttonIconPositionLabel}
|
|
33
|
+
name={buttonIconPositionName}
|
|
34
|
+
choices={[
|
|
35
|
+
['left', 'Left'],
|
|
36
|
+
['right', 'Right'],
|
|
37
|
+
]}
|
|
38
|
+
default={buttonIconPositionDefault}
|
|
39
|
+
visibility={iconPositionVisibility}
|
|
40
|
+
/>
|
|
21
41
|
</>
|
|
22
42
|
);
|
|
23
43
|
};
|
|
@@ -234,18 +234,22 @@ Configurable props for customizing field labels, names, and defaults:
|
|
|
234
234
|
|
|
235
235
|
#### StyleFields.tsx
|
|
236
236
|
|
|
237
|
-
Configurable props for variant
|
|
237
|
+
Configurable props for variant and icon position:
|
|
238
238
|
|
|
239
239
|
```tsx
|
|
240
240
|
<Button.StyleFields
|
|
241
241
|
buttonVariantLabel="Button variant"
|
|
242
242
|
buttonVariantName="buttonVariant"
|
|
243
243
|
buttonVariantDefault="primary"
|
|
244
|
+
buttonIconPositionLabel="Icon position"
|
|
245
|
+
buttonIconPositionName="buttonIconPosition"
|
|
246
|
+
buttonIconPositionDefault="right"
|
|
244
247
|
/>
|
|
245
248
|
```
|
|
246
249
|
|
|
247
250
|
**Fields:**
|
|
248
251
|
- `buttonVariant`: ChoiceField for selecting visual style (primary, secondary, tertiary)
|
|
252
|
+
- `buttonIconPosition`: ChoiceField for selecting icon placement (left, right). This field has a hardcoded visibility rule — it is only shown when the icon toggle is enabled (`iconComponentShowIcon === true`), which corresponds to the `BooleanField` id hardcoded in `Icon.ContentFields`.
|
|
249
253
|
|
|
250
254
|
### Module Usage Example
|
|
251
255
|
|
|
@@ -4,6 +4,8 @@ import {
|
|
|
4
4
|
} from '@hubspot/cms-components/fields';
|
|
5
5
|
import { IconContentFieldsWithToggleProps } from '../Icon/types.js';
|
|
6
6
|
|
|
7
|
+
export type IconPositionHorizontal = 'left' | 'right';
|
|
8
|
+
|
|
7
9
|
// Base props shared by all variants
|
|
8
10
|
export type BaseButtonProps = {
|
|
9
11
|
variant?: 'primary' | 'secondary' | 'tertiary'; // !todo: not used atm but keeping for when we need to add variant system.
|
|
@@ -11,7 +13,7 @@ export type BaseButtonProps = {
|
|
|
11
13
|
style?: React.CSSProperties;
|
|
12
14
|
children?: React.ReactNode;
|
|
13
15
|
iconFieldPath?: string;
|
|
14
|
-
iconPosition?:
|
|
16
|
+
iconPosition?: IconPositionHorizontal;
|
|
15
17
|
iconSize?: number;
|
|
16
18
|
showIcon?: boolean;
|
|
17
19
|
iconPurpose?: 'SEMANTIC' | 'DECORATIVE';
|
|
@@ -56,6 +58,9 @@ export type StyleFieldsProps = {
|
|
|
56
58
|
buttonVariantLabel?: string;
|
|
57
59
|
buttonVariantName?: string;
|
|
58
60
|
buttonVariantDefault?: string;
|
|
61
|
+
buttonIconPositionLabel?: string;
|
|
62
|
+
buttonIconPositionName?: string;
|
|
63
|
+
buttonIconPositionDefault?: IconPositionHorizontal;
|
|
59
64
|
};
|
|
60
65
|
|
|
61
66
|
export type RenderWithIconProps = Pick<
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cms-component-library",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "HubSpot CMS React component library for building CMS modules",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"exports": {
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
"url": "git@git.hubteam.com:HubSpot/cms-component-library.git"
|
|
17
17
|
},
|
|
18
18
|
"publishConfig": {
|
|
19
|
-
"access": "public"
|
|
19
|
+
"access": "public",
|
|
20
|
+
"registry": "https://registry.npmjs.org"
|
|
20
21
|
},
|
|
21
22
|
"type": "module",
|
|
22
23
|
"dependencies": {
|