Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui: update @material-ui/lab and convert SpeedDial to hooks #204

Merged
merged 30 commits into from
Nov 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
dd4f2e0
upgrade @hot-loader/react-dom @material-ui/core @material-ui/icons @t…
dctalbot Nov 20, 2019
9a94f4b
Merge branch 'master' into upgrade-dependencies
dctalbot Nov 20, 2019
1c988bf
upgrade history luxon mdi-material-ui husky
dctalbot Nov 20, 2019
7bac5d4
upgrade react react-dom react-ga react-router-dom terser-webpack-plug…
dctalbot Nov 20, 2019
a91de3f
oops, forgot the lockfile
dctalbot Nov 20, 2019
ffeef30
Merge branch 'master' into upgrade-dependencies
dctalbot Nov 20, 2019
0a51b09
WIP: convert speed dial to hooks, upgrade pkg
dctalbot Nov 20, 2019
aa4506b
merge master
dctalbot Nov 21, 2019
4773e0b
Merge branch 'master' into speeddial
dctalbot Nov 21, 2019
f8c7e23
Merge branch 'master' into speeddial
dctalbot Nov 21, 2019
8f99a3f
style tooltip labels
dctalbot Nov 22, 2019
41cd2fe
stop reversing every actions array
dctalbot Nov 22, 2019
f9f5f09
Merge branch 'master' into speeddial
dctalbot Nov 22, 2019
42e6c58
update speed dial tests
dctalbot Nov 22, 2019
0e30e78
combine selectors
dctalbot Nov 25, 2019
a1d32ea
Merge branch 'master' into speeddial
dctalbot Nov 25, 2019
84bea8c
upgrade @material-ui/lab
dctalbot Nov 25, 2019
fe01de8
merge master
dctalbot Nov 25, 2019
2520fa6
bundle
dctalbot Nov 25, 2019
edfd2cc
Revert "stop reversing every actions array"
dctalbot Nov 26, 2019
cd7d5e8
Merge branch 'master' into speeddial
dctalbot Nov 26, 2019
099ecd1
remove comments of perplexion
dctalbot Nov 26, 2019
f94b72e
upgrade @material-ui/lab
dctalbot Nov 26, 2019
b8f5015
use the handle naming convention set by jsx-handler-names
dctalbot Nov 26, 2019
d8f3515
makeStyles with obj
dctalbot Nov 26, 2019
0762abb
Merge branch 'master' into speeddial
dctalbot Nov 26, 2019
e738048
inline w anonymous funs
dctalbot Nov 26, 2019
244b5da
Merge branch 'speeddial' of https://github.com/target/goalert into sp…
dctalbot Nov 26, 2019
81b7f77
Merge branch 'master' into speeddial
dctalbot Nov 26, 2019
940f51a
Merge branch 'master' into speeddial
dctalbot Nov 26, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 60 additions & 68 deletions web/src/app/util/SpeedDial.js
Original file line number Diff line number Diff line change
@@ -1,74 +1,66 @@
import React from 'react'
import React, { useState } from 'react'
import p from 'prop-types'
import SpeedDialAction from '@material-ui/lab/SpeedDialAction'
import SpeedDialIcon from '@material-ui/lab/SpeedDialIcon'
import SpeedDial from '@material-ui/lab/SpeedDial'
import { SpeedDial, SpeedDialIcon, SpeedDialAction } from '@material-ui/lab'
import { makeStyles } from '@material-ui/styles'

export default class ScheduleNewOverrideFAB extends React.PureComponent {
static propsTypes = {
label: p.string.isRequired,
actions: p.arrayOf(
p.shape({
icon: p.element.isRequired,
onClick: p.func.isRequired,
label: p.string.isRequired,
}),
).isRequired,
}
const useStyles = makeStyles({
speedDial: {
position: 'fixed',
bottom: '2em',
right: '2em',
zIndex: 9001,
},
staticTooltipLabel: {
whiteSpace: 'nowrap',
},
})

state = {
open: false,
}
export default function CustomSpeedDial(props) {
const [open, setOpen] = useState(false)
const classes = useStyles()

shownState = false
_shownTimeout = -1
return (
<SpeedDial
ariaLabel={props.label}
FabProps={{
'data-cy': 'page-fab',
}}
icon={<SpeedDialIcon />}
onClick={() => setOpen(!open)}
onClose={() => setOpen(false)}
onMouseEnter={() => setOpen(true)}
onMouseLeave={() => setOpen(false)}
open={open}
className={classes.speedDial}
>
{props.actions
.slice()
.reverse()
.map((action, idx) => (
<SpeedDialAction
key={idx}
icon={action.icon}
tooltipTitle={action.label}
tooltipOpen
classes={{ staticTooltipLabel: classes.staticTooltipLabel }}
aria-label={action.label}
onClick={() => {
setOpen(false)
action.onClick()
}}
/>
))}
</SpeedDial>
)
}

render() {
if (this.state.open !== this.shownState) {
clearTimeout(this._shownTimeout)
this._shownTimeout = setTimeout(() => {
this.shownState = this.state.open
}, 350)
}
const doToggle = () => this.setState({ open: !this.shownState })
const doOpen = () => this.setState({ open: true })
const doClose = () => this.setState({ open: false })
return (
<SpeedDial
ariaLabel={this.props.label}
ButtonProps={{
'data-cy': 'page-fab',
}}
icon={<SpeedDialIcon />}
onClick={doToggle}
onClose={doClose}
onMouseEnter={doOpen}
onMouseLeave={doClose}
open={this.state.open}
style={{
position: 'fixed',
bottom: '2em',
right: '2em',
zIndex: 9001,
}}
>
{this.props.actions
.slice()
.reverse()
.map((action, idx) => (
<SpeedDialAction
key={idx}
icon={action.icon}
tooltipOpen
tooltipTitle={action.label}
aria-label={action.label}
onClick={() => {
this.setState({ open: false })
action.onClick()
}}
/>
))}
</SpeedDial>
)
}
CustomSpeedDial.propsTypes = {
label: p.string.isRequired,
actions: p.arrayOf(
p.shape({
icon: p.element.isRequired,
onClick: p.func.isRequired,
label: p.string.isRequired,
}),
).isRequired,
}
4 changes: 3 additions & 1 deletion web/src/cypress/support/page-fab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ function pageFab(dialOption?: string): Cypress.Chainable {

return res
.parent()
.find(`button[role=menuitem][aria-label*=${JSON.stringify(dialOption)}]`)
.find(
`span[aria-label*=${JSON.stringify(dialOption)}] button[role=menuitem]`,
)
.click()
}

Expand Down
2 changes: 1 addition & 1 deletion web/src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"@date-io/luxon": "1.3.11",
"@material-ui/core": "4.7.0",
"@material-ui/icons": "4.5.1",
"@material-ui/lab": "4.0.0-alpha.26",
"@material-ui/lab": "4.0.0-alpha.33",
"apollo-cache-inmemory": "1.6.3",
"apollo-client": "2.6.4",
"apollo-link": "1.2.13",
Expand Down
26 changes: 16 additions & 10 deletions web/src/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1219,13 +1219,20 @@
core-js "^2.6.5"
regenerator-runtime "^0.13.2"

"@babel/runtime@^7.1.2", "@babel/runtime@^7.1.5", "@babel/runtime@^7.3.1", "@babel/runtime@^7.4.0", "@babel/runtime@^7.4.2", "@babel/runtime@^7.4.4", "@babel/runtime@^7.4.5", "@babel/runtime@^7.5.5", "@babel/runtime@^7.6.0", "@babel/runtime@^7.6.2", "@babel/runtime@^7.6.3":
"@babel/runtime@^7.1.2", "@babel/runtime@^7.1.5", "@babel/runtime@^7.3.1", "@babel/runtime@^7.4.0", "@babel/runtime@^7.4.2", "@babel/runtime@^7.4.5", "@babel/runtime@^7.5.5", "@babel/runtime@^7.6.0", "@babel/runtime@^7.6.2", "@babel/runtime@^7.6.3":
version "7.7.2"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.7.2.tgz#111a78002a5c25fc8e3361bedc9529c696b85a6a"
integrity sha512-JONRbXbTXc9WQE2mAZd1p0Z3DZ/6vaQIkgYMSTP3KjRCyd7rCZCcfhCyX+YjwcKxcZ82UrxbRD358bpExNgrjw==
dependencies:
regenerator-runtime "^0.13.2"

"@babel/runtime@^7.4.4":
version "7.7.4"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.7.4.tgz#b23a856751e4bf099262f867767889c0e3fe175b"
integrity sha512-r24eVUUr0QqNZa+qrImUk8fn5SPhHq+IfYvIoIMg0do3GdK9sMdiLKP3GYVVaxpPKORgm8KRKaNTEhAjgIpLMw==
dependencies:
regenerator-runtime "^0.13.2"

"@babel/template@^7.1.0", "@babel/template@^7.4.0", "@babel/template@^7.4.4", "@babel/template@^7.6.0":
version "7.6.0"
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.6.0.tgz#7f0159c7f5012230dad64cca42ec9bdb5c9536e6"
Expand Down Expand Up @@ -1636,16 +1643,15 @@
dependencies:
"@babel/runtime" "^7.4.4"

"@material-ui/[email protected].26":
version "4.0.0-alpha.26"
resolved "https://registry.yarnpkg.com/@material-ui/lab/-/lab-4.0.0-alpha.26.tgz#8db16de1ab46cda5d06afdd97578536989ed3c4e"
integrity sha512-23N43d2/DJkQKbJjg3J9DqORgmvxA9ebqpnqrA6JB8zIiDSoSuZmJu1hHUtINgMechxwWGTf73PMy9ihm0AAQA==
"@material-ui/[email protected].33":
version "4.0.0-alpha.33"
resolved "https://registry.yarnpkg.com/@material-ui/lab/-/lab-4.0.0-alpha.33.tgz#3de96da1e813afcea5a07d56e54ec41cfa636e2c"
integrity sha512-+xttHUZLwH4+yfkB7B5A3pNDtQO27tGftuUxMRDMevNXwQtAB7mgYco34JwMr9kmvESYmacoZReOacJ6rxym/Q==
dependencies:
"@babel/runtime" "^7.4.4"
"@material-ui/utils" "^4.4.0"
"@material-ui/utils" "^4.5.2"
clsx "^1.0.4"
prop-types "^15.7.2"
warning "^4.0.3"

"@material-ui/[email protected]":
version "3.2.8"
Expand Down Expand Up @@ -1696,7 +1702,7 @@
dependencies:
"@types/react" "*"

"@material-ui/utils@^4.4.0", "@material-ui/utils@^4.5.2":
"@material-ui/utils@^4.5.2":
version "4.5.2"
resolved "https://registry.yarnpkg.com/@material-ui/utils/-/utils-4.5.2.tgz#4c2fb531d357cf0da8cece53b588dff9b0bde934"
integrity sha512-zhbNfHd1gLa8At6RPDG7uMZubHxbY+LtM6IkSfeWi6Lo4Ax80l62YaN1QmUpO1IvGCkn/j62tQX3yObiQZrJsQ==
Expand Down Expand Up @@ -9767,12 +9773,12 @@ react-input-autosize@^2.2.2:
dependencies:
prop-types "^15.5.8"

react-is@^16.6.0, react-is@^16.8.4, react-is@^16.8.6:
react-is@^16.6.0, react-is@^16.8.4:
version "16.9.0"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.9.0.tgz#21ca9561399aad0ff1a7701c01683e8ca981edcb"
integrity sha512-tJBzzzIgnnRfEm046qRcURvwQnZVXmuCbscxUO5RWrGTXpon2d4c8mI0D8WE6ydVIm29JiLB6+RslkIvym9Rjw==

react-is@^16.7.0, react-is@^16.8.1, react-is@^16.9.0:
react-is@^16.7.0, react-is@^16.8.1, react-is@^16.8.6, react-is@^16.9.0:
version "16.12.0"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.12.0.tgz#2cc0fe0fba742d97fd527c42a13bec4eeb06241c"
integrity sha512-rPCkf/mWBtKc97aLL9/txD8DZdemK0vkA3JMLShjlJB3Pj3s+lpf1KaBzMfQrAmhMQB0n1cU/SUGgKKBCe837Q==
Expand Down