fix: styling changes

This commit is contained in:
Pranshu Chittora 2022-04-05 12:19:54 +05:30
parent c9e02a8b25
commit 76fccbbba4
No known key found for this signature in database
GPG Key ID: 3A9E57A016CC0626
2 changed files with 21 additions and 12 deletions

View File

@ -2,7 +2,12 @@ import { Col, Row, Select } from 'antd';
import { find } from 'lodash-es'; import { find } from 'lodash-es';
import React, { useEffect, useRef, useState } from 'react'; import React, { useEffect, useRef, useState } from 'react';
import { Input, RetentionContainer, Typography } from './styles'; import {
Input,
RetentionContainer,
RetentionFieldInputContainer,
RetentionFieldLabel,
} from './styles';
import { import {
convertHoursValueToRelevantUnit, convertHoursValueToRelevantUnit,
SettingPeriod, SettingPeriod,
@ -22,7 +27,9 @@ function Retention({
timeUnitValue: initialTimeUnitValue, timeUnitValue: initialTimeUnitValue,
} = convertHoursValueToRelevantUnit(Number(retentionValue)); } = convertHoursValueToRelevantUnit(Number(retentionValue));
const [selectedTimeUnit, setSelectTimeUnit] = useState(initialTimeUnitValue); const [selectedTimeUnit, setSelectTimeUnit] = useState(initialTimeUnitValue);
const [selectedValue, setSelectedValue] = useState<number | null>(null); const [selectedValue, setSelectedValue] = useState<number | null>(
initialValue,
);
const interacted = useRef(false); const interacted = useRef(false);
useEffect(() => { useEffect(() => {
if (!interacted.current) setSelectedValue(initialValue); if (!interacted.current) setSelectedValue(initialValue);
@ -78,17 +85,10 @@ function Retention({
<RetentionContainer> <RetentionContainer>
<Row justify="space-between"> <Row justify="space-between">
<Col flex={1} style={{ display: 'flex' }}> <Col flex={1} style={{ display: 'flex' }}>
<Typography <RetentionFieldLabel>{text}</RetentionFieldLabel>
style={{
verticalAlign: 'middle',
whiteSpace: 'pre-wrap',
}}
>
{text}
</Typography>
</Col> </Col>
<Col flex="150px"> <Col flex="150px">
<div style={{ display: 'inline-flex' }}> <RetentionFieldInputContainer>
<Input <Input
value={selectedValue && selectedValue >= 0 ? selectedValue : ''} value={selectedValue && selectedValue >= 0 ? selectedValue : ''}
onChange={(e): void => onChangeHandler(e, setSelectedValue)} onChange={(e): void => onChangeHandler(e, setSelectedValue)}
@ -101,7 +101,7 @@ function Retention({
> >
{menuItems} {menuItems}
</Select> </Select>
</div> </RetentionFieldInputContainer>
</Col> </Col>
</Row> </Row>
</RetentionContainer> </RetentionContainer>

View File

@ -80,3 +80,12 @@ export const ErrorText = styled(TypographyComponent)`
font-style: italic; font-style: italic;
} }
`; `;
export const RetentionFieldLabel = styled(TypographyComponent)`
vertical-align: middle;
white-space: pre-wrap;
`;
export const RetentionFieldInputContainer = styled.div`
display: inline-flex;
`;