Skip to content

Commit 87d5344

Browse files
committed
fix(image): the mode property behaves incorrectly
1 parent b1c38b0 commit 87d5344

File tree

2 files changed

+66
-65
lines changed

2 files changed

+66
-65
lines changed

packages/nextjs/components/src/image/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ const Image: React.ForwardRefRenderFunction<HTMLDivElement, ImageProps> = ({
117117
div.current = el
118118
setRef(el)
119119
}}
120-
className={classNames({
120+
className={classNames('taro-img__content', {
121121
'taro-img__scale-to-fill': mode === 'scaleToFill',
122122
'taro-img__aspect-fit': mode === 'aspectFit',
123123
'taro-img__aspect-fill': mode === 'aspectFill',

packages/nextjs/components/src/image/style/index.scss

Lines changed: 65 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -3,71 +3,72 @@
33
display: inline-block;
44
width: 300px;
55
height: 225px;
6-
}
7-
8-
.taro-img > div {
9-
height: 100%;
10-
width: 100%;
11-
background-repeat: no-repeat;
12-
background-size: contain;
13-
}
14-
15-
.taro-img__scale-to-fill {
16-
background-size: 100% 100%;
17-
background-position: 0% 0%;
18-
}
19-
20-
.taro-img__aspect-fit {
21-
background-size: contain;
22-
background-position: center center;
23-
}
24-
25-
.taro-img__aspect-fill {
26-
background-size: cover;
27-
background-position: center center;
28-
}
29-
30-
.taro-img__width-fix {
31-
background-size: 100% 100%;
32-
background-position: 0% 0%;
33-
}
34-
35-
.taro-img__height-fix {
36-
background-size: 100% 100%;
37-
background-position: 0% 0%;
38-
}
396

40-
.taro-img__top {
41-
background-position: top center;
42-
}
43-
44-
.taro-img__bottom {
45-
background-position: bottom center;
46-
}
7+
&__content {
8+
height: 100%;
9+
width: 100%;
10+
background-repeat: no-repeat;
11+
background-size: contain;
12+
}
4713

48-
.taro-img__center {
49-
background-position: center center;
50-
}
51-
.taro-img__left {
52-
background-position: center left;
53-
}
54-
55-
.taro-img__right {
56-
background-position: center right;
57-
}
58-
59-
.taro-img__top-left {
60-
background-position: top left;
61-
}
62-
63-
.taro-img__top-right {
64-
background-position: top right;
65-
}
66-
67-
.taro-img__bottom-left {
68-
background-position: bottom left;
69-
}
14+
&__scale-to-fill {
15+
background-size: 100% 100%;
16+
background-position: 0% 0%;
17+
}
18+
19+
&__aspect-fit {
20+
background-size: contain;
21+
background-position: center center;
22+
}
23+
24+
&__aspect-fill {
25+
background-size: cover;
26+
background-position: center center;
27+
}
28+
29+
&__width-fix {
30+
background-size: 100% 100%;
31+
background-position: 0% 0%;
32+
}
33+
34+
&__height-fix {
35+
background-size: 100% 100%;
36+
background-position: 0% 0%;
37+
}
38+
39+
&__top {
40+
background-position: top center;
41+
}
42+
43+
&__bottom {
44+
background-position: bottom center;
45+
}
46+
47+
&__center {
48+
background-position: center center;
49+
}
7050

71-
.taro-img__bottom-right {
72-
background-position: bottom right;
51+
&__left {
52+
background-position: center left;
53+
}
54+
55+
&__right {
56+
background-position: center right;
57+
}
58+
59+
&__top-left {
60+
background-position: top left;
61+
}
62+
63+
&__top-right {
64+
background-position: top right;
65+
}
66+
67+
&__bottom-left {
68+
background-position: bottom left;
69+
}
70+
71+
&__bottom-right {
72+
background-position: bottom right;
73+
}
7374
}

0 commit comments

Comments
 (0)