@moda/om 18.2.0 → 18.3.0
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/CHANGELOG.md +7 -0
- package/dist/index.cjs.js +47 -16
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +47 -16
- package/dist/index.esm.js.map +1 -1
- package/dist/src/components/AspectRatioBox/AspectRatioBox.d.ts +4 -4
- package/dist/src/components/Text/Text.d.ts +1 -1
- package/package.json +2 -2
- package/src/components/AspectRatioBox/AspectRatioBox.tsx +25 -5
- package/src/components/Text/Text.tsx +1 -1
|
@@ -6,14 +6,14 @@ export declare const DEFAULT_PRODUCT_ASPECT_RATIO: number;
|
|
|
6
6
|
export type AspectRatioBoxProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
7
7
|
aspectWidth?: number;
|
|
8
8
|
aspectHeight?: number;
|
|
9
|
-
maxWidth
|
|
10
|
-
maxHeight
|
|
9
|
+
maxWidth?: number;
|
|
10
|
+
maxHeight?: number;
|
|
11
11
|
outlined?: boolean;
|
|
12
12
|
};
|
|
13
13
|
export declare const AspectRatioBox: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
14
14
|
aspectWidth?: number | undefined;
|
|
15
15
|
aspectHeight?: number | undefined;
|
|
16
|
-
maxWidth
|
|
17
|
-
maxHeight
|
|
16
|
+
maxWidth?: number | undefined;
|
|
17
|
+
maxHeight?: number | undefined;
|
|
18
18
|
outlined?: boolean | undefined;
|
|
19
19
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { ReactHTML } from 'react';
|
|
2
2
|
import { typography, colors } from '@moda/tokens';
|
|
3
3
|
import './Text.scss';
|
|
4
|
-
export type TextTreatment = keyof typeof typography['text-treatments'];
|
|
4
|
+
export type TextTreatment = keyof (typeof typography)['text-treatments'];
|
|
5
5
|
export type TextColor = keyof typeof colors.all;
|
|
6
6
|
export type TextFontFamily = keyof typeof typography.fonts;
|
|
7
7
|
export type TextProps = React.HTMLAttributes<HTMLSpanElement> & {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moda/om",
|
|
3
|
-
"version": "18.
|
|
3
|
+
"version": "18.3.0",
|
|
4
4
|
"description": "Moda Operandi design system",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -134,7 +134,7 @@
|
|
|
134
134
|
"rollup-plugin-scss": "^4.0.0",
|
|
135
135
|
"sass": "^1.57.1",
|
|
136
136
|
"sass-loader": "^13.0.0",
|
|
137
|
-
"semantic-release": "^
|
|
137
|
+
"semantic-release": "^20.0.2",
|
|
138
138
|
"storybook-states": "^1.2.0",
|
|
139
139
|
"style-loader": "^3.0.0",
|
|
140
140
|
"ts-jest": "^29.0.1",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
|
-
import { scale } from 'proportional-scale';
|
|
3
|
+
import { scale, paddingBottom } from 'proportional-scale';
|
|
4
4
|
import './AspectRatioBox.scss';
|
|
5
5
|
|
|
6
6
|
export const DEFAULT_PRODUCT_ASPECT_WIDTH = 128;
|
|
@@ -11,11 +11,31 @@ export const DEFAULT_PRODUCT_ASPECT_RATIO =
|
|
|
11
11
|
export type AspectRatioBoxProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
12
12
|
aspectWidth?: number;
|
|
13
13
|
aspectHeight?: number;
|
|
14
|
-
maxWidth
|
|
15
|
-
maxHeight
|
|
14
|
+
maxWidth?: number;
|
|
15
|
+
maxHeight?: number;
|
|
16
16
|
outlined?: boolean;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
+
const scaleDimensions = ({
|
|
20
|
+
width,
|
|
21
|
+
height,
|
|
22
|
+
maxWidth,
|
|
23
|
+
maxHeight
|
|
24
|
+
}: {
|
|
25
|
+
width: number;
|
|
26
|
+
height: number;
|
|
27
|
+
maxWidth?: number;
|
|
28
|
+
maxHeight?: number;
|
|
29
|
+
}) => {
|
|
30
|
+
if (maxWidth && maxHeight) return scale({ width, height, maxWidth, maxHeight });
|
|
31
|
+
|
|
32
|
+
if (maxWidth) return scale({ width, height, maxWidth });
|
|
33
|
+
|
|
34
|
+
if (maxHeight) return scale({ width, height, maxHeight });
|
|
35
|
+
|
|
36
|
+
return { width, height, paddingBottom: paddingBottom({ width, height }), scale: 1 };
|
|
37
|
+
};
|
|
38
|
+
|
|
19
39
|
export const AspectRatioBox = React.forwardRef(
|
|
20
40
|
(
|
|
21
41
|
{
|
|
@@ -30,7 +50,7 @@ export const AspectRatioBox = React.forwardRef(
|
|
|
30
50
|
}: AspectRatioBoxProps,
|
|
31
51
|
forwardedRef: React.Ref<HTMLDivElement>
|
|
32
52
|
) => {
|
|
33
|
-
const { width, paddingBottom } =
|
|
53
|
+
const { width, paddingBottom } = scaleDimensions({
|
|
34
54
|
width: aspectWidth,
|
|
35
55
|
height: aspectHeight,
|
|
36
56
|
maxWidth,
|
|
@@ -47,7 +67,7 @@ export const AspectRatioBox = React.forwardRef(
|
|
|
47
67
|
},
|
|
48
68
|
className
|
|
49
69
|
)}
|
|
50
|
-
style={{ maxWidth: `${width}px` }}
|
|
70
|
+
style={maxWidth || maxHeight ? { maxWidth: `${width}px` } : undefined}
|
|
51
71
|
{...rest}
|
|
52
72
|
>
|
|
53
73
|
<div className='AspectRatioBox__wrapper' style={{ paddingBottom }} />
|
|
@@ -3,7 +3,7 @@ import classNames from 'classnames';
|
|
|
3
3
|
import { typography, colors } from '@moda/tokens';
|
|
4
4
|
import './Text.scss';
|
|
5
5
|
|
|
6
|
-
export type TextTreatment = keyof typeof typography['text-treatments'];
|
|
6
|
+
export type TextTreatment = keyof (typeof typography)['text-treatments'];
|
|
7
7
|
export type TextColor = keyof typeof colors.all;
|
|
8
8
|
export type TextFontFamily = keyof typeof typography.fonts;
|
|
9
9
|
|