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

[theme] Add border-radius to the theme #11847

Merged
merged 2 commits into from
Jun 25, 2018
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
2 changes: 1 addition & 1 deletion docs/src/modules/components/Carbon.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const styles = theme => ({
},
ad: {
zIndex: 1,
borderRadius: 4,
borderRadius: theme.shape.borderRadius,
position: 'relative',
[theme.breakpoints.up('sm')]: {
margin: `${theme.spacing.unit * 2}px ${theme.spacing.unit}px ${theme.spacing.unit}px`,
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/demos/cards/cards.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Cards React component
components: Card, CardActions, CardContent, CardHeader, CardMedia, Collapse
components: Card, CardActions, CardContent, CardHeader, CardMedia, Collapse, Paper
---

# Cards
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const styles = theme => ({
margin: `${theme.spacing.unit * 3}px 0`,
padding: '12px 18px',
backgroundColor: theme.palette.background.paper,
borderRadius: 3,
borderRadius: theme.shape.borderRadius,
overflow: 'auto',
WebkitOverflowScrolling: 'touch', // iOS momentum scrolling.
},
Expand Down
4 changes: 2 additions & 2 deletions packages/material-ui/src/Button/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const styles = theme => ({
minWidth: 88,
minHeight: 36,
padding: '8px 16px',
borderRadius: 4,
borderRadius: theme.shape.borderRadius,
color: theme.palette.text.primary,
transition: theme.transitions.create(['background-color', 'box-shadow'], {
duration: theme.transitions.duration.short,
Expand Down Expand Up @@ -133,7 +133,7 @@ export const styles = theme => ({
},
},
extendedFab: {
borderRadius: 24,
borderRadius: 48 / 2,
padding: '0 16px',
width: 'initial',
minWidth: 48,
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/Card/Card.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function Card(props) {
const { classes, className, raised, ...other } = props;

return (
<Paper className={classNames(classes.root, className)} elevation={raised ? 8 : 2} {...other} />
<Paper className={classNames(classes.root, className)} elevation={raised ? 8 : 1} {...other} />
);
}

Expand Down
4 changes: 2 additions & 2 deletions packages/material-ui/src/Card/Card.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ describe('<Card />', () => {
classes = getClasses(<Card />);
});

it('should render Paper with the root class & with 2dp', () => {
it('should render Paper with the root class', () => {
const wrapper = shallow(<Card />);
assert.strictEqual(wrapper.type(), Paper);
assert.strictEqual(wrapper.props().elevation, 2);
assert.strictEqual(wrapper.props().elevation, 1);
});

it('should have the root and custom class', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/GridListTile/GridListTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import EventListener from 'react-event-listener';
import debounce from 'debounce';
import debounce from 'debounce'; // < 1kb payload overhead when lodash/debounce is > 3kb.
import withStyles from '../styles/withStyles';

export const styles = {
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/Input/Textarea.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import debounce from 'debounce';
import debounce from 'debounce'; // < 1kb payload overhead when lodash/debounce is > 3kb.
import EventListener from 'react-event-listener';
import withStyles from '../styles/withStyles';

Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/Paper/Paper.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const styles = theme => {
backgroundColor: theme.palette.background.paper,
},
rounded: {
borderRadius: 2,
borderRadius: theme.shape.borderRadius,
},
...elevations,
};
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/Popover/Popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import ReactDOM from 'react-dom';
import warning from 'warning';
import debounce from 'debounce';
import debounce from 'debounce'; // < 1kb payload overhead when lodash/debounce is > 3kb.
import EventListener from 'react-event-listener';
import ownerDocument from '../utils/ownerDocument';
import ownerWindow from '../utils/ownerWindow';
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/Slide/Slide.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import ReactDOM from 'react-dom';
import EventListener from 'react-event-listener';
import debounce from 'debounce';
import debounce from 'debounce'; // < 1kb payload overhead when lodash/debounce is > 3kb.
import Transition from 'react-transition-group/Transition';
import ownerWindow from '../utils/ownerWindow';
import withTheme from '../styles/withTheme';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const styles = theme => {
[theme.breakpoints.up('md')]: {
minWidth: 288,
maxWidth: 568,
borderRadius: 2,
borderRadius: theme.shape.borderRadius,
},
[theme.breakpoints.down('sm')]: {
flexGrow: 1,
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/Switch/Switch.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const styles = theme => ({
},
},
bar: {
borderRadius: 7,
borderRadius: 14 / 2,
display: 'block',
position: 'absolute',
width: 34,
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/Tabs/ScrollbarSize.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import EventListener from 'react-event-listener';
import debounce from 'debounce';
import debounce from 'debounce'; // < 1kb payload overhead when lodash/debounce is > 3kb.

const styles = {
width: '100px',
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/Tabs/Tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PropTypes from 'prop-types';
import warning from 'warning';
import classNames from 'classnames';
import EventListener from 'react-event-listener';
import debounce from 'debounce';
import debounce from 'debounce'; // < 1kb payload overhead when lodash/debounce is > 3kb.
import { getNormalizedScrollLeft, detectScrollType } from 'normalize-scroll-left';
import scroll from 'scroll';
import ScrollbarSize from './ScrollbarSize';
Expand Down
4 changes: 2 additions & 2 deletions packages/material-ui/src/Tooltip/Tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import EventListener from 'react-event-listener';
import debounce from 'debounce';
import debounce from 'debounce'; // < 1kb payload overhead when lodash/debounce is > 3kb.
import warning from 'warning';
import classNames from 'classnames';
import { Manager, Popper, Target } from 'react-popper';
Expand All @@ -24,7 +24,7 @@ export const styles = theme => ({
open: {},
tooltip: {
backgroundColor: theme.palette.grey[700],
borderRadius: 2,
borderRadius: theme.shape.borderRadius,
color: common.white,
fontFamily: theme.typography.fontFamily,
opacity: 0,
Expand Down
29 changes: 16 additions & 13 deletions packages/material-ui/src/styles/createMuiTheme.d.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,45 @@
import { Breakpoints, BreakpointsOptions } from './createBreakpoints';
import { Mixins, MixinsOptions } from './createMixins';
import { Palette, PaletteOptions } from './createPalette';
import { Typography, TypographyOptions } from './createTypography';
import { Shadows } from './shadows';
import { Shape, ShapeOptions } from './shape';
import { Spacing, SpacingOptions } from './spacing';
import { Transitions, TransitionsOptions } from './transitions';
import { Typography, TypographyOptions } from './createTypography';
import { ZIndex, ZIndexOptions } from './zIndex';
import { Overrides } from './overrides';
import { ComponentsProps } from './props';

export type Direction = 'ltr' | 'rtl';

export interface ThemeOptions {
shape?: ShapeOptions;
breakpoints?: BreakpointsOptions;
direction?: Direction;
palette?: PaletteOptions;
typography?: TypographyOptions | ((palette: Palette) => TypographyOptions);
mixins?: MixinsOptions;
breakpoints?: BreakpointsOptions;
overrides?: Overrides;
palette?: PaletteOptions;
props?: ComponentsProps;
shadows?: Shadows;
transitions?: TransitionsOptions;
spacing?: SpacingOptions;
transitions?: TransitionsOptions;
typography?: TypographyOptions | ((palette: Palette) => TypographyOptions);
zIndex?: ZIndexOptions;
overrides?: Overrides;
props?: ComponentsProps;
}

export interface Theme {
shape: Shape;
breakpoints: Breakpoints;
direction: Direction;
palette: Palette;
typography: Typography;
mixins: Mixins;
breakpoints: Breakpoints;
overrides?: Overrides;
palette: Palette;
props?: ComponentsProps;
shadows: Shadows;
transitions: Transitions;
spacing: Spacing;
transitions: Transitions;
typography: Typography;
zIndex: ZIndex;
overrides?: Overrides;
props?: ComponentsProps;
}

export default function createMuiTheme(options?: ThemeOptions): Theme;
12 changes: 7 additions & 5 deletions packages/material-ui/src/styles/createMuiTheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@

import deepmerge from 'deepmerge'; // < 1kb payload overhead when lodash/merge is > 3kb.
import warning from 'warning';
import createTypography from './createTypography';
import createBreakpoints from './createBreakpoints';
import createPalette from './createPalette';
import createMixins from './createMixins';
import createPalette from './createPalette';
import createTypography from './createTypography';
import shadows from './shadows';
import shape from './shape';
import spacing from './spacing';
import transitions from './transitions';
import zIndex from './zIndex';
import spacing from './spacing';

function createMuiTheme(options: Object = {}) {
const {
palette: paletteInput = {},
breakpoints: breakpointsInput = {},
mixins: mixinsInput = {},
typography: typographyInput = {},
palette: paletteInput = {},
shadows: shadowsInput,
typography: typographyInput = {},
...other
} = options;

Expand All @@ -32,6 +33,7 @@ function createMuiTheme(options: Object = {}) {
palette,
props: {}, // Inject custom properties
shadows: shadowsInput || shadows,
shape,
typography: createTypography(palette, typographyInput),
...deepmerge(
{
Expand Down
9 changes: 9 additions & 0 deletions packages/material-ui/src/styles/shape.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export interface Shape {
borderRadius: number;
}

export type ShapeOptions = Partial<Shape>;

declare const shape: Shape;

export default shape;
5 changes: 5 additions & 0 deletions packages/material-ui/src/styles/shape.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const shape = {
borderRadius: 4,
};

export default shape;
6 changes: 4 additions & 2 deletions packages/material-ui/src/styles/spacing.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
export default {
const spacing = {
// All components align to an 8dp square baseline grid for mobile, tablet, and desktop.
// https://material.io/guidelines/layout/metrics-keylines.html#metrics-keylines-baseline-grids
// https://material.io/design/layout/understanding-layout.html#pixel-density
unit: 8,
};

export default spacing;
2 changes: 1 addition & 1 deletion packages/material-ui/src/withWidth/withWidth.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import EventListener from 'react-event-listener';
import debounce from 'debounce';
import debounce from 'debounce'; // < 1kb payload overhead when lodash/debounce is > 3kb.
import wrapDisplayName from 'recompose/wrapDisplayName';
import hoistNonReactStatics from 'hoist-non-react-statics';
import withTheme from '../styles/withTheme';
Expand Down
1 change: 1 addition & 0 deletions pages/api/paper.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,6 @@ you need to use the following style sheet name: `MuiPaper`.
## Demos

- [Autocomplete](/demos/autocomplete)
- [Cards](/demos/cards)
- [Paper](/demos/paper)