Skip to content

fix(localized-multiline-text-input): margin fix #1089

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

Merged
merged 1 commit into from
Oct 8, 2019
Merged
Changes from all commits
Commits
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
fix(localized-multiline-text-input): margin fix
  • Loading branch information
montezume committed Oct 7, 2019
commit feb30f5c09b569a17bd72ad1107361f2ef82b59c
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import requiredIf from 'react-required-if';
import { css } from '@emotion/core';
import styled from '@emotion/styled';
import MultilineInput from '../../internals/multiline-input';
import FlatButton from '../../buttons/flat-button';
import { AngleUpIcon } from '../../icons';
@@ -14,6 +15,21 @@ import {
getLanguageLabelStyles,
} from './translation-input.styles';

const LeftColumn = styled.div`
flex: 1;
`;

const RightColumn = styled.div`
flex: 0;
`;

const Row = styled.div`
display: flex;
&:empty {
margin: 0 !important;
}
`;

const TranslationInput = props => {
const [contentRowCount, setContentRowCount] = React.useState(
TranslationInput.MIN_ROW_COUNT
@@ -99,37 +115,40 @@ const TranslationInput = props => {
{...filterDataAttributes(props)}
/>
</div>
<div
css={css`
display: flex;
`}
>
<div
css={css`
flex: 1;
`}
>
{(() => {
if (props.error) return <div>{props.error}</div>;
if (props.warning) return <div>{props.warning}</div>;
return props.languagesControl;
})()}
</div>
<div
css={css`
flex: 0;
`}
>
{!props.isCollapsed && contentExceedsShownRows && (
<FlatButton
onClick={props.onToggle}
isDisabled={props.isDisabled}
label={props.intl.formatMessage(messages.collapse)}
icon={<AngleUpIcon size="small" />}
/>
)}
</div>
</div>
<Row>
{(() => {
if (props.error)
return (
<LeftColumn>
<div>{props.error}</div>
</LeftColumn>
);
if (props.warning)
return (
<LeftColumn>
<div>{props.warning}</div>
</LeftColumn>
);
return (
props.languagesControl && (
<LeftColumn>{props.languagesControl}</LeftColumn>
)
);
})()}
{!props.isCollapsed && contentExceedsShownRows && (
<React.Fragment>
<LeftColumn />
<RightColumn>
<FlatButton
onClick={props.onToggle}
isDisabled={props.isDisabled}
label={props.intl.formatMessage(messages.collapse)}
icon={<AngleUpIcon size="small" />}
/>
</RightColumn>
</React.Fragment>
)}
</Row>
{(props.error || props.warning) && props.languagesControl}
</Spacings.Stack>
);