This commit is contained in:
Jan Prochazka
2021-02-14 09:26:24 +01:00
parent d08fc85459
commit b0deba4bae
4 changed files with 51 additions and 25 deletions

View File

@@ -43,6 +43,7 @@ const ButtonsContainer = styled.div`
const AgentInfoWrap = styled.div` const AgentInfoWrap = styled.div`
margin-left: 20px; margin-left: 20px;
margin-bottom: 20px;
`; `;
function DriverFields({ extensions }) { function DriverFields({ extensions }) {

View File

@@ -14,10 +14,10 @@ export const FormLabel = styled.div`
export const FormValue = styled.div``; export const FormValue = styled.div``;
export function FormFieldTemplateDefault({ label, children, onLabelClick, type }) { export function FormFieldTemplateDefault({ label, children, labelProps, type }) {
return ( return (
<FormRow> <FormRow>
<FormLabel onClick={onLabelClick}>{label}</FormLabel> <FormLabel {...labelProps}>{label}</FormLabel>
<FormValue>{children}</FormValue> <FormValue>{children}</FormValue>
</FormRow> </FormRow>
); );
@@ -36,19 +36,33 @@ export const FormValueTiny = styled.div`
margin-top: 3px; margin-top: 3px;
`; `;
export function FormFieldTemplateTiny({ label, children, onLabelClick, type }) { const FormLabelSpan = styled.span`
${props =>
// @ts-ignore
props.disabled &&
`
color: ${props.theme.manager_font3};
`}
`;
export function FormFieldTemplateTiny({ label, children, labelProps, type }) {
const theme = useTheme(); const theme = useTheme();
if (type == 'checkbox') { if (type == 'checkbox') {
return ( return (
<FormRowTiny> <FormRowTiny>
{children} <span onClick={onLabelClick}>{label}</span> {children}{' '}
<FormLabelSpan theme={theme} {...labelProps}>
{label}
</FormLabelSpan>
</FormRowTiny> </FormRowTiny>
); );
} }
return ( return (
<FormRowTiny> <FormRowTiny>
<FormLabelTiny theme={theme} onClick={onLabelClick}> <FormLabelTiny theme={theme}>
<FormLabelSpan theme={theme} {...labelProps}>
{label} {label}
</FormLabelSpan>
</FormLabelTiny> </FormLabelTiny>
<FormValueTiny>{children}</FormValueTiny> <FormValueTiny>{children}</FormValueTiny>
</FormRowTiny> </FormRowTiny>
@@ -76,7 +90,7 @@ export const FormLabelLarge = styled.div`
export const FormValueLarge = styled.div``; export const FormValueLarge = styled.div``;
export function FormFieldTemplateLarge({ label, onLabelClick, children, type, noMargin = false }) { export function FormFieldTemplateLarge({ label, labelProps, children, type, noMargin = false }) {
const theme = useTheme(); const theme = useTheme();
if (type == 'checkbox') { if (type == 'checkbox') {
return ( return (
@@ -84,7 +98,10 @@ export function FormFieldTemplateLarge({ label, onLabelClick, children, type, no
// @ts-ignore // @ts-ignore
noMargin={noMargin} noMargin={noMargin}
> >
{children} <span onClick={onLabelClick}>{label}</span> {children}{' '}
<FormLabelSpan {...labelProps} theme={theme}>
{label}
</FormLabelSpan>
</FormRowLargeTemplate> </FormRowLargeTemplate>
); );
} }
@@ -94,8 +111,10 @@ export function FormFieldTemplateLarge({ label, onLabelClick, children, type, no
// @ts-ignore // @ts-ignore
noMargin={noMargin} noMargin={noMargin}
> >
<FormLabelLarge theme={theme} onClick={onLabelClick}> <FormLabelLarge theme={theme}>
<FormLabelSpan theme={theme} {...labelProps}>
{label} {label}
</FormLabelSpan>
</FormLabelLarge> </FormLabelLarge>
<FormValueLarge>{children}</FormValueLarge> <FormValueLarge>{children}</FormValueLarge>
</FormRowLargeTemplate> </FormRowLargeTemplate>

View File

@@ -75,7 +75,7 @@ export function FormPasswordFieldRaw({ name, focused = false, ...other }) {
type={isCrypted || showPassword ? 'text' : 'password'} type={isCrypted || showPassword ? 'text' : 'password'}
/> />
{!isCrypted && ( {!isCrypted && (
<InlineButton onClick={() => setShowPassword(x => !x)}> <InlineButton onClick={() => setShowPassword(x => !x)} disabled={other.disabled}>
<FontIcon icon="icon eye" /> <FontIcon icon="icon eye" />
</InlineButton> </InlineButton>
)} )}
@@ -119,7 +119,9 @@ export function FormCheckboxField({ label, templateProps = undefined, ...other }
<FieldTemplate <FieldTemplate
label={label} label={label}
type="checkbox" type="checkbox"
onLabelClick={other.disabled ? undefined : () => setFieldValue(other.name, !values[other.name])} labelProps={
other.disabled ? { disabled: true } : { onClick: () => setFieldValue(other.name, !values[other.name]) }
}
{...templateProps} {...templateProps}
> >
<FormCheckboxFieldRaw {...other} /> <FormCheckboxFieldRaw {...other} />
@@ -353,7 +355,7 @@ export function FormElectronFileSelectorRaw({ name, ...other }) {
return ( return (
<FlexContainer> <FlexContainer>
<TextField value={values[name]} onClick={handleBrowse} {...other} readOnly /> <TextField value={values[name]} onClick={handleBrowse} {...other} readOnly />
<InlineButton onClick={handleBrowse}>Browse</InlineButton> <InlineButton onClick={handleBrowse} disabled={other.disabled}>Browse</InlineButton>
</FlexContainer> </FlexContainer>
); );
} }

View File

@@ -14,22 +14,26 @@ const ButtonDiv = styled.div`
display: inline-block; display: inline-block;
cursor: pointer; cursor: pointer;
vertical-align: middle; vertical-align: middle;
color: ${props => props.theme.inlinebtn_font1}; color: ${props => (props.disabled ? props.theme.inlinebtn_font3 : props.theme.inlinebtn_font1)};
font-size: 12px; font-size: 12px;
padding: 3px; padding: 3px;
margin: 0; margin: 0;
text-decoration: none; text-decoration: none;
${props =>
!props.disabled &&
`
&:hover { &:hover {
border: 1px solid ${props => props.theme.inlinebtn_font2}; border: 1px solid ${props.theme.inlinebtn_font2};
} }
&:active:hover { &:active:hover {
background: linear-gradient( background: linear-gradient(
to bottom, to bottom,
${props => props.theme.inlinebtn_background3} 5%, ${props.theme.inlinebtn_background3} 5%,
${props => props.theme.inlinebtn_background} 100% ${props.theme.inlinebtn_background} 100%
); );
background-color: ${props => props.theme.inlinebtn_background3}; background-color: ${props.theme.inlinebtn_background3};
} }
`}
display: flex; display: flex;
${props => ${props =>