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

Added support for portrait size ratios #6501

Merged
merged 3 commits into from Dec 1, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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%;/);
});
});