@mythpe/quasar-ui-qui 0.3.7 → 0.3.8
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/package.json
CHANGED
|
@@ -290,7 +290,28 @@ export const useMyth = () => {
|
|
|
290
290
|
}
|
|
291
291
|
return `${attr} ${value};`
|
|
292
292
|
}
|
|
293
|
+
const dimension = (options?: {
|
|
294
|
+
width?: string | number;
|
|
295
|
+
height?: string | number;
|
|
296
|
+
ratio?: string | number;
|
|
297
|
+
}): number | null => {
|
|
298
|
+
const is = (v: any): v is number | string => v !== undefined && v !== null
|
|
299
|
+
let { width, height, ratio } = options || {}
|
|
300
|
+
ratio = is(ratio) ? (typeof ratio === 'string' ? parseFloat(ratio) : ratio) : undefined
|
|
301
|
+
height = is(height) ? (typeof height === 'string' ? parseFloat(height) : height) : undefined
|
|
302
|
+
width = is(width) ? (typeof width === 'string' ? parseFloat(width) : width) : undefined
|
|
303
|
+
if (is(width) && is(height)) {
|
|
304
|
+
return width / height
|
|
305
|
+
}
|
|
306
|
+
if (is(ratio) && is(height)) {
|
|
307
|
+
return ratio * height
|
|
308
|
+
}
|
|
309
|
+
if (is(ratio) && is(width)) {
|
|
310
|
+
return width / ratio
|
|
311
|
+
}
|
|
293
312
|
|
|
313
|
+
return null
|
|
314
|
+
}
|
|
294
315
|
return {
|
|
295
316
|
__,
|
|
296
317
|
getPageTitle,
|
|
@@ -306,6 +327,7 @@ export const useMyth = () => {
|
|
|
306
327
|
veeRules,
|
|
307
328
|
isSmall,
|
|
308
329
|
colorStyle,
|
|
330
|
+
dimension,
|
|
309
331
|
...plugin
|
|
310
332
|
}
|
|
311
333
|
}
|