summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSuchita Lad2025-07-16 12:16:01 +0530
committerSuchita Lad2025-07-16 12:16:01 +0530
commit1a02da8b8a81b88a6f0f56e5900fa85cc6dda198 (patch)
treeb059ff36bc489a127e1faaa7da0a92b028d11c93
parent2afdf0cdbf4902d01a6ea6569ed6c6cd066e2814 (diff)
downloadCommon-Interface-Project-1a02da8b8a81b88a6f0f56e5900fa85cc6dda198.tar.gz
Common-Interface-Project-1a02da8b8a81b88a6f0f56e5900fa85cc6dda198.tar.bz2
Common-Interface-Project-1a02da8b8a81b88a6f0f56e5900fa85cc6dda198.zip
Added objectToStyle function
-rw-r--r--blocks/eda-frontend/src/utils/GalleryUtils.js20
1 files changed, 7 insertions, 13 deletions
diff --git a/blocks/eda-frontend/src/utils/GalleryUtils.js b/blocks/eda-frontend/src/utils/GalleryUtils.js
index 32aac61e..767f4f05 100644
--- a/blocks/eda-frontend/src/utils/GalleryUtils.js
+++ b/blocks/eda-frontend/src/utils/GalleryUtils.js
@@ -177,21 +177,15 @@ export const styleToObject = (style) => {
}
export const objectToStyle = (styleObject) => {
- let style = ''
-
- for (const key in styleObject) {
- if (Object.hasOwnProperty.call(styleObject, key)) {
- const value = styleObject[key]
- if (value !== undefined && value !== null && value !== '') {
- if (key === 'default') {
- style += `${value};`
- } else {
- style += `${key}=${value};`
- }
- }
+ let style = styleObject.default
+ for (const [key, value] of Object.entries(styleObject)) {
+ if (key === 'default') {
+ continue
}
+ if (value !== undefined && value !== null && value !== '') {
+ style += `;${key}=${value}`
+ }
}
-
return style
}