Skip to content

Commit 7c6dc0b

Browse files
authored
feat: add img alt (#9)
* feat: add img alt * docs
1 parent 5abd5a8 commit 7c6dc0b

File tree

5 files changed

+30
-11
lines changed

5 files changed

+30
-11
lines changed

.github/PULL_REQUEST_TEMPLATE.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ Describe changes from the user side, and list all potential break changes or oth
4444

4545
### ☑️ 请求合并前的自查清单 / Self Check before Merge
4646

47-
⚠️ 请自检并全部**勾选全部选项**。⚠️
48-
⚠️ Please check all items below before review. ⚠️
47+
⚠️ 请自检并全部**勾选全部选项**。/ Please check all items below before review. ⚠️
4948

5049
- [ ] 文档已补充或无须补充 / Doc is updated/provided or not needed
5150
- [ ] 代码演示已提供或无须提供 / Demo is updated/provided or not needed

README.md

+14-9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ A React image component. Simple realization of image shadow.
88

99
Online: https://image-component.github.io/react-image-shadow/
1010

11+
## 🌀 Template
12+
13+
https://github.com/one-template/react-component-template
14+
1115
## 📦 Install
1216

1317
```bash
@@ -31,15 +35,16 @@ export default () => (
3135

3236
## 📔 API
3337

34-
| Property | Description | Type | Required | Default |
35-
| ------------ | ----------------------------------- | ------------- | -------- | ------- |
36-
| className | Component extra class. | string || - |
37-
| shadowBlur | The shadow blur of the image. | number || 20 |
38-
| shadowHover | Whether to support the mouse hover. | boolean || false |
39-
| shadowRadius | The border radius of the image. | number || 8 |
40-
| src | The src of the image. | string || - |
41-
| style | Component extra style. | CSSProperties || - |
42-
| width | The width of the image. | number || 300 |
38+
| Property | Description | Type | Required | Default | Version |
39+
| ------------ | ----------------------------------- | ------------- | -------- | ------- | ------- |
40+
| alt | The alt of the image. | string || - | 1.1.0 |
41+
| className | Component extra class. | string || - | 1.0.0 |
42+
| shadowBlur | The shadow blur of the image. | number || 20 | 1.0.0 |
43+
| shadowHover | Whether to support the mouse hover. | boolean || false | 1.0.0 |
44+
| shadowRadius | The border radius of the image. | number || 8 | 1.0.0 |
45+
| src | The src of the image. | string || - | 1.0.0 |
46+
| style | Component extra style. | CSSProperties || - | 1.0.0 |
47+
| width | The width of the image. | number || 300 | 1.0.0 |
4348

4449
## 🔨 Development
4550

docs/changelog.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# 🗓 Changelog
22

3+
## 1.1.0
4+
5+
`2020-12-15`
6+
7+
- feat: add img `alt`. [#9](https://github.com/image-component/react-image-shadow/pull/9)
8+
39
## 1.0.3
410

511
`2020-12-10`

src/image-shadow.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as React from 'react';
22
import classNames from 'classnames';
33

44
interface ImageShadowProps {
5+
alt?: string;
56
className?: string;
67
shadowBlur?: number;
78
shadowHover?: boolean;
@@ -15,6 +16,7 @@ export { ImageShadowProps };
1516

1617
const ImageShadow = (props: ImageShadowProps) => {
1718
const {
19+
alt,
1820
className,
1921
shadowBlur = 20,
2022
shadowHover = false,
@@ -39,6 +41,7 @@ const ImageShadow = (props: ImageShadowProps) => {
3941
<img
4042
className="react-image-shadow-img"
4143
src={src}
44+
alt={alt}
4245
width={width}
4346
style={{
4447
borderRadius: `${shadowRadius}px`,

tests/index.spec.tsx

+6
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,10 @@ describe('imageShadow', () => {
5858
const node = wrapper.find('.react-image-shadow-img');
5959
expect(node.prop('width')).toEqual(100);
6060
});
61+
62+
it('alt', () => {
63+
const wrapper = mount(<ImageShadow alt="alt" src={testSrc} />);
64+
const node = wrapper.find('.react-image-shadow-img');
65+
expect(node.prop('alt')).toEqual('alt');
66+
});
6167
});

0 commit comments

Comments
 (0)