Skip to content

Commit ff8b210

Browse files
committed
fix: icon auto sizing issue
1 parent 94ea2c9 commit ff8b210

2 files changed

Lines changed: 20 additions & 14 deletions

File tree

packages/dnb-ui-lib/src/components/logo/Logo.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,22 @@ export default class Logo extends PureComponent {
5757
...rest
5858
} = this.props
5959

60+
if (parseFloat(size) > -1 && width === null && height === null) {
61+
width = size * ratio
62+
height = width / ratio
63+
} else if (parseFloat(width) > -1 && height === null) {
64+
height = width / ratio
65+
} else if (parseFloat(height) > -1 && width === null) {
66+
width = height * ratio
67+
}
68+
6069
const rootParams = {
61-
className: classnames('dnb-logo', className, _className),
70+
className: classnames(
71+
'dnb-logo',
72+
className,
73+
_className,
74+
(width > 0 || height > 0) && `dnb-logo--has-size`
75+
),
6276
role: 'img',
6377
alt: 'DNB Logo',
6478
['data-ratio']: ratio,
@@ -70,15 +84,6 @@ export default class Logo extends PureComponent {
7084
viewBox: '0 0 93.0362 64' // theese size are set to me assiosated with the svg path point values
7185
}
7286

73-
if (parseFloat(size) > -1 && width === null && height === null) {
74-
width = size * ratio
75-
height = width / ratio
76-
} else if (parseFloat(width) > -1 && height === null) {
77-
height = width / ratio
78-
} else if (parseFloat(height) > -1 && width === null) {
79-
width = height * ratio
80-
}
81-
8287
if (parseFloat(width) > -1) svgParams['width'] = width
8388
if (parseFloat(height) > -1) svgParams['height'] = height
8489
if (color) svgParams['color'] = color

packages/dnb-ui-lib/src/components/logo/style/_logo.scss

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@
99
font-size: inherit;
1010
line-height: 0;
1111

12-
width: calc(1em * attr(data-ratio));
13-
height: 1em;
14-
1512
color: var(--color-sea-green);
16-
1713
svg {
1814
fill: currentColor;
1915
}
16+
17+
&:not(&--has-size) {
18+
width: calc(1em * attr(data-ratio));
19+
height: 1em;
20+
}
2021
svg:not([width]):not([height]) {
2122
width: inherit;
2223
height: inherit;

0 commit comments

Comments
 (0)