Skip to content

Commit cd304ef

Browse files
authored
Merge branch 'main' into dependabot/npm_and_yarn/lint-staged-15.2.2
2 parents 675f4c6 + a108c0e commit cd304ef

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1523
-616
lines changed

package-lock.json

+1,177-570
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232
"devDependencies": {
3333
"@commitlint/cli": "^17.3.0",
3434
"@commitlint/config-conventional": "^17.6.5",
35-
"@npmcli/package-json": "^3.1.1",
35+
"@npmcli/package-json": "^5.0.0",
3636
"@semantic-release/changelog": "^6.0.3",
3737
"@semantic-release/commit-analyzer": "^9.0.2",
3838
"@semantic-release/exec": "^6.0.3",
3939
"@semantic-release/git": "^10.0.1",
40-
"@semantic-release/github": "^8.0.7",
40+
"@semantic-release/github": "^8.1.0",
4141
"@semantic-release/npm": "^9.0.2",
4242
"@semantic-release/release-notes-generator": "^10.0.3",
4343
"husky": "^8.0.1",

packages/core-components/.storybook/test-runner.ts

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const customSnapshotsDir = `${process.cwd()}/__snapshots__`;
44

55
const ignoredStories = [
66
'components-assets-icon--story-070-all-icons',
7+
'components-assets-icon--story-040-size-50',
78
'components-status-feedback-modal--story-010-backdrop-dismiss',
89
'components-status-feedback-modal--story-020-esc-dismiss',
910
'components-interaction-tooltip--story-010-hover',

packages/core-components/.stylelintrc.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"selector-class-pattern": null,
66
"scss/at-rule-no-unknown": true,
77
"no-descending-specificity": null,
8-
"declaration-block-no-redundant-longhand-properties": null
8+
"declaration-block-no-redundant-longhand-properties": null,
9+
"media-query-no-invalid": null
910
}
1011
}

packages/core-components/dist/loader/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
"es2015": "./index.es2017.js",
99
"es2017": "./index.es2017.js",
1010
"unpkg": "./cdn.js"
11-
}
11+
}

packages/core-components/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@
4949
"@fullhuman/postcss-purgecss": "^5.0.0",
5050
"@stencil/postcss": "^2.1.0",
5151
"@stencil/react-output-target": "^0.5.3",
52-
"@stencil/sass": "^3.0.0",
52+
"@stencil/sass": "^3.0.10",
5353
"@storybook/addon-actions": "^7.3.2",
5454
"@storybook/addon-docs": "^7.3.2",
5555
"@storybook/addon-essentials": "^7.3.2",
5656
"@storybook/addon-interactions": "^7.3.2",
57-
"@storybook/addon-links": "^7.3.2",
57+
"@storybook/addon-links": "^7.6.17",
5858
"@storybook/addon-mdx-gfm": "^7.3.2",
5959
"@storybook/preset-scss": "^1.0.3",
6060
"@storybook/preview-api": "^7.3.2",
@@ -80,12 +80,12 @@
8080
"react": "^18.2.0",
8181
"react-dom": "^18.2.0",
8282
"remark-gfm": "^3.0.1",
83-
"sass": "^1.57.1",
83+
"sass": "^1.71.0",
8484
"sass-loader": "^13.3.2",
8585
"storybook": "^7.3.2",
8686
"style-loader": "^3.3.2",
8787
"stylelint": "^15.6.3",
88-
"stylelint-config-standard": "^33.0.0",
88+
"stylelint-config-standard": "^34.0.0",
8989
"stylelint-config-standard-scss": "^9.0.0",
9090
"ts-dedent": "^2.2.0",
9191
"ts-jest": "^29.1.1",

packages/core-components/src/components.d.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,13 @@ export namespace Components {
346346
*/
347347
"icon": IconName;
348348
/**
349-
* The size of the icon
349+
* @deprecated The size of the icon. Use the newer variant property instead.
350350
*/
351351
"size": '50' | '100' | '200';
352+
/**
353+
* Icon variant. Icon 50 is only available for select icons. Icon 100 is 24x24px and can be scaled up.
354+
*/
355+
"variant": '50' | '100';
352356
}
353357
/**
354358
* Input component
@@ -2281,9 +2285,13 @@ declare namespace LocalJSX {
22812285
*/
22822286
"icon"?: IconName;
22832287
/**
2284-
* The size of the icon
2288+
* @deprecated The size of the icon. Use the newer variant property instead.
22852289
*/
22862290
"size"?: '50' | '100' | '200';
2291+
/**
2292+
* Icon variant. Icon 50 is only available for select icons. Icon 100 is 24x24px and can be scaled up.
2293+
*/
2294+
"variant"?: '50' | '100';
22872295
}
22882296
/**
22892297
* Input component

packages/core-components/src/components/icon/__snapshots__/icon.spec.tsx.snap

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`should gracefully fail if icon is the wrong size 1`] = `
4+
<b2b-icon>
5+
<mock:shadow-root></mock:shadow-root>
6+
</b2b-icon>
7+
`;
8+
39
exports[`should gracefully fail if icon name is not found by not rendering icon and emitting a warning 1`] = `
410
<b2b-icon>
511
<mock:shadow-root></mock:shadow-root>

packages/core-components/src/components/icon/icon.docs.mdx

+24-6
Original file line numberDiff line numberDiff line change
@@ -72,27 +72,45 @@ Inherit will allow you to specify any color for the icon by first defining the p
7272
<Story id="components-assets-icon--story-035-inherit" />
7373
</Canvas>
7474

75-
### Size
76-
77-
The icon comes in three different sizes that can be adjusted according
78-
to the context the icon is used in.
75+
### Variant
7976

8077
#### 50
8178

82-
The smallest icon size at 16 x 16px. Can be used in a small button or label.
79+
This is a special variant that only a subset of icons is available in.
80+
They are marked by a `-50` suffix in the icon name. The icon 50 is 12x12px and uses bold strokes.
81+
Use this for small labels or interactive icons in a form element.
8382

8483
<Canvas columns={3} withSource="open" withToolbar={false}>
8584
<Story id="components-assets-icon--story-040-size-50" />
8685
</Canvas>
8786

8887
#### 100
8988

90-
This is the standard size of the icon, 24 x 24px. If not otherwise specified, this is the default.
89+
Standard size for the icon is 24x24px. The icon can be scaled up but not scaled down.
90+
You can change the size of the icon by overwriting the following CSS custom properties on the `b2b-icon` element:
91+
92+
```css
93+
--b2b-icon-height: 1rem;
94+
--b2b-icon-width: 1rem;
95+
```
9196

9297
<Canvas columns={3} withSource="open" withToolbar={false}>
9398
<Story id="components-assets-icon--story-050-size-100" />
9499
</Canvas>
95100

101+
### Size (Deprecated)
102+
103+
The icon comes in three different sizes that can be adjusted according
104+
to the context the icon is used in.
105+
106+
#### 50
107+
108+
The smallest icon size at 16 x 16px. Can be used in a small button or label.
109+
110+
#### 100
111+
112+
This is the standard size of the icon, 24 x 24px. If not otherwise specified, this is the default.
113+
96114
#### 200
97115

98116
This is a big icon with a size of 32 x 32px. It should not be used within

packages/core-components/src/components/icon/icon.scss

+14
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
:host {
44
--b2b-icon-line-height: inherit;
55
--b2b-icon-cursor: default;
6+
--b2b-icon-width: var(--b2b-size-60);
7+
--b2b-icon-height: var(--b2b-size-60);
68

79
.b2b-icon {
810
display: inline-flex;
@@ -19,6 +21,18 @@
1921
height: var(--b2b-size-40);
2022
}
2123

24+
&.b2b-icon--variant-50 {
25+
width: var(--b2b-size-30);
26+
height: var(--b2b-size-30);
27+
}
28+
29+
&.b2b-icon--variant-100 {
30+
width: var(--b2b-icon-width);
31+
height: var(--b2b-icon-height);
32+
min-width: var(--b2b-size-60);
33+
min-height: var(--b2b-size-60);
34+
}
35+
2236
&.b2b-icon--100 {
2337
width: var(--b2b-size-60);
2438
height: var(--b2b-size-60);

packages/core-components/src/components/icon/icon.spec.tsx

+12
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,15 @@ it('should gracefully fail if icon name is not found by not rendering icon and e
2121
expect(page.root).toMatchSnapshot();
2222
expect(console.warn).toBeCalled();
2323
});
24+
25+
it('should gracefully fail if icon is the wrong size', async () => {
26+
// @ts-ignore
27+
global.console.warn = jest.fn();
28+
const page = await newSpecPage({
29+
components: [B2bIcon],
30+
// @ts-ignore
31+
template: () => <b2b-icon icon="b2b_icon-edit" variant="50"></b2b-icon>,
32+
});
33+
expect(page.root).toMatchSnapshot();
34+
expect(console.warn).toBeCalled();
35+
});

packages/core-components/src/components/icon/icon.stories.tsx

+20-17
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@ import { getArgTypes } from '../../docs/config/utils';
44
import { iconTypes } from './types';
55
import './icon.stories.scss';
66

7-
const Template: Story = ({ icon, color, size }) => {
8-
return html`<b2b-icon icon="${icon}" color="${color}" size="${size}" />`;
7+
const Template: Story = ({ icon, color, variant }) => {
8+
return html`<b2b-icon
9+
icon="${icon}"
10+
color="${color}"
11+
variant="${variant}" />`;
912
};
1013

1114
const defaultArgs = {
1215
icon: 'b2b_icon-edit',
1316
color: 'primary',
14-
size: '100',
17+
variant: '100',
1518
};
1619

1720
export const story010Primary = Template.bind({});
@@ -31,46 +34,46 @@ story030Inverse.parameters = {
3134
},
3235
};
3336

34-
export const story035Inherit: Story = ({ icon, color, size }) => {
37+
export const story035Inherit: Story = ({ icon, color, variant }) => {
3538
return html` <div style="color: red;">
36-
<b2b-icon icon="${icon}" color="${color}" size="${size}" />
39+
<b2b-icon icon="${icon}" color="${color}" variant="${variant}" />
3740
</div>`;
3841
};
3942
story035Inherit.args = { ...defaultArgs, color: 'inherit' };
4043
story035Inherit.storyName = 'Inherit';
4144

4245
export const story040Size50 = Template.bind({});
43-
story040Size50.args = { ...defaultArgs, size: '50' };
44-
story040Size50.storyName = 'Size 50';
46+
story040Size50.args = {
47+
...defaultArgs,
48+
variant: '50',
49+
icon: 'b2b_icon-info-50',
50+
};
51+
story040Size50.storyName = 'Variant 50';
4552

4653
export const story050Size100 = Template.bind({});
4754
story050Size100.args = defaultArgs;
48-
story050Size100.storyName = 'Size 100';
49-
50-
export const story060Size200 = Template.bind({});
51-
story060Size200.args = { ...defaultArgs, size: '200' };
52-
story060Size200.storyName = 'Size 200';
55+
story050Size100.storyName = 'Variant 100';
5356

54-
export const story070AllIcons: Story = ({ color, size }) => {
57+
export const story070AllIcons: Story = ({ color, variant }) => {
5558
// not using a self-closing tag as that messes up with the display order of the icon and paragraph
5659
const icons = iconTypes.map(icon => {
5760
return html`
5861
<div class="icon-container">
5962
<b2b-icon
6063
icon="${icon}"
6164
color="${color || defaultArgs.color}"
62-
size="${size || 200}"></b2b-icon>
65+
variant="${variant || 100}"></b2b-icon>
6366
<p>${icon}</p>
6467
</div>
6568
`;
6669
});
6770
return html`<div class="icons-grid-container">${icons}</div>`;
6871
};
69-
story070AllIcons.args = { color: 'primary', size: '200' };
72+
story070AllIcons.args = { color: 'primary', variant: '100' };
7073
story070AllIcons.storyName = 'All Icons';
7174

7275
const controls = {
73-
size: 'radio',
76+
variant: 'radio',
7477
color: 'radio',
7578
icon: 'select',
7679
};
@@ -79,6 +82,6 @@ const iconArgs = getArgTypes('b2b-icon', controls);
7982

8083
export default {
8184
title: 'Components/Assets/Icon',
82-
argTypes: iconArgs,
85+
argTypes: { ...iconArgs, size: { controls: false } },
8386
viewMode: 'docs',
8487
} as Meta;

packages/core-components/src/components/icon/icon.tsx

+26-4
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ export class B2bIcon {
1515
/** The color of the icon */
1616
@Prop() color: 'primary' | 'secondary' | 'inverse' | 'inherit' = 'inherit';
1717

18-
/** The size of the icon */
18+
/** @deprecated The size of the icon. Use the newer variant property instead. */
1919
@Prop() size: '50' | '100' | '200' = '100';
2020

21+
/** Icon variant. Icon 50 is only available for select icons. Icon 100 is 24x24px and can be scaled up. */
22+
@Prop() variant: '50' | '100';
23+
2124
/** Will display a pointer cursor when hovering the icon */
2225
@Prop() clickable: boolean = false;
2326

@@ -27,18 +30,30 @@ export class B2bIcon {
2730
this.loadIconPathData();
2831
}
2932

30-
private isIconSupported = () => {
33+
private isIconSupported = (): boolean => {
3134
return iconTypes.includes(this.icon);
3235
};
3336

37+
private isIconCorrectSize = (): boolean => {
38+
if (Boolean(this.variant)) {
39+
const isSmall = this.icon.includes('50') && this.variant != '50';
40+
const isBig = !this.icon.includes('50') && this.variant === '50';
41+
return !(isSmall || isBig);
42+
} else {
43+
return true;
44+
}
45+
};
46+
3447
render() {
35-
if (!this.isIconSupported()) return null;
48+
if (!this.isIconSupported() || !this.isIconCorrectSize()) return null;
3649
return (
3750
<Host>
3851
<div
3952
class={{
4053
'b2b-icon': true,
41-
[`b2b-icon--${this.size}`]: true,
54+
[`b2b-icon--${this.size}`]:
55+
Boolean(this.size) && !Boolean(this.variant),
56+
[`b2b-icon--variant-${this.variant}`]: Boolean(this.variant),
4257
[`b2b-icon--${this.color}`]: true,
4358
'b2b-icon--clickable': this.clickable,
4459
}}
@@ -54,6 +69,13 @@ export class B2bIcon {
5469
'icon name: ' + this.icon + ' is not supported or might have a typo.',
5570
);
5671
return;
72+
} else if (!this.isIconCorrectSize()) {
73+
console.warn(
74+
'you are trying to use ' +
75+
this.icon +
76+
' as a size 50 icon but have specified an incorrect variant property. Please make sure that all icons with the suffix -50 are of variant 50.',
77+
);
78+
return;
5779
}
5880
const icon = buildPath(this.icon);
5981

Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)