UNPKG

1.92 kBJavaScriptView Raw
1import * as React from 'react';
2import PropTypes from 'prop-types';
3import clsx from 'clsx';
4import RadioButtonUncheckedIcon from '../internal/svg-icons/RadioButtonUnchecked';
5import RadioButtonCheckedIcon from '../internal/svg-icons/RadioButtonChecked';
6import withStyles from '../styles/withStyles';
7export const styles = theme => ({
8 root: {
9 position: 'relative',
10 display: 'flex',
11 '&$checked $layer': {
12 transform: 'scale(1)',
13 transition: theme.transitions.create('transform', {
14 easing: theme.transitions.easing.easeOut,
15 duration: theme.transitions.duration.shortest
16 })
17 }
18 },
19 layer: {
20 left: 0,
21 position: 'absolute',
22 transform: 'scale(0)',
23 transition: theme.transitions.create('transform', {
24 easing: theme.transitions.easing.easeIn,
25 duration: theme.transitions.duration.shortest
26 })
27 },
28 checked: {}
29});
30/**
31 * @ignore - internal component.
32 */
33
34function RadioButtonIcon(props) {
35 const {
36 checked,
37 classes,
38 fontSize
39 } = props;
40 return /*#__PURE__*/React.createElement("div", {
41 className: clsx(classes.root, checked && classes.checked)
42 }, /*#__PURE__*/React.createElement(RadioButtonUncheckedIcon, {
43 fontSize: fontSize
44 }), /*#__PURE__*/React.createElement(RadioButtonCheckedIcon, {
45 fontSize: fontSize,
46 className: classes.layer
47 }));
48}
49
50process.env.NODE_ENV !== "production" ? RadioButtonIcon.propTypes = {
51 /**
52 * If `true`, the component is checked.
53 */
54 checked: PropTypes.bool,
55
56 /**
57 * Override or extend the styles applied to the component.
58 * See [CSS API](#css) below for more details.
59 */
60 classes: PropTypes.object.isRequired,
61
62 /**
63 * The size of the radio.
64 * `small` is equivalent to the dense radio styling.
65 */
66 fontSize: PropTypes.oneOf(['small', 'medium'])
67} : void 0;
68export default withStyles(styles, {
69 name: 'PrivateRadioButtonIcon'
70})(RadioButtonIcon);
\No newline at end of file