Skip to content

Commit 7af104b

Browse files
author
agonzalez97
committed
Fixed bug margin function
1 parent 614e731 commit 7af104b

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

projects/dxc-ngx-cdk/src/lib/utils.ts

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,9 @@ export class CssUtils {
2222
}
2323

2424
getMarginValue = (margin, type) => {
25-
const marginSize = spaces[margin[type]] || "0px";
26-
return marginSize;
27-
}
28-
29-
25+
const marginSize = margin && margin !== null ? spaces[margin[type]] : "0px";
26+
return marginSize;
27+
};
3028

3129
getTopMargin(margin) {
3230
return margin && typeof margin !== "object"
@@ -175,40 +173,44 @@ export class CssUtils {
175173
return value;
176174
}
177175

178-
getBoxShadow(shadowDepth, isImportant:boolean = false) {
176+
getBoxShadow(shadowDepth, isImportant: boolean = false) {
179177
switch (shadowDepth) {
180178
case "1":
181179
return css`
182180
box-shadow: var(--box-oneShadowDepthShadowOffsetX)
183181
var(--box-oneShadowDepthShadowOffsetY)
184182
var(--box-oneShadowDepthShadowBlur)
185183
var(--box-oneShadowDepthShadowSpread)
186-
var(--box-oneShadowDepthShadowColor) ${this.isPropertyImportant(isImportant)};`;
184+
var(--box-oneShadowDepthShadowColor)
185+
${this.isPropertyImportant(isImportant)};
186+
`;
187187
case "2":
188188
return css`
189-
box-shadow: var(--box-twoShadowDepthShadowOffsetX)
190-
var(--box-twoShadowDepthShadowOffsetY)
191-
var(--box-twoShadowDepthShadowBlur)
192-
var(--box-twoShadowDepthShadowSpread)
193-
var(--box-twoShadowDepthShadowColor) ${this.isPropertyImportant(isImportant)};
194-
` ;
189+
box-shadow: var(--box-twoShadowDepthShadowOffsetX)
190+
var(--box-twoShadowDepthShadowOffsetY)
191+
var(--box-twoShadowDepthShadowBlur)
192+
var(--box-twoShadowDepthShadowSpread)
193+
var(--box-twoShadowDepthShadowColor)
194+
${this.isPropertyImportant(isImportant)};
195+
`;
195196
default:
196197
return css`
197-
box-shadow: var(--box-noneShadowDepthShadowOffsetX)
198-
var(--box-noneShadowDepthShadowOffsetY)
199-
var(--box-noneShadowDepthShadowBlur)
200-
var(--box-noneShadowDepthShadowSpread)
201-
var(--box-noneShadowDepthShadowColor) ${this.isPropertyImportant(isImportant)};
198+
box-shadow: var(--box-noneShadowDepthShadowOffsetX)
199+
var(--box-noneShadowDepthShadowOffsetY)
200+
var(--box-noneShadowDepthShadowBlur)
201+
var(--box-noneShadowDepthShadowSpread)
202+
var(--box-noneShadowDepthShadowColor)
203+
${this.isPropertyImportant(isImportant)};
202204
`;
203205
}
204206
}
205207

206208
readProperty(name: string): string {
207209
let bodyStyles = window.getComputedStyle(document.body);
208210
return bodyStyles.getPropertyValue(name);
209-
}
211+
}
210212

211-
private isPropertyImportant(isImportant){
212-
return isImportant ? ' !important': '';
213+
private isPropertyImportant(isImportant) {
214+
return isImportant ? " !important" : "";
213215
}
214216
}

0 commit comments

Comments
 (0)