WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
This repository was archived by the owner on Jul 19, 2025. It is now read-only.

Commit 3048401

Browse files
[TimePicker] Fix time position in landscape orientation (#1224)
* [TimePicker] Fix incorrect toolbar margin for landscape 24h * Add 1sec delay to wait client app before visual regression * Mock js date object on server side for percy
1 parent 6cd75e9 commit 3048401

File tree

8 files changed

+120
-3
lines changed

8 files changed

+120
-3
lines changed

.circleci/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ jobs:
9999
background: true
100100
name: Run docs in background
101101
command: yarn workspace docs start
102+
environment:
103+
VISUAL_TESTING: true
102104
- run: npx wait-on http://localhost:3000
103105
- run: yarn percy exec -- cypress run --record
104106

.vscode/launch.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "chrome",
9+
"request": "launch",
10+
"name": "Launch Chrome against localhost",
11+
"url": "http://localhost:3000",
12+
"webRoot": "${workspaceFoler}"
13+
}
14+
]
15+
}

docs/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"@types/react": "^16.8.13",
3333
"@types/react-jss": "^8.6.2",
3434
"@types/react-kawaii": "^0.11.0",
35+
"@types/sinon": "^7.0.13",
3536
"@types/styled-jsx": "^2.2.8",
3637
"@types/w3c-permissions": "^1.0.1",
3738
"@zeit/next-bundle-analyzer": "^0.1.2",
@@ -69,6 +70,7 @@
6970
"redux-form": "^8.2.4",
7071
"remark-slug": "^5.1.1",
7172
"safe-json-stringify": "^1.2.0",
73+
"sinon": "^7.3.2",
7274
"typescript": "^3.4.4",
7375
"unist-util-visit": "^1.4.0"
7476
},

docs/pages/_app.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1+
import sinon from 'sinon';
12
import React from 'react';
23
import App from 'next/app';
34
import cookies from 'next-cookies';
45
import getPageContext from '../utils/getPageContext';
56
import { PageWithContexts, ThemeType } from '../layout/PageWithContext';
67

8+
if (process.env.VISUAL_TESTING) {
9+
const now = new Date('2019-01-01T09:41:00.000Z');
10+
sinon.useFakeTimers(now.getTime());
11+
}
12+
713
class MyApp extends App<{ theme: ThemeType }> {
814
pageContext = getPageContext();
915

docs/pages/demo/timepicker/StaticTimePicker.example.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const StaticTimePicker = () => {
1717

1818
<TimePicker
1919
autoOk
20+
ampm={false}
2021
variant="static"
2122
orientation="landscape"
2223
openTo="minutes"

e2e/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"esModuleInterop": true,
88
"allowSyntheticDefaultImports": true,
99
"resolveJsonModule": true,
10+
"jsx": "react",
1011
"lib": ["es5", "dom"],
1112
"types": ["cypress", "@percy/cypress"]
1213
},

lib/src/TimePicker/TimePickerToolbar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const useStyles = makeStyles(
2828
justifyContent: 'flex-end',
2929
alignItems: 'flex-end',
3030
},
31-
hourMinuteLabelLandscape: {
31+
hourMinuteLabelAmpmLandscape: {
3232
marginTop: 'auto',
3333
},
3434
hourMinuteLabelReverse: {
@@ -102,7 +102,7 @@ const TimePickerToolbar: React.FC<ToolbarComponentProps> = ({
102102
>
103103
<div
104104
className={clsx(classes.hourMinuteLabel, {
105-
[classes.hourMinuteLabelLandscape]: isLandscape,
105+
[classes.hourMinuteLabelAmpmLandscape]: ampm && isLandscape,
106106
[classes.hourMinuteLabelReverse]: theme.direction === 'rtl',
107107
})}
108108
>

yarn.lock

Lines changed: 91 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1950,6 +1950,35 @@
19501950
dependencies:
19511951
any-observable "^0.3.0"
19521952

1953+
"@sinonjs/commons@^1", "@sinonjs/commons@^1.0.2", "@sinonjs/commons@^1.4.0":
1954+
version "1.4.0"
1955+
resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.4.0.tgz#7b3ec2d96af481d7a0321252e7b1c94724ec5a78"
1956+
integrity sha512-9jHK3YF/8HtJ9wCAbG+j8cD0i0+ATS9A7gXFqS36TblLPNy6rEEc+SB0imo91eCboGaBYGV/MT1/br/J+EE7Tw==
1957+
dependencies:
1958+
type-detect "4.0.8"
1959+
1960+
"@sinonjs/formatio@^3.1.0", "@sinonjs/formatio@^3.2.1":
1961+
version "3.2.1"
1962+
resolved "https://registry.yarnpkg.com/@sinonjs/formatio/-/formatio-3.2.1.tgz#52310f2f9bcbc67bdac18c94ad4901b95fde267e"
1963+
integrity sha512-tsHvOB24rvyvV2+zKMmPkZ7dXX6LSLKZ7aOtXY6Edklp0uRcgGpOsQTTGTcWViFyx4uhWc6GV8QdnALbIbIdeQ==
1964+
dependencies:
1965+
"@sinonjs/commons" "^1"
1966+
"@sinonjs/samsam" "^3.1.0"
1967+
1968+
"@sinonjs/samsam@^3.1.0", "@sinonjs/samsam@^3.3.1":
1969+
version "3.3.2"
1970+
resolved "https://registry.yarnpkg.com/@sinonjs/samsam/-/samsam-3.3.2.tgz#63942e3d5eb0b79f6de3bef9abfad15fb4b6401b"
1971+
integrity sha512-ILO/rR8LfAb60Y1Yfp9vxfYAASK43NFC2mLzpvLUbCQY/Qu8YwReboseu8aheCEkyElZF2L2T9mHcR2bgdvZyA==
1972+
dependencies:
1973+
"@sinonjs/commons" "^1.0.2"
1974+
array-from "^2.1.1"
1975+
lodash "^4.17.11"
1976+
1977+
"@sinonjs/text-encoding@^0.7.1":
1978+
version "0.7.1"
1979+
resolved "https://registry.yarnpkg.com/@sinonjs/text-encoding/-/text-encoding-0.7.1.tgz#8da5c6530915653f3a1f38fd5f101d8c3f8079c5"
1980+
integrity sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ==
1981+
19531982
"@types/anymatch@*":
19541983
version "1.3.1"
19551984
resolved "https://registry.yarnpkg.com/@types/anymatch/-/anymatch-1.3.1.tgz#336badc1beecb9dacc38bea2cf32adf627a8421a"
@@ -2306,6 +2335,11 @@
23062335
"@types/express-serve-static-core" "*"
23072336
"@types/mime" "*"
23082337

2338+
"@types/sinon@^7.0.13":
2339+
version "7.0.13"
2340+
resolved "https://registry.yarnpkg.com/@types/sinon/-/sinon-7.0.13.tgz#ca039c23a9e27ebea53e0901ef928ea2a1a6d313"
2341+
integrity sha512-d7c/C/+H/knZ3L8/cxhicHUiTDxdgap0b/aNJfsmLwFu/iOP17mdgbQsbHA3SJmrzsjD0l3UEE5SN4xxuz5ung==
2342+
23092343
"@types/stack-utils@^1.0.1":
23102344
version "1.0.1"
23112345
resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-1.0.1.tgz#0a851d3bd96498fa25c33ab7278ed3bd65f06c3e"
@@ -2986,6 +3020,11 @@ [email protected]:
29863020
resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2"
29873021
integrity sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=
29883022

3023+
array-from@^2.1.1:
3024+
version "2.1.1"
3025+
resolved "https://registry.yarnpkg.com/array-from/-/array-from-2.1.1.tgz#cfe9d8c26628b9dc5aecc62a9f5d8f1f352c1195"
3026+
integrity sha1-z+nYwmYoudxa7MYqn12PHzUsEZU=
3027+
29893028
array-includes@^3.0.3:
29903029
version "3.0.3"
29913030
resolved "https://registry.yarnpkg.com/array-includes/-/array-includes-3.0.3.tgz#184b48f62d92d7452bb31b323165c7f8bd02266d"
@@ -4929,7 +4968,7 @@ diff-sequences@^24.3.0:
49294968
resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-24.3.0.tgz#0f20e8a1df1abddaf4d9c226680952e64118b975"
49304969
integrity sha512-xLqpez+Zj9GKSnPWS0WZw1igGocZ+uua8+y+5dDNTT934N3QuY1sp2LkHzwiaYQGz60hMq0pjAshdeXm5VUOEw==
49314970

4932-
diff@^3.2.0:
4971+
diff@^3.2.0, diff@^3.5.0:
49334972
version "3.5.0"
49344973
resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12"
49354974
integrity sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==
@@ -7141,6 +7180,11 @@ is-wsl@^1.1.0:
71417180
resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-1.1.0.tgz#1f16e4aa22b04d1336b66188a66af3c600c3a66d"
71427181
integrity sha1-HxbkqiKwTRM2tmGIpmrzxgDDpm0=
71437182

7183+
7184+
version "0.0.1"
7185+
resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf"
7186+
integrity sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=
7187+
71447188
[email protected], isarray@^1.0.0, isarray@~1.0.0:
71457189
version "1.0.0"
71467190
resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"
@@ -7953,6 +7997,11 @@ junk@^1.0.1:
79537997
resolved "https://registry.yarnpkg.com/junk/-/junk-1.0.3.tgz#87be63488649cbdca6f53ab39bec9ccd2347f592"
79547998
integrity sha1-h75jSIZJy9ym9Tqzm+yczSNH9ZI=
79557999

8000+
just-extend@^4.0.2:
8001+
version "4.0.2"
8002+
resolved "https://registry.yarnpkg.com/just-extend/-/just-extend-4.0.2.tgz#f3f47f7dfca0f989c55410a7ebc8854b07108afc"
8003+
integrity sha512-FrLwOgm+iXrPV+5zDU6Jqu4gCRXbWEQg2O3SKONsWE4w7AXFRkryS53bpWdaL9cNol+AmR3AEYz6kn+o0fCPnw==
8004+
79568005
kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.2.0:
79578006
version "3.2.2"
79588007
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64"
@@ -8321,6 +8370,11 @@ log-update@^2.3.0:
83218370
cli-cursor "^2.0.0"
83228371
wrap-ansi "^3.0.1"
83238372

8373+
lolex@^4.0.1, lolex@^4.1.0:
8374+
version "4.1.0"
8375+
resolved "https://registry.yarnpkg.com/lolex/-/lolex-4.1.0.tgz#ecdd7b86539391d8237947a3419aa8ac975f0fe1"
8376+
integrity sha512-BYxIEXiVq5lGIXeVHnsFzqa1TxN5acnKnPCdlZSpzm8viNEOhiigupA4vTQ9HEFQ6nLTQ9wQOgBknJgzUYQ9Aw==
8377+
83248378
loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.3.1, loose-envify@^1.4.0:
83258379
version "1.4.0"
83268380
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf"
@@ -8924,6 +8978,17 @@ nice-try@^1.0.4:
89248978
resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366"
89258979
integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==
89268980

8981+
nise@^1.4.10:
8982+
version "1.5.0"
8983+
resolved "https://registry.yarnpkg.com/nise/-/nise-1.5.0.tgz#d03ea0e6c1b75c638015aa3585eddc132949a50d"
8984+
integrity sha512-Z3sfYEkLFzFmL8KY6xnSJLRxwQwYBjOXi/24lb62ZnZiGA0JUzGGTI6TBIgfCSMIDl9Jlu8SRmHNACLTemDHww==
8985+
dependencies:
8986+
"@sinonjs/formatio" "^3.1.0"
8987+
"@sinonjs/text-encoding" "^0.7.1"
8988+
just-extend "^4.0.2"
8989+
lolex "^4.1.0"
8990+
path-to-regexp "^1.7.0"
8991+
89278992
no-case@^2.2.0, no-case@^2.3.2:
89288993
version "2.3.2"
89298994
resolved "https://registry.yarnpkg.com/no-case/-/no-case-2.3.2.tgz#60b813396be39b3f1288a4c1ed5d1e7d28b464ac"
@@ -9598,6 +9663,13 @@ [email protected]:
95989663
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-2.1.0.tgz#7e30f9f5b134bd6a28ffc2e3ef1e47075ac5259b"
95999664
integrity sha512-dZY7QPCPp5r9cnNuQ955mOv4ZFVDXY/yvqeV7Y1W2PJA3PEFcuow9xKFfJxbBj1pIjOAP+M2B4/7xubmykLrXw==
96009665

9666+
path-to-regexp@^1.7.0:
9667+
version "1.7.0"
9668+
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-1.7.0.tgz#59fde0f435badacba103a84e9d3bc64e96b9937d"
9669+
integrity sha1-Wf3g9DW62suhA6hOnTvGTpa5k30=
9670+
dependencies:
9671+
isarray "0.0.1"
9672+
96019673
path-type@^2.0.0:
96029674
version "2.0.0"
96039675
resolved "https://registry.yarnpkg.com/path-type/-/path-type-2.0.0.tgz#f012ccb8415b7096fc2daa1054c3d72389594c73"
@@ -11470,6 +11542,19 @@ simple-swizzle@^0.2.2:
1147011542
dependencies:
1147111543
is-arrayish "^0.3.1"
1147211544

11545+
sinon@^7.3.2:
11546+
version "7.3.2"
11547+
resolved "https://registry.yarnpkg.com/sinon/-/sinon-7.3.2.tgz#82dba3a6d85f6d2181e1eca2c10d8657c2161f28"
11548+
integrity sha512-thErC1z64BeyGiPvF8aoSg0LEnptSaWE7YhdWWbWXgelOyThent7uKOnnEh9zBxDbKixtr5dEko+ws1sZMuFMA==
11549+
dependencies:
11550+
"@sinonjs/commons" "^1.4.0"
11551+
"@sinonjs/formatio" "^3.2.1"
11552+
"@sinonjs/samsam" "^3.3.1"
11553+
diff "^3.5.0"
11554+
lolex "^4.0.1"
11555+
nise "^1.4.10"
11556+
supports-color "^5.5.0"
11557+
1147311558
sisteransi@^1.0.0:
1147411559
version "1.0.0"
1147511560
resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.0.tgz#77d9622ff909080f1c19e5f4a1df0c1b0a27b88c"
@@ -12360,6 +12445,11 @@ type-check@~0.3.2:
1236012445
dependencies:
1236112446
prelude-ls "~1.1.2"
1236212447

12448+
12449+
version "4.0.8"
12450+
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c"
12451+
integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==
12452+
1236312453
type-is@~1.6.16:
1236412454
version "1.6.16"
1236512455
resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.16.tgz#f89ce341541c672b25ee7ae3c73dee3b2be50194"

0 commit comments

Comments
 (0)