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

[core] Avoid !important in borderColor prop #16875

Merged
merged 2 commits into from
Aug 5, 2019
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 14 additions & 29 deletions docs/src/pages/system/borders/BorderAdditive.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,21 @@
import React from 'react';
import Grid from '@material-ui/core/Grid';
import Box from '@material-ui/core/Box';

const inner = (
<Box
bgcolor="background.paper"
m={1}
borderColor="text.primary"
style={{ width: '5rem', height: '5rem' }}
/>
);
const defaultProps = {
bgcolor: 'background.paper',
m: 1,
style: { width: '5rem', height: '5rem' },
borderColor: 'text.primary',
};

function BorderAdditive() {
export default function BorderAdditive() {
return (
<Grid container justify="center">
<Box border={1} clone>
{inner}
</Box>
<Box borderTop={1} clone>
{inner}
</Box>
<Box borderRight={1} clone>
{inner}
</Box>
<Box borderBottom={1} clone>
{inner}
</Box>
<Box borderLeft={1} clone>
{inner}
</Box>
</Grid>
<Box display="flex" justifyContent="center">
<Box border={1} {...defaultProps} />
<Box borderTop={1} {...defaultProps} />
<Box borderRight={1} {...defaultProps} />
<Box borderBottom={1} {...defaultProps} />
<Box borderLeft={1} {...defaultProps} />
</Box>
);
}

export default BorderAdditive;
21 changes: 21 additions & 0 deletions docs/src/pages/system/borders/BorderAdditive.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react';
import Box from '@material-ui/core/Box';

const defaultProps = {
bgcolor: 'background.paper',
m: 1,
style: { width: '5rem', height: '5rem' },
borderColor: 'text.primary',
};

export default function BorderAdditive() {
return (
<Box display="flex" justifyContent="center">
<Box border={1} {...defaultProps} />
<Box borderTop={1} {...defaultProps} />
<Box borderRight={1} {...defaultProps} />
<Box borderBottom={1} {...defaultProps} />
<Box borderLeft={1} {...defaultProps} />
</Box>
);
}
38 changes: 14 additions & 24 deletions docs/src/pages/system/borders/BorderColor.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,21 @@
import React from 'react';
import Grid from '@material-ui/core/Grid';
import Box from '@material-ui/core/Box';

const inner = (
<Box bgcolor="background.paper" m={1} border={1} style={{ width: '5rem', height: '5rem' }} />
);
const defaultProps = {
bgcolor: 'background.paper',
m: 1,
border: 1,
style: { width: '5rem', height: '5rem' },
};

function BorderColor() {
export default function BorderColor() {
return (
<Grid container justify="center">
<Box borderColor="primary.main" clone>
{inner}
</Box>
<Box borderColor="secondary.main" clone>
{inner}
</Box>
<Box borderColor="error.main" clone>
{inner}
</Box>
<Box borderColor="grey.500" clone>
{inner}
</Box>
<Box borderColor="text.primary" clone>
{inner}
</Box>
</Grid>
<Box display="flex" justifyContent="center">
<Box borderColor="primary.main" {...defaultProps} />
<Box borderColor="secondary.main" {...defaultProps} />
<Box borderColor="error.main" {...defaultProps} />
<Box borderColor="grey.500" {...defaultProps} />
<Box borderColor="text.primary" {...defaultProps} />
</Box>
);
}

export default BorderColor;
21 changes: 21 additions & 0 deletions docs/src/pages/system/borders/BorderColor.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react';
import Box from '@material-ui/core/Box';

const defaultProps = {
bgcolor: 'background.paper',
m: 1,
border: 1,
style: { width: '5rem', height: '5rem' },
};

export default function BorderColor() {
return (
<Box display="flex" justifyContent="center">
<Box borderColor="primary.main" {...defaultProps} />
<Box borderColor="secondary.main" {...defaultProps} />
<Box borderColor="error.main" {...defaultProps} />
<Box borderColor="grey.500" {...defaultProps} />
<Box borderColor="text.primary" {...defaultProps} />
</Box>
);
}
37 changes: 13 additions & 24 deletions docs/src/pages/system/borders/BorderRadius.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,20 @@
import React from 'react';
import Grid from '@material-ui/core/Grid';
import Box from '@material-ui/core/Box';

const inner = (
<Box
bgcolor="background.paper"
borderColor="text.primary"
m={1}
border={1}
style={{ width: '5rem', height: '5rem' }}
/>
);
const defaultProps = {
bgcolor: 'background.paper',
borderColor: 'text.primary',
m: 1,
border: 1,
style: { width: '5rem', height: '5rem' },
};

function BorderRadius() {
export default function BorderRadius() {
return (
<Grid container justify="center">
<Box borderRadius="50%" clone>
{inner}
</Box>
<Box borderRadius="borderRadius" clone>
{inner}
</Box>
<Box borderRadius={16} clone>
{inner}
</Box>
</Grid>
<Box display="flex" justifyContent="center">
<Box borderRadius="50%" {...defaultProps} />
<Box borderRadius="borderRadius" {...defaultProps} />
<Box borderRadius={16} {...defaultProps} />
</Box>
);
}

export default BorderRadius;
20 changes: 20 additions & 0 deletions docs/src/pages/system/borders/BorderRadius.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react';
import Box from '@material-ui/core/Box';

const defaultProps = {
bgcolor: 'background.paper',
borderColor: 'text.primary',
m: 1,
border: 1,
style: { width: '5rem', height: '5rem' },
};

export default function BorderRadius() {
return (
<Box display="flex" justifyContent="center">
<Box borderRadius="50%" {...defaultProps} />
<Box borderRadius="borderRadius" {...defaultProps} />
<Box borderRadius={16} {...defaultProps} />
</Box>
);
}
45 changes: 15 additions & 30 deletions docs/src/pages/system/borders/BorderSubtractive.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,22 @@
import React from 'react';
import Grid from '@material-ui/core/Grid';
import Box from '@material-ui/core/Box';

const inner = (
<Box
bgcolor="background.paper"
border={1}
m={1}
borderColor="text.primary"
style={{ width: '5rem', height: '5rem' }}
/>
);
const defaultProps = {
bgcolor: 'background.paper',
border: 1,
m: 1,
borderColor: 'text.primary',
style: { width: '5rem', height: '5rem' },
};

function BorderSubtractive() {
export default function BorderSubtractive() {
return (
<Grid container justify="center">
<Box border={0} clone>
{inner}
</Box>
<Box borderTop={0} clone>
{inner}
</Box>
<Box borderRight={0} clone>
{inner}
</Box>
<Box borderBottom={0} clone>
{inner}
</Box>
<Box borderLeft={0} clone>
{inner}
</Box>
</Grid>
<Box display="flex" justifyContent="center">
<Box border={0} {...defaultProps} />
<Box borderTop={0} {...defaultProps} />
<Box borderRight={0} {...defaultProps} />
<Box borderBottom={0} {...defaultProps} />
<Box borderLeft={0} {...defaultProps} />
</Box>
);
}

export default BorderSubtractive;
22 changes: 22 additions & 0 deletions docs/src/pages/system/borders/BorderSubtractive.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react';
import Box from '@material-ui/core/Box';

const defaultProps = {
bgcolor: 'background.paper',
border: 1,
m: 1,
borderColor: 'text.primary',
style: { width: '5rem', height: '5rem' },
};

export default function BorderSubtractive() {
return (
<Box display="flex" justifyContent="center">
<Box border={0} {...defaultProps} />
<Box borderTop={0} {...defaultProps} />
<Box borderRight={0} {...defaultProps} />
<Box borderBottom={0} {...defaultProps} />
<Box borderLeft={0} {...defaultProps} />
</Box>
);
}
3 changes: 1 addition & 2 deletions packages/material-ui-system/src/borders.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function getBorder(value) {
return value;
}

return `${value}px solid${value === 0 ? ' !important' : ''}`;
return `${value}px solid`;
}

export const border = style({
Expand Down Expand Up @@ -42,7 +42,6 @@ export const borderLeft = style({
export const borderColor = style({
prop: 'borderColor',
themeKey: 'palette',
transform: value => `${value} !important`,
});

export const borderRadius = style({
Expand Down