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] Typography moved inside muitheme #3301

Merged
merged 1 commit into from
Feb 12, 2016
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
3 changes: 1 addition & 2 deletions src/Subheader/Subheader.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import muiThemeable from './../muiThemeable';
import Typography from '../styles/typography';

const propTypes = {
/**
Expand Down Expand Up @@ -48,7 +47,7 @@ let Subheader = (props) => {
boxSizing: 'border-box',
color: subheader.color,
fontSize: 14,
fontWeight: Typography.fontWeightMedium,
fontWeight: subheader.fontWeight,
lineHeight: '48px',
paddingLeft: inset ? 72 : 16,
width: '100%',
Expand Down
3 changes: 1 addition & 2 deletions src/app-bar.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import Typography from './styles/typography';
import IconButton from './icon-button';
import NavigationMenu from './svg-icons/navigation/menu';
import getMuiTheme from './styles/getMuiTheme';
Expand Down Expand Up @@ -38,7 +37,7 @@ function getStyles(props, state) {
paddingTop: 0,
letterSpacing: 0,
fontSize: 24,
fontWeight: Typography.fontWeightNormal,
fontWeight: appBar.titleFontWeight,
color: appBar.textColor,
lineHeight: `${appBar.height}px`,
},
Expand Down
3 changes: 1 addition & 2 deletions src/badge.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import Typography from './styles/typography';
import getMuiTheme from './styles/getMuiTheme';

function getStyles(props, state) {
Expand Down Expand Up @@ -45,7 +44,7 @@ function getStyles(props, state) {
position: 'absolute',
top: 0,
right: 0,
fontWeight: Typography.fontWeightMedium,
fontWeight: badge.fontWeight,
fontSize: radius,
width: radius2x,
height: radius2x,
Expand Down
3 changes: 1 addition & 2 deletions src/card/card-header.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import Avatar from '../avatar';
import getMuiTheme from '../styles/getMuiTheme';
import typography from '../styles/typography';

function getStyles(props, state) {
const {card} = state.muiTheme;
Expand All @@ -10,7 +9,7 @@ function getStyles(props, state) {
root: {
height: 72,
padding: 16,
fontWeight: typography.fontWeightMedium,
fontWeight: card.fontWeight,
boxSizing: 'border-box',
position: 'relative',
},
Expand Down
17 changes: 11 additions & 6 deletions src/card/card-media.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import React from 'react';
import getMuiTheme from '../styles/getMuiTheme';
import typography from '../styles/typography';

function getStyles() {
function getStyles(props, state) {
const {
cardMedia,
} = state.muiTheme;
return {
root: {
position: 'relative',
Expand All @@ -24,7 +26,7 @@ function getStyles() {
right: 0,
left: 0,
paddingTop: 8,
background: typography.textLightBlack,
background: cardMedia.overlayContentBackground,
},
media: {},
mediaChild: {
Expand Down Expand Up @@ -91,6 +93,9 @@ const CardMedia = React.createClass({
const overlayContainerStyle = Object.assign(styles.overlayContainer, this.props.overlayContainerStyle);
const overlayContentStyle = Object.assign(styles.overlayContent, this.props.overlayContentStyle);
const overlayStyle = Object.assign(styles.overlay, this.props.overlayStyle);
const titleColor = this.state.muiTheme.cardMedia.titleColor;
const subtitleColor = this.state.muiTheme.cardMedia.subtitleColor;
const color = this.state.muiTheme.cardMedia.color;

let children = React.Children.map(this.props.children, (child) => {
return React.cloneElement(child, {
Expand All @@ -101,12 +106,12 @@ const CardMedia = React.createClass({
let overlayChildren = React.Children.map(this.props.overlay, (child) => {
if (child.type.displayName === 'CardHeader' || child.type.displayName === 'CardTitle') {
return React.cloneElement(child, {
titleColor: typography.textDarkWhite,
subtitleColor: typography.textLightWhite,
titleColor: titleColor,
subtitleColor: subtitleColor,
});
} else if (child.type.displayName === 'CardText') {
return React.cloneElement(child, {
color: typography.textDarkWhite,
color: color,
});
} else {
return child;
Expand Down
7 changes: 4 additions & 3 deletions src/flat-button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import ContextPure from './mixins/context-pure';
import Transitions from './styles/transitions';
import Children from './utils/children';
import ColorManipulator from './utils/color-manipulator';
import Typography from './styles/typography';
import EnhancedButton from './enhanced-button';
import FlatButtonLabel from './buttons/flat-button-label';
import getMuiTheme from './styles/getMuiTheme';
Expand Down Expand Up @@ -255,14 +254,16 @@ const FlatButton = React.createClass({
const buttonRippleColor = rippleColor || defaultRippleColor;
const buttonBackgroundColor = backgroundColor || buttonColor;
const hovered = (this.state.hovered || this.state.isKeyboardFocused) && !disabled;
const fontSize = this.state.muiTheme.flatButton.fontSize;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, this can also be written like this:

const {
  fontSize,
  fontWeight,
} = this.state.muiTheme.flatButton;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should I update this change @newoga?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be okay for now, what do you think @oliviertassinari @alitaheri?

If the the theme changes are solid, I'm good merging this as is. I think for this file we'll have to revisit to removing ContextPure and getRelevantContextKeys. That might be a good opportunity to reorganize the assignment of theme variables.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll have to revisit all the files again. so this is alright in my book 😁

const fontWeight = this.state.muiTheme.flatButton.fontWeight;

const mergedRootStyles = Object.assign({}, {
color: defaultTextColor,
transition: Transitions.easeOut(),
fontSize: Typography.fontStyleButtonFontSize,
fontSize: fontSize,
letterSpacing: 0,
textTransform: textTransform,
fontWeight: Typography.fontWeightMedium,
fontWeight: fontWeight,
borderRadius: 2,
userSelect: 'none',
position: 'relative',
Expand Down
3 changes: 1 addition & 2 deletions src/raised-button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from 'react';
import Transitions from './styles/transitions';
import ColorManipulator from './utils/color-manipulator';
import Children from './utils/children';
import Typography from './styles/typography';
import EnhancedButton from './enhanced-button';
import Paper from './paper';
import getMuiTheme from './styles/getMuiTheme';
Expand Down Expand Up @@ -71,7 +70,7 @@ function getStyles(props, state) {
fontSize: '14px',
letterSpacing: 0,
textTransform: raisedButton.textTransform || button.textTransform || 'uppercase',
fontWeight: Typography.fontWeightMedium,
fontWeight: raisedButton.fontWeight,
margin: 0,
userSelect: 'none',
paddingLeft: icon && labelPosition !== 'before' ? 8 : baseTheme.spacing.desktopGutterLess,
Expand Down
14 changes: 14 additions & 0 deletions src/styles/getMuiTheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import lightBaseTheme from './baseThemes/lightBaseTheme';
import zIndex from './zIndex';
import {autoprefixer, callOnce, rtl} from './transformers';
import compose from 'lodash.flowright';
import Typography from '../styles/typography';

/**
* Get the MUI theme corresponding to a base theme.
Expand All @@ -29,6 +30,7 @@ export default function getMuiTheme(baseTheme, muiTheme) {
color: palette.primary1Color,
textColor: palette.alternateTextColor,
height: spacing.desktopKeylineIncrement,
titleFontWeight: Typography.fontWeightNormal,
},
avatar: {
color: palette.canvasColor,
Expand All @@ -44,6 +46,7 @@ export default function getMuiTheme(baseTheme, muiTheme) {
primaryTextColor: palette.alternateTextColor,
secondaryColor: palette.primary1Color,
secondaryTextColor: palette.alternateTextColor,
fontWeight: Typography.fontWeightMedium,
},
button: {
height: 36,
Expand All @@ -53,6 +56,13 @@ export default function getMuiTheme(baseTheme, muiTheme) {
card: {
titleColor: ColorManipulator.fade(palette.textColor, 0.87),
subtitleColor: ColorManipulator.fade(palette.textColor, 0.54),
fontWeight: Typography.fontWeightMedium,
},
cardMedia: {
color: Colors.darkWhite,
overlayContentBackground: Colors.lightBlack,
titleColor: Colors.darkWhite,
subtitleColor: Colors.lightWhite,
},
cardText: {
textColor: palette.textColor,
Expand Down Expand Up @@ -82,6 +92,8 @@ export default function getMuiTheme(baseTheme, muiTheme) {
textColor: palette.textColor,
primaryTextColor: palette.accent1Color,
secondaryTextColor: palette.primary1Color,
fontSize: Typography.fontStyleButtonFontSize,
fontWeight: Typography.fontWeightMedium,
},
floatingActionButton: {
buttonSize: 56,
Expand Down Expand Up @@ -158,6 +170,7 @@ export default function getMuiTheme(baseTheme, muiTheme) {
secondaryTextColor: palette.alternateTextColor,
disabledColor: ColorManipulator.darken(palette.alternateTextColor, 0.1),
disabledTextColor: ColorManipulator.fade(palette.textColor, 0.3),
fontWeight: Typography.fontWeightMedium,
},
refreshIndicator: {
strokeColor: palette.borderColor,
Expand Down Expand Up @@ -185,6 +198,7 @@ export default function getMuiTheme(baseTheme, muiTheme) {
},
subheader: {
color: ColorManipulator.fade(palette.textColor, 0.54),
fontWeight: Typography.fontWeightMedium,
},
table: {
backgroundColor: palette.canvasColor,
Expand Down