From f9d4a9a3a04ffdb833ba70987922dd85eb2f6e1c Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Sat, 13 Feb 2021 19:46:15 +0100 Subject: [PATCH] connection modal style --- packages/web/src/modals/ConnectionModal.js | 89 +++++++++++++++++++--- packages/web/src/utility/flexGrid.js | 73 ++++++++++++++++++ packages/web/src/utility/formStyle.js | 27 +++++-- packages/web/src/utility/forms.js | 25 +++--- 4 files changed, 187 insertions(+), 27 deletions(-) create mode 100644 packages/web/src/utility/flexGrid.js diff --git a/packages/web/src/modals/ConnectionModal.js b/packages/web/src/modals/ConnectionModal.js index 76e7bae5d..1f9e9fbfe 100644 --- a/packages/web/src/modals/ConnectionModal.js +++ b/packages/web/src/modals/ConnectionModal.js @@ -20,8 +20,9 @@ import { FormProvider, useForm } from '../utility/FormProvider'; import { TabControl, TabPage } from '../widgets/TabControl'; import { usePlatformInfo } from '../utility/metadataLoaders'; import getElectron from '../utility/getElectron'; -import { FormFieldTemplateLarge } from '../utility/formStyle'; +import { FormFieldTemplateLarge, FormRowLarge } from '../utility/formStyle'; import styled from 'styled-components'; +import { FlexCol3, FlexCol6, FlexCol9 } from '../utility/flexGrid'; // import FormikForm from '../utility/FormikForm'; const FlexContainer = styled.div` @@ -79,10 +80,49 @@ function DriverFields({ extensions }) { ))} )} - - - - + + + + + + + + + + + + + + + + + {!disabledFields.includes('password') && ( @@ -111,8 +151,17 @@ function SshTunnelFields() { return ( <> - - + + + + + + + + @@ -126,11 +175,27 @@ function SshTunnelFields() { {sshMode == 'userPassword' && } {sshMode == 'keyFile' && ( - - )} - - {sshMode == 'keyFile' && ( - + + + + + + + + )} {useSshTunnel && sshMode == 'agent' && ( diff --git a/packages/web/src/utility/flexGrid.js b/packages/web/src/utility/flexGrid.js new file mode 100644 index 000000000..0603932f5 --- /dev/null +++ b/packages/web/src/utility/flexGrid.js @@ -0,0 +1,73 @@ +// @ts-nocheck +import styled from 'styled-components'; + +export const FlexCol3 = styled.div` + flex-basis: 25%; + max-width: 25%; + ${props => + !!props.marginRight && + ` + margin-right: ${props.marginRight}px; + `} + ${props => + !!props.marginLeft && + ` + margin-left: ${props.marginLeft}px; + `} +`; +export const FlexCol4 = styled.div` + flex-basis: 33.3333%; + max-width: 33.3333%; + ${props => + !!props.marginRight && + ` + margin-right: ${props.marginRight}px; + `} + ${props => + !!props.marginLeft && + ` + margin-left: ${props.marginLeft}px; + `} +`; +export const FlexCol6 = styled.div` + flex-basis: 50%; + max-width: 50%; + ${props => + !!props.marginRight && + ` + margin-right: ${props.marginRight}px; + `} + ${props => + !!props.marginLeft && + ` + margin-left: ${props.marginLeft}px; + `} +`; +export const FlexCol8 = styled.div` + flex-basis: 66.6667%; + max-width: 66.6667%; + ${props => + !!props.marginRight && + ` + margin-right: ${props.marginRight}px; + `} + ${props => + !!props.marginLeft && + ` + margin-left: ${props.marginLeft}px; + `} +`; +export const FlexCol9 = styled.div` + flex-basis: 75%; + max-width: 75%; + ${props => + !!props.marginRight && + ` + margin-right: ${props.marginRight}px; + `} + ${props => + !!props.marginLeft && + ` + margin-left: ${props.marginLeft}px; + `} +`; diff --git a/packages/web/src/utility/formStyle.js b/packages/web/src/utility/formStyle.js index ff4369e50..7d21f831e 100644 --- a/packages/web/src/utility/formStyle.js +++ b/packages/web/src/utility/formStyle.js @@ -55,8 +55,18 @@ export function FormFieldTemplateTiny({ label, children, onLabelClick, type }) { ); } +const FormRowLargeTemplate = styled.div` + ${props => + // @ts-ignore + !props.noMargin && + ` + margin: 20px; + `} +`; + export const FormRowLarge = styled.div` margin: 20px; + display: flex; `; export const FormLabelLarge = styled.div` @@ -66,21 +76,28 @@ export const FormLabelLarge = styled.div` export const FormValueLarge = styled.div``; -export function FormFieldTemplateLarge({ label, onLabelClick, children, type }) { +export function FormFieldTemplateLarge({ label, onLabelClick, children, type, noMargin = false }) { const theme = useTheme(); if (type == 'checkbox') { return ( - + {children} {label} - + ); } return ( - + {label} {children} - + ); } diff --git a/packages/web/src/utility/forms.js b/packages/web/src/utility/forms.js index 2ec24e24e..7d20a7427 100644 --- a/packages/web/src/utility/forms.js +++ b/packages/web/src/utility/forms.js @@ -83,19 +83,19 @@ export function FormPasswordFieldRaw({ name, focused = false, ...other }) { ); } -export function FormTextField({ name, label, focused = false, ...other }) { +export function FormTextField({ name, label, focused = false, templateProps = undefined, ...other }) { const FieldTemplate = useFormFieldTemplate(); return ( - + ); } -export function FormPasswordField({ name, label, focused = false, ...other }) { +export function FormPasswordField({ name, label, focused = false, templateProps = undefined, ...other }) { const FieldTemplate = useFormFieldTemplate(); return ( - + ); @@ -112,11 +112,16 @@ export function FormCheckboxFieldRaw({ name = undefined, defaultValue = undefine // return ; } -export function FormCheckboxField({ label, ...other }) { +export function FormCheckboxField({ label, templateProps = undefined, ...other }) { const { values, setFieldValue } = useForm(); const FieldTemplate = useFormFieldTemplate(); return ( - setFieldValue(other.name, !values[other.name])}> + setFieldValue(other.name, !values[other.name])} + {...templateProps} + > ); @@ -134,10 +139,10 @@ export function FormSelectFieldRaw({ children, name, ...other }) { ); } -export function FormSelectField({ label, name, children = null, ...other }) { +export function FormSelectField({ label, name, children = null, templateProps = undefined, ...other }) { const FieldTemplate = useFormFieldTemplate(); return ( - + {children} @@ -353,10 +358,10 @@ export function FormElectronFileSelectorRaw({ name, ...other }) { ); } -export function FormElectronFileSelector({ label, name, ...other }) { +export function FormElectronFileSelector({ label, name, templateProps = undefined, ...other }) { const FieldTemplate = useFormFieldTemplate(); return ( - + );