Skip to content
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

style: update multiple choice input node style #1954

Merged
merged 7 commits into from
Feb 13, 2020
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
LoopIconSize,
ChoiceInputSize,
ChoiceInputMarginTop,
ChoiceInputMarginBottom,
} from '../../src/constants/ElementSizes';

describe('measureJsonBoundary', () => {
Expand All @@ -34,13 +35,23 @@ describe('measureJsonBoundary', () => {
);
});
it("should return boundary whose size is determined by the data's choices when json.$type is choiceInput", () => {
const data: { [key: string]: any } = {
const data1: { [key: string]: any } = {
$type: ObiTypes.ChoiceInputDetail,
choices: [{ value: '1' }],
};

expect(measureJsonBoundary(data)).toEqual(
new Boundary(InitNodeSize.width, InitNodeSize.height + ChoiceInputSize.height + ChoiceInputMarginTop)
const data2: { [key: string]: any } = {
$type: ObiTypes.ChoiceInputDetail,
choices: [{ value: '1' }, { value: '2' }, { value: '3' }, { value: '4' }, { value: '5' }],
};
expect(measureJsonBoundary(data1)).toEqual(
new Boundary(
InitNodeSize.width,
InitNodeSize.height + ChoiceInputSize.height + ChoiceInputMarginTop + ChoiceInputMarginBottom
)
);
expect(measureJsonBoundary(data2)).toEqual(
new Boundary(InitNodeSize.width, InitNodeSize.height + 4 * (ChoiceInputSize.height + ChoiceInputMarginTop))
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ export const TriggerSize = InitNodeSize;
export const TerminatorSize = { width: 14, height: 14 };

export const ChoiceInputSize = {
width: 145,
width: 155,
height: 22,
};

export const ChoiceInputMarginTop = 5;
export const ChoiceInputMarginTop = 8;
export const ChoiceInputMarginBottom = 10;

export const EventNodeSize = {
width: 240,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
LoopIconSize,
ChoiceInputSize,
ChoiceInputMarginTop,
ChoiceInputMarginBottom,
IconBrickSize,
} from '../constants/ElementSizes';
import { transformIfCondtion } from '../transformers/transformIfCondition';
Expand Down Expand Up @@ -64,7 +65,9 @@ export function measureChoiceInputDetailBoundary(data): Boundary {
const height =
InitNodeSize.height +
(data.choices && Array.isArray(data.choices)
? (data.choices.length <= 4 ? data.choices.length : 4) * (ChoiceInputSize.height + ChoiceInputMarginTop)
? data.choices.length < 4
? data.choices.length * (ChoiceInputSize.height + ChoiceInputMarginTop) + ChoiceInputMarginBottom
: 4 * (ChoiceInputSize.height + ChoiceInputMarginTop)
: 0);
return new Boundary(width, height);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const ChoiceInputChoices = ({ choices }) => {
}

return (
<div data-testid="ChoiceInput" css={{ padding: '0 0 8px 45px' }}>
<div data-testid="ChoiceInput" css={{ padding: '0 0 16px 29px' }}>
{choices.map(({ value }, index) => {
if (index < 3) {
return (
Expand Down Expand Up @@ -60,7 +60,7 @@ export const ChoiceInputChoices = ({ choices }) => {
textAlign: 'center',
fontFamily: 'Segoe UI',
fontSize: '12px',
lineHeight: '19px',
lineHeight: '14px',
boxSizing: 'border-box',
}}
>
Expand Down