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

Fix: RGBA calculations && issue 5540 #5544

Merged
merged 2 commits into from
Jan 17, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ export const NumberInput = factory<NumberInputFactory>((_props, ref) => {
__staticSelector="NumberInput"
decimalScale={allowDecimal ? decimalScale : 0}
onKeyDown={handleKeyDown}
rightSectionPointerEvents={rightSectionPointerEvents ?? disabled ? 'none' : undefined}
rightSectionPointerEvents={rightSectionPointerEvents ?? (disabled ? 'none' : undefined)}
rightSectionWidth={rightSectionWidth ?? `var(--ni-right-section-width-${size || 'sm'})`}
allowLeadingZeros={allowLeadingZeros}
onBlur={(event) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ describe('@mantine/core/to-rgba', () => {
expect(toRgba('rgb(240, 62, 62, 0.8)')).toStrictEqual({ r: 240, g: 62, b: 62, a: 0.8 });
expect(toRgba('rgb(214, 51, 108, 1)')).toStrictEqual({ r: 214, g: 51, b: 108, a: 1 });
expect(toRgba('rgb(112, 72, 232, .2)')).toStrictEqual({ r: 112, g: 72, b: 232, a: 0.2 });
expect(toRgba('rgb(240, 62, 62 / 0.8)')).toStrictEqual({ r: 240, g: 62, b: 62, a: 0.8 });
expect(toRgba('rgb(214, 51, 108 / 1)')).toStrictEqual({ r: 214, g: 51, b: 108, a: 1 });
expect(toRgba('rgb(112, 72, 232 / .2)')).toStrictEqual({ r: 112, g: 72, b: 232, a: 0.2 });
});

it('returns the correct rgba values when given an hsl string', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ function hexToRgba(color: string): RGBA {

function rgbStringToRgba(color: string): RGBA {
const [r, g, b, a] = color
.replace(/[^0-9,.]/g, '')
.split(',')
.replace(/[^0-9,./]/g, '')
.split(/[/,]/)
.map(Number);

return { r, g, b, a: a || 1 };
Expand Down