@arcblock/ux 1.17.21 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/ActionButton/index.js +1 -1
- package/lib/ActivityIndicator/index.js +5 -7
- package/lib/Alert/index.js +3 -3
- package/lib/Async/index.js +1 -1
- package/lib/Badge/index.js +1 -1
- package/lib/Blocklet/blocklet.js +5 -5
- package/lib/BlockletNFT/index.js +7 -7
- package/lib/Button/index.js +1 -1
- package/lib/Button/wrap.js +2 -21
- package/lib/ButtonGroup/index.js +2 -2
- package/lib/ClickToCopy/index.js +2 -2
- package/lib/CodeBlock/index.js +3 -3
- package/lib/ContactForm/index.js +3 -3
- package/lib/CookieConsent/index.js +7 -3
- package/lib/Dialog/dialog.js +10 -9
- package/lib/Footer/index.js +1 -1
- package/lib/Header/header.js +4 -4
- package/lib/Header/responsive-header.js +7 -7
- package/lib/Icon/index.js +1 -1
- package/lib/Img/index.js +12 -7
- package/lib/InfoRow/index.js +1 -1
- package/lib/Layout/dashboard/header.js +9 -9
- package/lib/Layout/dashboard/index.js +3 -3
- package/lib/Layout/dashboard/sidebar.js +6 -6
- package/lib/Layout/index.js +19 -16
- package/lib/Locale/selector.js +16 -11
- package/lib/NFTDisplay/broken.js +1 -1
- package/lib/NavMenu/nav-menu.js +1 -1
- package/lib/PageScroller/index.js +6 -2
- package/lib/PricingTable/PricingPlan.js +4 -4
- package/lib/PricingTable/index.js +2 -2
- package/lib/Result/common.js +3 -3
- package/lib/Result/index.js +3 -6
- package/lib/Result/result.js +3 -2
- package/lib/Spinner/index.js +2 -2
- package/lib/SplitButton/index.js +8 -8
- package/lib/Switch/index.js +60 -60
- package/lib/Tabs/index.js +26 -17
- package/lib/Tag/index.js +2 -2
- package/lib/TextCollapse/index.js +1 -1
- package/lib/Theme/index.js +51 -67
- package/lib/Toast/index.js +12 -11
- package/lib/Video/index.js +1 -1
- package/lib/Wallet/Action.js +1 -1
- package/lib/Wallet/Download.js +1 -1
- package/lib/Wallet/Open.js +1 -1
- package/lib/WechatPrompt/index.js +2 -2
- package/lib/withTheme/index.js +3 -3
- package/package.json +10 -8
- package/src/ActionButton/index.js +1 -1
- package/src/ActivityIndicator/index.js +1 -2
- package/src/Alert/index.js +2 -2
- package/src/Async/index.js +1 -1
- package/src/Badge/index.js +1 -1
- package/src/Blocklet/blocklet.js +4 -4
- package/src/BlockletNFT/index.js +7 -7
- package/src/Button/index.js +1 -1
- package/src/Button/wrap.js +2 -9
- package/src/ButtonGroup/index.js +2 -2
- package/src/ClickToCopy/index.js +2 -2
- package/src/CodeBlock/index.js +3 -3
- package/src/ContactForm/index.js +3 -3
- package/src/CookieConsent/index.js +4 -3
- package/src/Dialog/dialog.js +12 -9
- package/src/Footer/index.js +1 -1
- package/src/Header/header.js +5 -5
- package/src/Header/responsive-header.js +7 -7
- package/src/Icon/index.js +1 -0
- package/src/Img/index.js +12 -6
- package/src/InfoRow/index.js +1 -1
- package/src/Layout/dashboard/header.js +10 -10
- package/src/Layout/dashboard/index.js +3 -3
- package/src/Layout/dashboard/sidebar.js +10 -13
- package/src/Layout/index.js +18 -16
- package/src/Locale/selector.js +22 -17
- package/src/NFTDisplay/broken.js +1 -1
- package/src/NavMenu/nav-menu.js +1 -1
- package/src/PageScroller/index.js +4 -2
- package/src/PricingTable/PricingPlan.js +4 -4
- package/src/PricingTable/index.js +2 -2
- package/src/Result/common.js +3 -3
- package/src/Result/index.js +0 -2
- package/src/Result/result.js +3 -2
- package/src/Spinner/index.js +2 -2
- package/src/SplitButton/index.js +8 -8
- package/src/Switch/index.js +44 -48
- package/src/Tabs/index.js +16 -10
- package/src/Tag/index.js +2 -2
- package/src/TextCollapse/index.js +1 -1
- package/src/Theme/index.js +44 -57
- package/src/Toast/index.js +11 -11
- package/src/Video/index.js +1 -1
- package/src/Wallet/Action.js +1 -1
- package/src/Wallet/Download.js +1 -1
- package/src/Wallet/Open.js +1 -1
- package/src/WechatPrompt/index.js +2 -2
- package/src/withTheme/index.js +2 -2
- package/lib/Theme/responsiveFontSizes.js +0 -83
- package/src/Theme/responsiveFontSizes.js +0 -94
package/src/Tabs/index.js
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { styled } from '@mui/material/styles';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import MuiTab from '@material-ui/core/Tab';
|
|
4
|
+
import MuiTabs from '@mui/material/Tabs';
|
|
5
|
+
import MuiTab from '@mui/material/Tab';
|
|
6
6
|
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const PREFIX = 'index';
|
|
8
|
+
|
|
9
|
+
const classes = {
|
|
10
|
+
tabs: `${PREFIX}-tabs`,
|
|
11
|
+
tab: `${PREFIX}-tab`,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const StyledMuiTabs = styled(MuiTabs)(({ theme }) => ({
|
|
15
|
+
[`& .${classes.tabs}`]: {},
|
|
16
|
+
|
|
17
|
+
[`& .${classes.tab}`]: {
|
|
10
18
|
fontSize: '0.875rem',
|
|
11
19
|
[theme.breakpoints.up('md')]: {
|
|
12
20
|
fontSize: '1rem',
|
|
@@ -15,10 +23,8 @@ const useStyles = makeStyles(theme => ({
|
|
|
15
23
|
}));
|
|
16
24
|
|
|
17
25
|
export default function Tabs({ tabs, current, onChange, ...rest }) {
|
|
18
|
-
const classes = useStyles();
|
|
19
|
-
|
|
20
26
|
return (
|
|
21
|
-
<
|
|
27
|
+
<StyledMuiTabs
|
|
22
28
|
scrollButtons="on"
|
|
23
29
|
variant="scrollable"
|
|
24
30
|
value={current}
|
|
@@ -35,7 +41,7 @@ export default function Tabs({ tabs, current, onChange, ...rest }) {
|
|
|
35
41
|
icon={x.icon || null}
|
|
36
42
|
/>
|
|
37
43
|
))}
|
|
38
|
-
</
|
|
44
|
+
</StyledMuiTabs>
|
|
39
45
|
);
|
|
40
46
|
}
|
|
41
47
|
|
package/src/Tag/index.js
CHANGED
|
@@ -2,8 +2,8 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
|
|
5
|
-
import Typography from '@material
|
|
6
|
-
import useTheme from '@
|
|
5
|
+
import Typography from '@mui/material/Typography';
|
|
6
|
+
import useTheme from '@mui/styles/useTheme';
|
|
7
7
|
|
|
8
8
|
import { mergeProps } from '../Util';
|
|
9
9
|
import colors from '../Colors';
|
package/src/Theme/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// https://app.zeplin.io/styleguide/5d1436f1e97c2156f49c0725/colors
|
|
2
|
-
import { createTheme } from '@material
|
|
2
|
+
import { createTheme, responsiveFontSizes } from '@mui/material/styles';
|
|
3
3
|
import '@fontsource/lato/400.css';
|
|
4
4
|
import '@fontsource/lato/700.css';
|
|
5
|
-
import responsiveFontSizes from './responsiveFontSizes';
|
|
6
5
|
import colors from '../Colors';
|
|
7
6
|
|
|
7
|
+
const muiDarkTheme = createTheme({ palette: { mode: 'dark' } });
|
|
8
|
+
|
|
8
9
|
// https://material-ui.com/customization/default-theme/
|
|
9
10
|
// eslint-disable-next-line import/prefer-default-export
|
|
10
11
|
export const create = ({
|
|
@@ -15,19 +16,37 @@ export const create = ({
|
|
|
15
16
|
overrides,
|
|
16
17
|
...rest
|
|
17
18
|
} = {}) => {
|
|
19
|
+
// palette 考虑 light & dark mode, dark mode 需要持续完善
|
|
20
|
+
// - 能配合 ColorModeContext 使用
|
|
21
|
+
// - 为 dark mode 系统的设计整个 palette, 不要单个 color 设置
|
|
22
|
+
const _palette =
|
|
23
|
+
mode === 'light'
|
|
24
|
+
? Object.assign(
|
|
25
|
+
{
|
|
26
|
+
...colors,
|
|
27
|
+
background: {
|
|
28
|
+
paper: colors.common.white,
|
|
29
|
+
default: colors.background.default,
|
|
30
|
+
},
|
|
31
|
+
mode,
|
|
32
|
+
},
|
|
33
|
+
palette || {}
|
|
34
|
+
)
|
|
35
|
+
: Object.assign(
|
|
36
|
+
{
|
|
37
|
+
...muiDarkTheme.palette,
|
|
38
|
+
background: {
|
|
39
|
+
paper: colors.grey[900],
|
|
40
|
+
default: colors.grey[900],
|
|
41
|
+
},
|
|
42
|
+
mode,
|
|
43
|
+
},
|
|
44
|
+
palette || {}
|
|
45
|
+
);
|
|
46
|
+
|
|
18
47
|
const theme = createTheme({
|
|
19
48
|
themeName: 'ArcBlock',
|
|
20
|
-
palette:
|
|
21
|
-
{
|
|
22
|
-
...colors,
|
|
23
|
-
background: {
|
|
24
|
-
paper: mode === 'light' ? colors.common.white : colors.grey[900],
|
|
25
|
-
default: mode === 'light' ? colors.background.default : colors.grey[900],
|
|
26
|
-
},
|
|
27
|
-
type: mode,
|
|
28
|
-
},
|
|
29
|
-
palette || {}
|
|
30
|
-
),
|
|
49
|
+
palette: _palette,
|
|
31
50
|
typography: Object.assign(
|
|
32
51
|
{
|
|
33
52
|
useNextVariants: true,
|
|
@@ -65,29 +84,23 @@ export const create = ({
|
|
|
65
84
|
},
|
|
66
85
|
typography || {}
|
|
67
86
|
),
|
|
68
|
-
|
|
69
|
-
{
|
|
70
|
-
|
|
87
|
+
components: {
|
|
88
|
+
MuiButton: {
|
|
89
|
+
styleOverrides: {
|
|
71
90
|
root: {
|
|
72
91
|
boxShadow: 'none',
|
|
73
92
|
},
|
|
74
93
|
},
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
MuiAppBar: {
|
|
81
|
-
root: {
|
|
82
|
-
height: 80,
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
MuiToolbar: {
|
|
94
|
+
},
|
|
95
|
+
MuiButtonGroup: {
|
|
96
|
+
styleOverrides: {
|
|
86
97
|
root: {
|
|
87
|
-
|
|
98
|
+
boxShadow: 'none',
|
|
88
99
|
},
|
|
89
100
|
},
|
|
90
|
-
|
|
101
|
+
},
|
|
102
|
+
MuiTableCell: {
|
|
103
|
+
styleOverrides: {
|
|
91
104
|
root: {
|
|
92
105
|
borderBottomWidth: '0',
|
|
93
106
|
paddingTop: '14px',
|
|
@@ -103,35 +116,9 @@ export const create = ({
|
|
|
103
116
|
color: mode === 'light' ? colors.grey[900] : colors.grey[300],
|
|
104
117
|
},
|
|
105
118
|
},
|
|
106
|
-
MuiChip: {
|
|
107
|
-
root: {
|
|
108
|
-
padding: '3px',
|
|
109
|
-
height: '24px',
|
|
110
|
-
fontSize: '12px',
|
|
111
|
-
marginRight: '10px',
|
|
112
|
-
},
|
|
113
|
-
label: {
|
|
114
|
-
paddingLeft: '5px',
|
|
115
|
-
paddingRight: '5px',
|
|
116
|
-
marginRight: '5px',
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
MuiTooltip: {
|
|
120
|
-
tooltip: {
|
|
121
|
-
fontSize: '14px',
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
MuiTypography: {
|
|
125
|
-
body1: {
|
|
126
|
-
color: mode === 'light' ? colors.grey[900] : colors.grey[300],
|
|
127
|
-
},
|
|
128
|
-
body2: {
|
|
129
|
-
color: mode === 'light' ? colors.grey[900] : colors.grey[300],
|
|
130
|
-
},
|
|
131
|
-
},
|
|
132
119
|
},
|
|
133
|
-
overrides
|
|
134
|
-
|
|
120
|
+
...overrides,
|
|
121
|
+
},
|
|
135
122
|
pageWidth,
|
|
136
123
|
// TODO: 过时的 colors, 需要各项目负责人检查项目中是否使用 "theme.colors", 如果有需要清除,
|
|
137
124
|
// 可以从 Colors 模块/theme.palette/mui colors 中取值
|
package/src/Toast/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
|
|
4
|
-
import CheckCircleIcon from '@
|
|
5
|
-
import ErrorIcon from '@
|
|
6
|
-
import InfoIcon from '@
|
|
7
|
-
import CloseIcon from '@
|
|
8
|
-
import WarningIcon from '@
|
|
9
|
-
import IconButton from '@material
|
|
10
|
-
import Snackbar from '@material
|
|
11
|
-
import SnackbarContent from '@material
|
|
12
|
-
import { amber, green } from '@material
|
|
13
|
-
import { makeStyles } from '@
|
|
4
|
+
import CheckCircleIcon from '@mui/icons-material/CheckCircle';
|
|
5
|
+
import ErrorIcon from '@mui/icons-material/Error';
|
|
6
|
+
import InfoIcon from '@mui/icons-material/Info';
|
|
7
|
+
import CloseIcon from '@mui/icons-material/Close';
|
|
8
|
+
import WarningIcon from '@mui/icons-material/Warning';
|
|
9
|
+
import IconButton from '@mui/material/IconButton';
|
|
10
|
+
import Snackbar from '@mui/material/Snackbar';
|
|
11
|
+
import SnackbarContent from '@mui/material/SnackbarContent';
|
|
12
|
+
import { amber, green } from '@mui/material/colors';
|
|
13
|
+
import { makeStyles } from '@mui/styles';
|
|
14
14
|
|
|
15
15
|
const variantIcon = {
|
|
16
16
|
success: CheckCircleIcon,
|
|
@@ -60,7 +60,7 @@ function SnackbarContentWrapper(props) {
|
|
|
60
60
|
</span>
|
|
61
61
|
}
|
|
62
62
|
action={[
|
|
63
|
-
<IconButton key="close" aria-label="close" color="inherit" onClick={onClose}>
|
|
63
|
+
<IconButton key="close" aria-label="close" color="inherit" onClick={onClose} size="large">
|
|
64
64
|
<CloseIcon className={classes.icon} />
|
|
65
65
|
</IconButton>,
|
|
66
66
|
]}
|
package/src/Video/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import Player from 'react-player';
|
|
4
4
|
import styled from 'styled-components';
|
|
5
5
|
|
|
6
|
-
import CircularProgress from '@material
|
|
6
|
+
import CircularProgress from '@mui/material/CircularProgress';
|
|
7
7
|
|
|
8
8
|
import { mergeProps } from '../Util';
|
|
9
9
|
|
package/src/Wallet/Action.js
CHANGED
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
|
|
5
|
-
import Typography from '@material
|
|
5
|
+
import Typography from '@mui/material/Typography';
|
|
6
6
|
|
|
7
7
|
import logo from './images/abtwallet.png';
|
|
8
8
|
import { mergeProps } from '../Util';
|
package/src/Wallet/Download.js
CHANGED
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
|
|
5
|
-
import Typography from '@material
|
|
5
|
+
import Typography from '@mui/material/Typography';
|
|
6
6
|
import useBrowser from '@arcblock/react-hooks/lib/useBrowser';
|
|
7
7
|
|
|
8
8
|
import { ReactComponent as AppStoreIcon } from './images/app-store.svg';
|
package/src/Wallet/Open.js
CHANGED
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import useBrowser from '@arcblock/react-hooks/lib/useBrowser';
|
|
5
|
-
import Fab from '@material
|
|
5
|
+
import Fab from '@mui/material/Fab';
|
|
6
6
|
|
|
7
7
|
export default function OpenInWallet({ locale, link }) {
|
|
8
8
|
const buttonText = locale === 'zh' ? '在 ABT 钱包打开' : 'Open in DID Wallet';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
|
|
4
|
-
import Typography from '@material
|
|
5
|
-
import Dialog from '@material
|
|
4
|
+
import Typography from '@mui/material/Typography';
|
|
5
|
+
import Dialog from '@mui/material/Dialog';
|
|
6
6
|
import useBrowser from '@arcblock/react-hooks/lib/useBrowser';
|
|
7
7
|
|
|
8
8
|
import IosImage from './images/ios.png';
|
package/src/withTheme/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ThemeProvider, createGlobalStyle } from 'styled-components';
|
|
3
|
-
import { MuiThemeProvider } from '@material
|
|
4
|
-
import CssBaseline from '@material
|
|
3
|
+
import { ThemeProvider as MuiThemeProvider } from '@mui/material/styles';
|
|
4
|
+
import CssBaseline from '@mui/material/CssBaseline';
|
|
5
5
|
|
|
6
6
|
import { create } from '../Theme';
|
|
7
7
|
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = responsiveFontSizes;
|
|
7
|
-
|
|
8
|
-
var _cssUtils = require("@material-ui/core/styles/cssUtils");
|
|
9
|
-
|
|
10
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
11
|
-
|
|
12
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
13
|
-
|
|
14
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
-
|
|
16
|
-
function responsiveFontSizes(themeInput) {
|
|
17
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
18
|
-
const {
|
|
19
|
-
breakpoints = ['sm', 'md', 'lg'],
|
|
20
|
-
disableAlign = false,
|
|
21
|
-
factor = 3,
|
|
22
|
-
maxSize = 2.5,
|
|
23
|
-
// minSize = 0.8,
|
|
24
|
-
variants = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'subtitle1', 'subtitle2', 'body1', 'body2', 'caption', 'button', 'overline']
|
|
25
|
-
} = options;
|
|
26
|
-
|
|
27
|
-
const theme = _objectSpread({}, themeInput);
|
|
28
|
-
|
|
29
|
-
theme.typography = _objectSpread({}, theme.typography);
|
|
30
|
-
const {
|
|
31
|
-
typography
|
|
32
|
-
} = theme; // Convert between css lengths e.g. em->px or px->rem
|
|
33
|
-
// Set the baseFontSize for your project. Defaults to 16px (also the browser default).
|
|
34
|
-
|
|
35
|
-
const convert = (0, _cssUtils.convertLength)(typography.htmlFontSize);
|
|
36
|
-
const breakpointValues = breakpoints.map(x => theme.breakpoints.values[x]);
|
|
37
|
-
variants.forEach(variant => {
|
|
38
|
-
const style = typography[variant];
|
|
39
|
-
const remFontSize = parseFloat(convert(style.fontSize, 'rem'));
|
|
40
|
-
|
|
41
|
-
if (remFontSize <= 1) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const maxFontSize = Math.min(remFontSize, maxSize);
|
|
46
|
-
const minFontSize = 1 + (maxFontSize - 1) / factor;
|
|
47
|
-
let {
|
|
48
|
-
lineHeight
|
|
49
|
-
} = style;
|
|
50
|
-
|
|
51
|
-
if (!(0, _cssUtils.isUnitless)(lineHeight) && !disableAlign) {
|
|
52
|
-
throw new Error(['Material-UI: unsupported non-unitless line height with grid alignment.', 'Use unitless line heights instead.'].join('\n'));
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (!(0, _cssUtils.isUnitless)(lineHeight)) {
|
|
56
|
-
// make it unitless
|
|
57
|
-
lineHeight = parseFloat(convert(lineHeight, 'rem')) / parseFloat(remFontSize);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
let transform = null;
|
|
61
|
-
|
|
62
|
-
if (!disableAlign) {
|
|
63
|
-
transform = value => (0, _cssUtils.alignProperty)({
|
|
64
|
-
size: value,
|
|
65
|
-
grid: (0, _cssUtils.fontGrid)({
|
|
66
|
-
pixels: 4,
|
|
67
|
-
lineHeight,
|
|
68
|
-
htmlFontSize: typography.htmlFontSize
|
|
69
|
-
})
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
typography[variant] = _objectSpread(_objectSpread({}, style), (0, _cssUtils.responsiveProperty)({
|
|
74
|
-
cssProperty: 'fontSize',
|
|
75
|
-
min: minFontSize,
|
|
76
|
-
max: maxFontSize,
|
|
77
|
-
unit: 'rem',
|
|
78
|
-
breakpoints: breakpointValues,
|
|
79
|
-
transform
|
|
80
|
-
}));
|
|
81
|
-
});
|
|
82
|
-
return theme;
|
|
83
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
// https://github.com/mui-org/material-ui/blob/f2d74e9144ffec1ba6a098528573c7dfb3957b48/packages/material-ui/src/styles/responsiveFontSizes.js
|
|
2
|
-
import {
|
|
3
|
-
isUnitless,
|
|
4
|
-
convertLength,
|
|
5
|
-
responsiveProperty,
|
|
6
|
-
alignProperty,
|
|
7
|
-
fontGrid,
|
|
8
|
-
} from '@material-ui/core/styles/cssUtils';
|
|
9
|
-
|
|
10
|
-
export default function responsiveFontSizes(themeInput, options = {}) {
|
|
11
|
-
const {
|
|
12
|
-
breakpoints = ['sm', 'md', 'lg'],
|
|
13
|
-
disableAlign = false,
|
|
14
|
-
factor = 3,
|
|
15
|
-
maxSize = 2.5,
|
|
16
|
-
// minSize = 0.8,
|
|
17
|
-
variants = [
|
|
18
|
-
'h1',
|
|
19
|
-
'h2',
|
|
20
|
-
'h3',
|
|
21
|
-
'h4',
|
|
22
|
-
'h5',
|
|
23
|
-
'h6',
|
|
24
|
-
'subtitle1',
|
|
25
|
-
'subtitle2',
|
|
26
|
-
'body1',
|
|
27
|
-
'body2',
|
|
28
|
-
'caption',
|
|
29
|
-
'button',
|
|
30
|
-
'overline',
|
|
31
|
-
],
|
|
32
|
-
} = options;
|
|
33
|
-
|
|
34
|
-
const theme = { ...themeInput };
|
|
35
|
-
theme.typography = { ...theme.typography };
|
|
36
|
-
const { typography } = theme;
|
|
37
|
-
|
|
38
|
-
// Convert between css lengths e.g. em->px or px->rem
|
|
39
|
-
// Set the baseFontSize for your project. Defaults to 16px (also the browser default).
|
|
40
|
-
const convert = convertLength(typography.htmlFontSize);
|
|
41
|
-
const breakpointValues = breakpoints.map(x => theme.breakpoints.values[x]);
|
|
42
|
-
|
|
43
|
-
variants.forEach(variant => {
|
|
44
|
-
const style = typography[variant];
|
|
45
|
-
const remFontSize = parseFloat(convert(style.fontSize, 'rem'));
|
|
46
|
-
|
|
47
|
-
if (remFontSize <= 1) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const maxFontSize = Math.min(remFontSize, maxSize);
|
|
52
|
-
const minFontSize = 1 + (maxFontSize - 1) / factor;
|
|
53
|
-
|
|
54
|
-
let { lineHeight } = style;
|
|
55
|
-
|
|
56
|
-
if (!isUnitless(lineHeight) && !disableAlign) {
|
|
57
|
-
throw new Error(
|
|
58
|
-
[
|
|
59
|
-
'Material-UI: unsupported non-unitless line height with grid alignment.',
|
|
60
|
-
'Use unitless line heights instead.',
|
|
61
|
-
].join('\n')
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (!isUnitless(lineHeight)) {
|
|
66
|
-
// make it unitless
|
|
67
|
-
lineHeight = parseFloat(convert(lineHeight, 'rem')) / parseFloat(remFontSize);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
let transform = null;
|
|
71
|
-
|
|
72
|
-
if (!disableAlign) {
|
|
73
|
-
transform = value =>
|
|
74
|
-
alignProperty({
|
|
75
|
-
size: value,
|
|
76
|
-
grid: fontGrid({ pixels: 4, lineHeight, htmlFontSize: typography.htmlFontSize }),
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
typography[variant] = {
|
|
81
|
-
...style,
|
|
82
|
-
...responsiveProperty({
|
|
83
|
-
cssProperty: 'fontSize',
|
|
84
|
-
min: minFontSize,
|
|
85
|
-
max: maxFontSize,
|
|
86
|
-
unit: 'rem',
|
|
87
|
-
breakpoints: breakpointValues,
|
|
88
|
-
transform,
|
|
89
|
-
}),
|
|
90
|
-
};
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
return theme;
|
|
94
|
-
}
|