Skip to content

Commit 67076a4

Browse files
codiinisiriwatknp
andauthored
[system] Update the type for borderRadius (#46154)
Signed-off-by: Iniubong Obonguko <[email protected]> Co-authored-by: siriwatknp <[email protected]>
1 parent 2eaf854 commit 67076a4

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

packages/mui-material/src/styles/createTheme.spec.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,12 +249,19 @@ const theme = createTheme();
249249
{
250250
createTheme({
251251
shape: {
252-
// @ts-expect-error invalid borderRadius string value in theme
253252
borderRadius: '5px',
254253
},
255254
});
256255
}
257256

257+
{
258+
createTheme({
259+
shape: {
260+
borderRadius: 8,
261+
},
262+
});
263+
}
264+
258265
// CSS variables for shadow DOM
259266
{
260267
createTheme({

packages/mui-system/src/borders/borders.test.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,34 @@ describe('borders', () => {
2323
borderRadius: 0,
2424
});
2525
});
26+
27+
describe('theme shape as string', () => {
28+
it('should work ', () => {
29+
const output = borders({
30+
borderRadius: 2,
31+
theme: {
32+
shape: {
33+
borderRadius: '4px',
34+
},
35+
},
36+
});
37+
expect(output).to.deep.equal({
38+
borderRadius: 'calc(2 * 4px)',
39+
});
40+
});
41+
42+
it('should work with 0', () => {
43+
const output = borders({
44+
borderRadius: 0,
45+
theme: {
46+
shape: {
47+
borderRadius: '4px',
48+
},
49+
},
50+
});
51+
expect(output).to.deep.equal({
52+
borderRadius: 'calc(0 * 4px)',
53+
});
54+
});
55+
});
2656
});

packages/mui-system/src/createTheme/shape.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export interface Shape {
2-
borderRadius: number;
2+
borderRadius: number | string;
33
}
44

55
export type ShapeOptions = Partial<Shape>;

0 commit comments

Comments
 (0)