Skip to content

Commit

Permalink
fix(areaselector): fix incorrect height selection when using pixels
Browse files Browse the repository at this point in the history
Fix an issue when the max height could be greater than the image height by a small margin when the
selected unit were pixels
  • Loading branch information
ByronMunozG committed Jul 28, 2022
1 parent 7f40b98 commit 5d9ad55
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/components/AreaSelector/AreaSelector.stories.tsx
Expand Up @@ -2,12 +2,14 @@ import { useState } from 'react';
import { AreaSelector } from 'src/components/AreaSelector';
import { CustomAreaRenderer, IArea } from 'src/types';
import type { Story } from '@ladle/react';
import { IPropUnit } from './types';

export const AreaSelectExample: Story<{
maxAreas: number;
debug: boolean;
customRenderExampleText: string;
}> = ({ maxAreas, debug, customRenderExampleText }) => {
unit: IPropUnit;
}> = ({ maxAreas, debug, customRenderExampleText, unit }) => {
const [areas, setAreas] = useState<IArea[]>([]);
const onChangeHandler = (areas: IArea[]) => {
setAreas(areas);
Expand Down Expand Up @@ -38,8 +40,9 @@ export const AreaSelectExample: Story<{
opacity: '0.5'
}}
customAreaRenderer={customRender}
unit={unit}
>
<img src='logo512.png' />
<img src="logo512.png" />
</AreaSelector>
);
};
Expand All @@ -49,3 +52,10 @@ AreaSelectExample.args = {
debug: true,
customRenderExampleText: 'test'
};
AreaSelectExample.argTypes = {
unit: {
options: ['pixel', 'percentage'],
control: { type: 'select' },
defaultValue: 'pixel'
}
};
1 change: 1 addition & 0 deletions src/components/AreaSelector/AreaSelector.tsx
Expand Up @@ -408,6 +408,7 @@ export const AreaSelector: FunctionComponent<IAreaSelectorProps> = ({
boxSizing: 'border-box',
maxWidth: '100%',
touchAction: 'none',
lineHeight: 0,
...wrapperStyle
}}
>
Expand Down

0 comments on commit 5d9ad55

Please sign in to comment.