1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2025-02-25 15:58:56 +01:00

50 lines
1.1 KiB
React
Raw Normal View History

import '@material/mwc-circular-progress';
import {type Button} from '@material/mwc-button';
import type CSS from 'csstype';
import {type ClassComponent} from 'mithril';
import Component from './Component.jsx';
import Mdi from './Mdi.jsx';
export default class LoadingButton extends Component implements ClassComponent<Button> {
view(vnode) {
return (
<>
<mwc-button {...this.attrs.all()}>
<span slot="icon" style="display: inline;">
<mwc-circular-progress
indeterminate
style={this.getCSSProperties()}/>
{this.attrs.has('icon') ? <Mdi icon={this.attrs.get('icon')}/> : ''}
</span>
</mwc-button>
</>
);
}
getCSSProperties() {
const css: CSS.Properties<> = {
display: 'none',
verticalAlign: 'bottom'
};
if (this.attrs.has('raised')) {
css['--mdc-theme-primary'] = '#ffffff';
}
if (this.attrs.has('icon')) {
css.marginRight = '8px';
}
return css;
}
oncreate(vnode) {
super.oncreate(vnode);
$(this.element)
.find('mwc-circular-progress')
.attr('density', -7);
}
}