Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pie-icons-webc): DSW-000 set height and width on icon hosts #1367

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/polite-donkeys-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@justeattakeaway/pie-icons-webc": minor
---

[Changed] - Apply height and widths of svg to host element to ensure correct sizings in the browser
7 changes: 7 additions & 0 deletions packages/tools/pie-icons-webc/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ const componentSelector = '${kebabCase(name)}';
export class ${name} extends LitElement implements IconProps {
// The following styles make sure that the icon will be sized correctly
static styles = css\`
:host {
display: inline-block;
}
:host svg {
display: var(--icon-display-override);
width: var(--icon-size-override);
Expand All @@ -58,6 +61,8 @@ export class ${name} extends LitElement implements IconProps {
super.connectedCallback();
if (this._svg?.getAttribute('width') === null) {
const svgSize = getSvgProps('${svgClasses}', '', null, '${name}');
this.style.width = \`\${\`var(--icon-size-override,\${svgSize.width}\`}px)\`;
this.style.height = \`\${\`var(--icon-size-override,\${svgSize.height}\`}px)\`;
this._svg?.setAttribute('width', svgSize.width);
this._svg?.setAttribute('height', svgSize.height);
}
Expand All @@ -69,6 +74,8 @@ export class ${name} extends LitElement implements IconProps {
if (changedProperties.has('size')) {
svgSize = getSvgProps('${svgClasses}', '', this.size, '${name}');

this.style.width = \`\${\`var(--icon-size-override,\${svgSize.width}\`}px)\`;
this.style.height = \`\${\`var(--icon-size-override,\${svgSize.height}\`}px)\`;
this._svg?.setAttribute('width', svgSize.width);
this._svg?.setAttribute('height', svgSize.height);
}
Expand Down
29 changes: 14 additions & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -27383,20 +27383,6 @@ __metadata:
languageName: node
linkType: hard

"node-fetch@npm:2, node-fetch@npm:^2.0.0, node-fetch@npm:^2.5.0, node-fetch@npm:^2.6.1, node-fetch@npm:^2.6.7":
version: 2.7.0
resolution: "node-fetch@npm:2.7.0"
dependencies:
whatwg-url: ^5.0.0
peerDependencies:
encoding: ^0.1.0
peerDependenciesMeta:
encoding:
optional: true
checksum: d76d2f5edb451a3f05b15115ec89fc6be39de37c6089f1b6368df03b91e1633fd379a7e01b7ab05089a25034b2023d959b47e59759cb38d88341b2459e89d6e5
languageName: node
linkType: hard

"node-fetch@npm:2.6.1":
version: 2.6.1
resolution: "node-fetch@npm:2.6.1"
Expand All @@ -27418,6 +27404,20 @@ __metadata:
languageName: node
linkType: hard

"node-fetch@npm:^2.0.0, node-fetch@npm:^2.5.0, node-fetch@npm:^2.6.1, node-fetch@npm:^2.6.7":
version: 2.7.0
resolution: "node-fetch@npm:2.7.0"
dependencies:
whatwg-url: ^5.0.0
peerDependencies:
encoding: ^0.1.0
peerDependenciesMeta:
encoding:
optional: true
checksum: d76d2f5edb451a3f05b15115ec89fc6be39de37c6089f1b6368df03b91e1633fd379a7e01b7ab05089a25034b2023d959b47e59759cb38d88341b2459e89d6e5
languageName: node
linkType: hard

"node-fetch@npm:^3.2.8":
version: 3.3.2
resolution: "node-fetch@npm:3.3.2"
Expand Down Expand Up @@ -29152,7 +29152,6 @@ __metadata:
glob: 10.3.3
husky: 8.0.3
jsdom: 24.0.0
node-fetch: 2
npm-run-all: 4.1.5
pinst: 3.0.0
postcss: 8.4.32
Expand Down
Loading