From 2124cc5261be4a7d666cf6f70d4295309f3705d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=98=89=E6=B6=B5?= Date: Thu, 6 Feb 2020 11:52:17 +0800 Subject: [PATCH] feat(Calendar): improve accessibility --- src/calendar/components/Month.js | 15 +- src/calendar/index.less | 2 +- .../test/__snapshots__/demo.spec.js.snap | 188 ++++----- .../test/__snapshots__/index.spec.js.snap | 384 +++++++++--------- 4 files changed, 299 insertions(+), 290 deletions(-) diff --git a/src/calendar/components/Month.js b/src/calendar/components/Month.js index f5252a6c7..2ecf43d3f 100644 --- a/src/calendar/components/Month.js +++ b/src/calendar/components/Month.js @@ -170,7 +170,7 @@ export default createComponent({ genDays() { if (this.visible) { return ( -
+
{this.genMark()} {this.days.map(this.genDay)}
@@ -183,9 +183,10 @@ export default createComponent({ genDay(item, index) { const { type, topInfo, bottomInfo } = item; const style = this.getDayStyle(type, index); + const disabled = type === 'disabled'; const onClick = () => { - if (type !== 'disabled') { + if (!disabled) { this.$emit('click', item); } }; @@ -198,7 +199,13 @@ export default createComponent({ if (type === 'selected') { return ( -
+
{TopInfo} {item.text} @@ -210,8 +217,10 @@ export default createComponent({ return (
{TopInfo} diff --git a/src/calendar/index.less b/src/calendar/index.less index 5641d5a06..6b75c348e 100644 --- a/src/calendar/index.less +++ b/src/calendar/index.less @@ -18,7 +18,7 @@ } .van-popup__close-icon { - top: 13px; + top: 11px; } } diff --git a/src/calendar/test/__snapshots__/demo.spec.js.snap b/src/calendar/test/__snapshots__/demo.spec.js.snap index a8e4c121e..f73371de5 100644 --- a/src/calendar/test/__snapshots__/demo.spec.js.snap +++ b/src/calendar/test/__snapshots__/demo.spec.js.snap @@ -57,113 +57,113 @@ exports[`renders demo correctly 1`] = `
-
+
1
-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
+
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
2012年2月
-
+
2
-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
+
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
2012年3月
-
+
3
-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
+
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
diff --git a/src/calendar/test/__snapshots__/index.spec.js.snap b/src/calendar/test/__snapshots__/index.spec.js.snap index 763f5a7e1..d053737c1 100644 --- a/src/calendar/test/__snapshots__/index.spec.js.snap +++ b/src/calendar/test/__snapshots__/index.spec.js.snap @@ -9,41 +9,41 @@ exports[`color prop when type is range 1`] = `
-
+
1
-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
开始
+
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
开始
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
结束
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
结束
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
@@ -60,41 +60,41 @@ exports[`color prop when type is single 1`] = `
-
+
1
-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
+
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
@@ -111,44 +111,44 @@ exports[`formatter prop 1`] = `
-
+
1
-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
+
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
-
+
Top Info
11
-
12
Bottom Info
+
12
Bottom Info
-
Text
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
+
Text
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
@@ -168,41 +168,41 @@ exports[`popup wrapper 2`] = `
-
+
1
-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
+
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
@@ -221,41 +221,41 @@ exports[`row-height prop 1`] = `
-
+
1
-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
+
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
@@ -272,41 +272,41 @@ exports[`title & footer slot 1`] = `
-
+
1
-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
+
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31