Widgets: add TimezonePicker widget.

master
Tom Hacohen 5 years ago
parent 6a0fc11ab3
commit bfc54018ce

@ -3,8 +3,9 @@
"version": "0.4.0",
"private": true,
"dependencies": {
"@material-ui/core": "^4.6.1",
"@material-ui/core": "^4.7.0",
"@material-ui/icons": "^3.0.2",
"@material-ui/lab": "^4.0.0-alpha.33",
"@material-ui/styles": "^4.6.0",
"etesync": "^0.1.2",
"ical.js": "^1.2.2",

@ -100,3 +100,7 @@ export function formatOurTimezoneOffset() {
return `GMT${prefix}${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`;
}
export function getCurrentTimezone() {
return Intl.DateTimeFormat().resolvedOptions().timeZone;
}

@ -0,0 +1,28 @@
import * as React from 'react';
import Autocomplete from '@material-ui/lab/Autocomplete';
import TextField from '@material-ui/core/TextField';
import * as zones from '../data/zones.json';
const zonelist = Object.keys(zones.zones).sort();
interface PropsType {
value: string | null;
onChange: (value: string) => void;
style?: React.CSSProperties;
}
export default React.memo(function TimezonePicker(props: PropsType) {
return (
<Autocomplete
options={zonelist}
value={props.value}
onChange={(_e, value) => props.onChange(value)}
getOptionLabel={(option) => option.replace('_', ' ')}
style={props.style}
renderInput={(params) => (
<TextField {...params} label="Timezone" fullWidth />
)}
/>
);
});

@ -1486,10 +1486,10 @@
"@types/istanbul-reports" "^1.1.1"
"@types/yargs" "^13.0.0"
"@material-ui/core@^4.6.1":
version "4.6.1"
resolved "https://registry.yarnpkg.com/@material-ui/core/-/core-4.6.1.tgz#039f97443547a88c41d290deabfb4a044c6031ec"
integrity sha512-TljDMCJmi1zh7JhAFTp8qjIlbkVACiNftrcitzJJ+hAqpuP9PTO4euEkkAuYjISfUFZl3Z4kaOrBwN1HDrhIOQ==
"@material-ui/core@^4.7.0":
version "4.7.0"
resolved "https://registry.yarnpkg.com/@material-ui/core/-/core-4.7.0.tgz#84c02a6d1c99c7900e184538c5f9d87e30cf4c23"
integrity sha512-mwLehUo0Q9ZxjuWo7J1uy1/Grh3nRxlOAaWJ3EtKeJP2HwqlSy8bWrcvRQYlapaYIPXa5jN8zWbTwi8Pk30VQg==
dependencies:
"@babel/runtime" "^7.4.4"
"@material-ui/styles" "^4.6.0"
@ -1513,6 +1513,16 @@
"@babel/runtime" "^7.2.0"
recompose "0.28.0 - 0.30.0"
"@material-ui/lab@^4.0.0-alpha.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.5.2"
clsx "^1.0.4"
prop-types "^15.7.2"
"@material-ui/styles@^4.6.0":
version "4.6.0"
resolved "https://registry.yarnpkg.com/@material-ui/styles/-/styles-4.6.0.tgz#15679fab6dcbe0cc2416f01a22966f3ea26607c5"

Loading…
Cancel
Save