@craftercms/studio-ui
Version:
Services, components, models & utils to build CrafterCMS authoring extensions.
71 lines (69 loc) • 2.42 kB
JavaScript
/*
* Copyright (C) 2007-2022 Crafter Software Corporation. All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3 as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Copyright (C) 2007-2022 Crafter Software Corporation. All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React from 'react';
import { makeStyles } from 'tss-react/mui';
import palette from '../../styles/palette';
const progressBarStyles = makeStyles()(() => ({
progressBar: {
position: 'absolute',
bottom: 0,
left: 0,
width: '100%',
height: '3px',
transition: 'height .2s'
},
progressBarInner: {
backgroundColor: palette.blue.tint,
height: '100%',
width: 0,
transition: 'width 0.4s ease',
'&.complete': {
transition: 'background-color 0.5s ease',
backgroundColor: palette.green.main
},
'&.failed': {
backgroundColor: palette.red.main
}
}
}));
export function ProgressBar(props) {
const { status, progress } = props;
const { classes, cx } = progressBarStyles();
return React.createElement(
'div',
{ className: classes.progressBar },
React.createElement('div', {
className: cx(classes.progressBarInner, status === 'failed' && 'failed', progress === 100 && 'complete'),
style: { width: `${progress}%` }
})
);
}
export default ProgressBar;