storybook-addon-sdc 0.24.6 → 0.24.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/preset.js +18 -3
- package/package.json +1 -1
package/dist/preset.js
CHANGED
|
@@ -154,9 +154,24 @@ var renderComponent = (item) => {
|
|
|
154
154
|
return `${kebabCaseName}.default.component({...${kebabCaseName}.Basic.baseArgs, ${storyArgs}, ${componentProps}})`;
|
|
155
155
|
};
|
|
156
156
|
var renderImage = (item) => {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
)
|
|
157
|
+
const attrs = { ...item.attributes ?? {} };
|
|
158
|
+
if (item.uri != null) attrs.src = item.uri;
|
|
159
|
+
if (Array.isArray(item.srcset) && item.srcset.length > 0) {
|
|
160
|
+
attrs.srcset = item.srcset.map(
|
|
161
|
+
(s) => s && typeof s === "object" ? [s.uri, s.width].filter(Boolean).join(" ") : s
|
|
162
|
+
).join(", ");
|
|
163
|
+
}
|
|
164
|
+
const mapped = {
|
|
165
|
+
width: item.width,
|
|
166
|
+
height: item.height,
|
|
167
|
+
alt: item.alt ?? "",
|
|
168
|
+
sizes: item.sizes,
|
|
169
|
+
title: item.title
|
|
170
|
+
};
|
|
171
|
+
for (const key of ["width", "height", "alt", "sizes", "title"]) {
|
|
172
|
+
if (mapped[key] != null) attrs[key] = mapped[key];
|
|
173
|
+
}
|
|
174
|
+
return JSON.stringify(`<img${toAttributes(attrs)} />`);
|
|
160
175
|
};
|
|
161
176
|
var renderElement = (item) => {
|
|
162
177
|
return JSON.stringify(
|