@hubspot/cms-component-library 0.1.0-alpha.3 → 0.1.0-alpha.5
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/scaffolds/fields.tsx.template +1 -1
- package/components/componentLibrary/Button/scaffolds/index.ts.template +3 -3
- package/components/componentLibrary/Heading/scaffolds/index.ts.template +6 -5
- package/components/componentLibrary/Image/index.module.scss +13 -0
- package/components/componentLibrary/Image/index.tsx +54 -0
- package/package.json +5 -12
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import DefaultButton, { ButtonProps as DefaultButtonProps } from '@hubspot/cms-component-library/Button';
|
|
2
2
|
import { createComponentInstance } from '@hubspot/cms-component-library';
|
|
3
3
|
import { __NC__ContentFieldsProps, __NC__StyleFieldsProps, contentFields, styleFields } from './fields.js';
|
|
4
4
|
|
|
5
|
-
export type __NC__Props =
|
|
5
|
+
export type __NC__Props = DefaultButtonProps & {
|
|
6
6
|
variant: 'solid' | 'outline' | 'unstyled';
|
|
7
7
|
size: 'small' | 'medium' | 'large' | 'xlarge';
|
|
8
8
|
borderRadius: 'none' | 'small' | 'medium' | 'large' | 'full';
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
const __NC__ = createComponentInstance<__NC__Props>(
|
|
11
|
+
const __NC__ = createComponentInstance<__NC__Props>(DefaultButton)
|
|
12
12
|
.withContentFields<__NC__ContentFieldsProps>(contentFields)
|
|
13
13
|
.withStyleFields<__NC__StyleFieldsProps>(styleFields);
|
|
14
14
|
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { createComponentInstance } from '@hubspot/cms-component-library
|
|
2
|
-
import
|
|
3
|
-
import { HeadingProps } from '@hubspot/cms-component-library/Heading'
|
|
1
|
+
import { createComponentInstance } from '@hubspot/cms-component-library';
|
|
2
|
+
import DefaultHeading, { HeadingProps as DefaultHeadingProps } from '@hubspot/cms-component-library/Heading'
|
|
4
3
|
import { __NC__ContentFieldsProps, __NC__StyleFieldsProps, contentFields, styleFields } from './fields.js';
|
|
5
4
|
|
|
6
|
-
export type __NC__Props =
|
|
5
|
+
export type __NC__Props = DefaultHeadingProps & {
|
|
7
6
|
displayAs: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
8
7
|
};
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
const __NC__ = createComponentInstance<__NC__Props>(DefaultHeading)
|
|
11
10
|
.withContentFields<__NC__ContentFieldsProps>(contentFields)
|
|
12
11
|
.withStyleFields<__NC__StyleFieldsProps>(styleFields);
|
|
13
12
|
|
|
@@ -44,3 +43,5 @@ __NC__.setDimension('displayAs')
|
|
|
44
43
|
})
|
|
45
44
|
.createDimensionChoiceField();
|
|
46
45
|
|
|
46
|
+
export default Heading
|
|
47
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
@use '../styles/_component-base';
|
|
2
|
+
|
|
3
|
+
@layer hscl-library {
|
|
4
|
+
.image {
|
|
5
|
+
@include component-base.hscl-component-conditional('image');
|
|
6
|
+
@include component-base.hscl-component-hover-conditional('image');
|
|
7
|
+
}
|
|
8
|
+
.responsive {
|
|
9
|
+
display: var(--hscl-image-display, block);
|
|
10
|
+
max-inline-size: 100%;
|
|
11
|
+
block-size: auto;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
|
|
3
|
+
import createHsclComponent from '../utils/createHsclComponent.js';
|
|
4
|
+
import styles from './index.module.scss';
|
|
5
|
+
import { BaseAndInternalComponentProps } from '../types/index.js';
|
|
6
|
+
import cx from '../utils/classname.js';
|
|
7
|
+
|
|
8
|
+
export type ImageProps = BaseAndInternalComponentProps & {
|
|
9
|
+
src: string;
|
|
10
|
+
alt: string;
|
|
11
|
+
title?: string;
|
|
12
|
+
imgWidth: number; // <img width={imgWidth} /> (html attribute)
|
|
13
|
+
imgHeight: number; // <img height={imgHeight} /> (html attribute)
|
|
14
|
+
loading?: 'lazy' | 'eager' | 'disabled';
|
|
15
|
+
responsive?: boolean;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const componentName = 'image';
|
|
19
|
+
|
|
20
|
+
const Component = (props: ImageProps) => {
|
|
21
|
+
const {
|
|
22
|
+
title = '',
|
|
23
|
+
loading = 'lazy',
|
|
24
|
+
imgWidth,
|
|
25
|
+
imgHeight,
|
|
26
|
+
responsive = true,
|
|
27
|
+
hsclInternal: { hsclProcessedClasses, hsclProcessedStyles },
|
|
28
|
+
...rest
|
|
29
|
+
} = props;
|
|
30
|
+
|
|
31
|
+
const classes = cx(
|
|
32
|
+
hsclProcessedClasses,
|
|
33
|
+
responsive ? styles.responsive : null
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<img
|
|
38
|
+
style={hsclProcessedStyles}
|
|
39
|
+
className={classes}
|
|
40
|
+
title={title}
|
|
41
|
+
loading={loading !== 'disabled' ? loading : 'eager'}
|
|
42
|
+
width={imgWidth}
|
|
43
|
+
height={imgHeight}
|
|
44
|
+
{...rest}
|
|
45
|
+
/>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
Component.hsclComponentName = componentName;
|
|
50
|
+
Component.cssModule = styles;
|
|
51
|
+
|
|
52
|
+
const Image = createHsclComponent(Component);
|
|
53
|
+
|
|
54
|
+
export default Image;
|
package/package.json
CHANGED
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cms-component-library",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.5",
|
|
4
4
|
"description": "HubSpot CMS React component library for building CMS modules",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
|
-
"main": "index.ts",
|
|
7
|
-
"types": "index.ts",
|
|
6
|
+
"main": "./index.ts",
|
|
7
|
+
"types": "./index.ts",
|
|
8
8
|
"exports": {
|
|
9
|
-
".":
|
|
10
|
-
|
|
11
|
-
"import": "./index.ts",
|
|
12
|
-
"require": "./index.ts"
|
|
13
|
-
},
|
|
14
|
-
"./*": {
|
|
15
|
-
"types": "./components/componentLibrary/*/index.tsx",
|
|
16
|
-
"import": "./components/componentLibrary/*/index.tsx"
|
|
17
|
-
}
|
|
9
|
+
".": "./index.ts",
|
|
10
|
+
"./*": "./components/componentLibrary/*/index.tsx"
|
|
18
11
|
},
|
|
19
12
|
"bin": {
|
|
20
13
|
"hscl": "./cli/index.ts"
|