Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | 1x 5x 5x 3x 3x 3x 5x 5x 5x 1x | // @flow import React from 'react'; import MuiRaisedButton from 'material-ui/RaisedButton'; import lightBaseTheme from 'material-ui/styles/baseThemes/lightBaseTheme'; import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'; import getMuiTheme from 'material-ui/styles/getMuiTheme'; type Props = { /** * Override the default background color for the button, but not the default disabled * background color (use disabledBackgroundColor for this). */ backgroundColor?: string, /** Override the inline styles of the button element. */ buttonStyle?: Object, /** * The content of the button. If a label is provided via the label prop, the text within the * label will be displayed in addition to the content provided here. */ children?: Node, /** CSS class name of the root element */ className?: string, /** If true, the element's ripple effect will be disabled */ disableTouchRipple?: boolean, /** Button is disabled? */ disabled?: boolean, /** Override the default background for the disabled button */ disabledBackgroundColor?: string, /** Override the default label color for the disabled button */ disabledLabelColor?: string, /** Dash event handler for click events */ fireEvent?: () => void, /** If true, the button will take up the full width of its container */ fullWidth?: boolean, /** The URL to link to when the button is clicked */ href?: string, /** Use this property to display an icon */ icon?: Node, /** Element ID */ id?: string, /** * The label to be displayed within the button. If content is provided via the children prop, * that content will be displayed in addition to the label provided here. */ label: string, /** Color of the button's label */ labelColor?: string, /** The position of the button's label relative to its children */ labelPosition?: 'before' | 'after', /** Override the inline styles of the label element */ labelStyle?: Object, /** An integer that represents the number of times this element has been clicked */ n_clicks?: number, /** An integer that represents the previous number of times this element has been clicked */ n_clicks_previous?: number, /** Override the inline style of the button overlay */ overlayStyle?: Object, /** If true, the button will use the theme's primary color */ primary?: boolean, /** Color of the ripple on click */ rippleColor?: string, /** Override the inline style of the ripple element */ rippleStyle?: Object, /** * If true, the button will use the theme's secondary color. If both secondary and primary are * true, the button will use the theme's primary color. */ secondary?: boolean, /** Dash callback to update props on the server */ setProps?: () => void, /** Override the inline styles of the root element */ style?: Object, }; const defaultProps = { backgroundColor: '', buttonStyle: {}, children: null, className: '', disableTouchRipple: false, disabled: false, disabledBackgroundColor: '', disabledLabelColor: '', fireEvent: () => {}, fullWidth: false, href: '', icon: null, labelColor: '', labelPosition: 'after', labelStyle: {}, n_clicks: 0, n_clicks_previous: 0, overlayStyle: {}, primary: false, rippleStyle: {}, secondary: false, setProps: () => {}, style: {}, }; export default class RaisedButton extends React.Component<Props> { constructor(props: Props) { super(props); this.handleClick = this.handleClick.bind(this); } handleClick() { Eif (this.props.setProps) this.props.setProps({n_clicks: this.props.n_clicks + 1}); Eif (this.props.fireEvent) this.props.fireEvent({event: 'click'}); Eif (this.props.setProps) this.props.setProps({n_clicks_previous: this.props.n_clicks + 1}); } render() { const { backgroundColor, buttonStyle, className, disabled, disabledBackgroundColor, disabledLabelColor, disableTouchRipple, fullWidth, href, icon, id, label, labelColor, labelPosition, labelStyle, overlayStyle, primary, rippleColor, rippleStyle, secondary, style } = this.props; Eif (this.props.fireEvent || this.props.setProps) { return ( <div id={id}> <MuiThemeProvider muiTheme={getMuiTheme(lightBaseTheme)}> <MuiRaisedButton backgroundColor={backgroundColor} buttonStyle={buttonStyle} className={className} disabled={disabled} disabledBackgroundColor={disabledBackgroundColor} disabledLabelColor={disabledLabelColor} disableTouchRipple={disableTouchRipple} fullWidth={fullWidth} href={href} icon={icon} label={label} labelColor={labelColor} labelPosition={labelPosition} labelStyle={labelStyle} onClick={this.handleClick} overlayStyle={overlayStyle} primary={primary} rippleColor={rippleColor} rippleStyle={rippleStyle} secondary={secondary} style={style} > {this.props.children} </MuiRaisedButton> </MuiThemeProvider> </div>); } return ( <div id={id}> <MuiThemeProvider muiTheme={getMuiTheme(lightBaseTheme)}> <MuiRaisedButton backgroundColor={backgroundColor} buttonStyle={buttonStyle} className={className} disabled={disabled} disabledBackgroundColor={disabledBackgroundColor} disabledLabelColor={disabledLabelColor} disableTouchRipple={disableTouchRipple} fullWidth={fullWidth} href={href} icon={icon} label={label} labelColor={labelColor} labelPosition={labelPosition} labelStyle={labelStyle} overlayStyle={overlayStyle} primary={primary} rippleColor={rippleColor} rippleStyle={rippleStyle} secondary={secondary} style={style} > {this.props.children} </MuiRaisedButton> </MuiThemeProvider> </div>); } } RaisedButton.defaultProps = defaultProps; |