Skip to content

Commit

Permalink
feat(Ratio): add support for portrait size ratios (#6501)
Browse files Browse the repository at this point in the history
* Added support for portrait size ratios

* removed the 100% cap on the aspect ratio to allow portrait style size ratios

* modified RatioSpec to allow aspect ratio greater than 100%
  • Loading branch information
JustinTime42 committed Dec 1, 2022
1 parent eaa4bb9 commit 3cfdab1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Ratio.tsx
Expand Up @@ -37,7 +37,7 @@ const defaultProps = {
};

function toPercent(num: number): string {
if (num <= 0 || num > 100) return '100%';
if (num <= 0) return '100%';
if (num < 1) return `${num * 100}%`;
return `${num}%`;
}
Expand Down
4 changes: 2 additions & 2 deletions test/RatioSpec.tsx
Expand Up @@ -49,14 +49,14 @@ describe('Ratio', () => {
styleAttr.should.match(/--bs-aspect-ratio:[ ]*100%;/);
});

it('should support use 100% as custom ratio if aspectRatio is greater than 100', () => {
it('should support aspectRatio greater than 100', () => {
const { getByTestId } = render(
<Ratio data-testid="test" aspectRatio={200}>
<div />
</Ratio>,
);
const ratioElem = getByTestId('test');
const styleAttr = ratioElem.getAttribute('style')!;
styleAttr.should.match(/--bs-aspect-ratio:[ ]*100%;/);
styleAttr.should.match(/--bs-aspect-ratio:[ ]*200%;/);
});
});

0 comments on commit 3cfdab1

Please sign in to comment.