diff --git a/scss/components/_spinner.scss b/scss/components/_spinner.scss index 7c098c6f..7eb52a80 100644 --- a/scss/components/_spinner.scss +++ b/scss/components/_spinner.scss @@ -58,6 +58,13 @@ } transition: ease-out all 0.3s; + + &--icon { + background: transparent; + animation: spin 2s linear infinite; + width: auto; + height: auto; + } } // 当启用 overlay 的时候,应该是居中模式。 diff --git a/scss/components/_status.scss b/scss/components/_status.scss index 5816a6a0..a6ed929e 100644 --- a/scss/components/_status.scss +++ b/scss/components/_status.scss @@ -34,6 +34,11 @@ } } + svg.#{$ns}Status-icon { + width: 16px; + height: 16px; + } + .#{$ns}Status-icon { &--danger, &--primary, diff --git a/scss/components/_table.scss b/scss/components/_table.scss index 1c64679e..d67cc8e3 100644 --- a/scss/components/_table.scss +++ b/scss/components/_table.scss @@ -741,4 +741,9 @@ > .#{$ns}Button--disabled-wrap > .#{$ns}Button { margin: px2rem(3px); } + + > .#{$ns}Button--link { + padding: 0; + margin-right: px2rem(10px); + } } diff --git a/src/components/Select.tsx b/src/components/Select.tsx index 898b1bd0..4b8ad104 100644 --- a/src/components/Select.tsx +++ b/src/components/Select.tsx @@ -24,6 +24,7 @@ import Checkbox from './Checkbox'; import Input from './Input'; import {Api} from '../types'; import {LocaleProps, localeable} from '../locale'; +import Spinner from './Spinner'; export interface Option { label?: string; @@ -330,7 +331,6 @@ export class Select extends React.Component { placeholder: '请选择', valueField: 'value', labelField: 'label', - spinnerClassName: 'fa fa-spinner fa-spin fa-1x fa-fw', inline: false, disabled: false, checkAll: false, @@ -871,7 +871,6 @@ export class Select extends React.Component { className, value, loading, - spinnerClassName, clearable, labelField, disabled, @@ -927,9 +926,11 @@ export class Select extends React.Component { ) : null} {loading ? ( - - - + ) : null} diff --git a/src/components/Spinner.tsx b/src/components/Spinner.tsx index 52445208..f774720f 100644 --- a/src/components/Spinner.tsx +++ b/src/components/Spinner.tsx @@ -6,8 +6,9 @@ */ import React from 'react'; -import {ClassNamesFn, themeable} from '../theme'; +import {themeable, ThemeProps} from '../theme'; import Transition, {ENTERED, ENTERING} from 'react-transition-group/Transition'; +import {Icon} from './icons'; const fadeStyles: { [propName: string]: string; @@ -16,25 +17,21 @@ const fadeStyles: { [ENTERED]: 'in' }; -interface SpinnerProps { +interface SpinnerProps extends ThemeProps { overlay: boolean; spinnerClassName: string; mode: string; size: 'sm' | 'lg' | ''; - classPrefix: string; - classnames: ClassNamesFn; show: boolean; + icon?: string; } export class Spinner extends React.Component { - static defaultProps: Pick< - SpinnerProps, - 'overlay' | 'spinnerClassName' | 'size' | 'mode' | 'show' - > = { + static defaultProps = { overlay: false, spinnerClassName: '', mode: '', - size: '', + size: '' as '', show: true }; @@ -48,7 +45,8 @@ export class Spinner extends React.Component { spinnerClassName, mode, size, - overlay + overlay, + icon } = this.props; return ( @@ -75,9 +73,12 @@ export class Spinner extends React.Component { className={cx(`Spinner`, spinnerClassName, fadeStyles[status], { [`Spinner--${mode}`]: mode, [`Spinner--overlay`]: overlay, - [`Spinner--${size}`]: size + [`Spinner--${size}`]: size, + [`Spinner--icon`]: icon })} - /> + > + {icon ? : null} + ); }} diff --git a/src/components/icons.tsx b/src/components/icons.tsx index 6b837ac0..57d67b89 100644 --- a/src/components/icons.tsx +++ b/src/components/icons.tsx @@ -143,6 +143,7 @@ registerIcon('prev', LeftArrowIcon); registerIcon('next', RightArrowIcon); registerIcon('check', CheckIcon); registerIcon('plus', PlusIcon); +registerIcon('add', PlusIcon); registerIcon('minus', MinusIcon); registerIcon('pencil', PencilIcon); registerIcon('view', ViewIcon); diff --git a/src/icons/pencil.svg b/src/icons/pencil.svg index 93052f73..09e550c1 100644 --- a/src/icons/pencil.svg +++ b/src/icons/pencil.svg @@ -1,4 +1,6 @@ - - - \ No newline at end of file + + + + + + diff --git a/src/renderers/Chart.tsx b/src/renderers/Chart.tsx index 461f239f..a0df53d7 100644 --- a/src/renderers/Chart.tsx +++ b/src/renderers/Chart.tsx @@ -11,6 +11,7 @@ import {resolveVariableAndFilter, isPureVariable} from '../utils/tpl-builtin'; import {isApiOutdated, isEffectiveApi} from '../utils/api'; import {ScopedContext, IScopedContext} from '../Scoped'; import {createObject} from '../utils/helper'; +import Spinner from '../components/Spinner'; export interface ChartProps extends RendererProps { chartRef?: (echart: any) => void; @@ -238,7 +239,11 @@ export class Chart extends React.Component { placeholder={
- +
} diff --git a/src/renderers/Form/Table.tsx b/src/renderers/Form/Table.tsx index c78a18c9..1caf49aa 100644 --- a/src/renderers/Form/Table.tsx +++ b/src/renderers/Form/Table.tsx @@ -11,6 +11,7 @@ import {dataMapping} from '../../utils/tpl-builtin'; import findIndex from 'lodash/findIndex'; import memoize from 'lodash/memoize'; import {SimpleMap} from '../../utils/SimpleMap'; +import {Icon} from '../../components/icons'; export interface TableProps extends FormControlProps { placeholder?: string; @@ -48,11 +49,11 @@ export default class FormTable extends React.Component { static defaultProps = { placeholder: '空', scaffold: {}, - addBtnIcon: 'fa fa-plus', - updateBtnIcon: 'fa fa-pencil', - deleteBtnIcon: 'fa fa-minus', - confirmBtnIcon: 'fa fa-check', - cancelBtnIcon: 'fa fa-times', + addBtnIcon: 'plus', + updateBtnIcon: 'pencil', + deleteBtnIcon: 'minus', + confirmBtnIcon: 'check', + cancelBtnIcon: 'close', valueField: '' }; @@ -376,7 +377,9 @@ export default class FormTable extends React.Component { onClick={this.addItem.bind(this, rowIndex, undefined)} > {props.addBtnLabel ? {props.addBtnLabel} : null} - {props.addBtnIcon ? : null} + {props.addBtnIcon ? ( + + ) : null} ) }); @@ -428,7 +431,7 @@ export default class FormTable extends React.Component { {props.updateBtnLabel} ) : null} {props.updateBtnIcon ? ( - + ) : null} ) @@ -452,7 +455,7 @@ export default class FormTable extends React.Component { {props.confirmBtnLabel} ) : null} {props.confirmBtnIcon ? ( - + ) : null} ) : null @@ -476,7 +479,7 @@ export default class FormTable extends React.Component { {props.cancelBtnLabel} ) : null} {props.cancelBtnIcon ? ( - + ) : null} ) : null @@ -510,7 +513,7 @@ export default class FormTable extends React.Component { {props.deleteBtnLabel} ) : null} {props.deleteBtnIcon ? ( - + ) : null} ) diff --git a/src/renderers/Form/Text.tsx b/src/renderers/Form/Text.tsx index 4ecff8aa..c94d63ef 100644 --- a/src/renderers/Form/Text.tsx +++ b/src/renderers/Form/Text.tsx @@ -12,6 +12,7 @@ import {Icon} from '../../components/icons'; import Input from '../../components/Input'; import {autobind, createObject, setVariable} from '../../utils/helper'; import {isEffectiveApi} from '../../utils/api'; +import Spinner from '../../components/Spinner'; // declare function matchSorter(items:Array, input:any, options:any): Array; @@ -74,8 +75,7 @@ export default class TextControl extends React.PureComponent< labelField: 'label', valueField: 'value', placeholder: '', - allowInputText: true, - spinnerClassName: 'fa fa-spinner fa-spin fa-1x fa-fw' + allowInputText: true }; componentWillReceiveProps(nextProps: TextProps) { @@ -415,7 +415,6 @@ export default class TextControl extends React.PureComponent< labelField, valueField, multiple, - spinnerClassName, translate: __ } = this.props; @@ -523,7 +522,11 @@ export default class TextControl extends React.PureComponent< ) : null} {loading ? ( - + ) : null} {isOpen && filtedOptions.length ? (
diff --git a/src/renderers/Form/TreeSelect.tsx b/src/renderers/Form/TreeSelect.tsx index 46b6edc0..bbc2e65a 100644 --- a/src/renderers/Form/TreeSelect.tsx +++ b/src/renderers/Form/TreeSelect.tsx @@ -12,6 +12,7 @@ import debouce from 'lodash/debounce'; import find from 'lodash/find'; import {Api} from '../../types'; import {isEffectiveApi} from '../../utils/api'; +import Spinner from '../../components/Spinner'; export interface TreeSelectProps extends OptionsControlProps { placeholder?: any; @@ -39,8 +40,7 @@ export default class TreeSelectControl extends React.Component< joinValues: true, extractValue: false, delimiter: ',', - resetValue: '', - spinnerClassName: 'fa fa-spinner fa-spin fa-1x fa-fw' + resetValue: '' }; container: React.RefObject; @@ -456,7 +456,6 @@ export default class TreeSelectControl extends React.Component< const { className, disabled, - spinnerClassName, inline, loading, multiple, @@ -521,9 +520,11 @@ export default class TreeSelectControl extends React.Component< ) : null} {loading ? ( - - - + ) : null}
diff --git a/src/renderers/Status.tsx b/src/renderers/Status.tsx index 4fe7aa01..0ba6f560 100644 --- a/src/renderers/Status.tsx +++ b/src/renderers/Status.tsx @@ -4,6 +4,7 @@ import {ServiceStore, IServiceStore} from '../store/service'; import {Api, SchemaNode, PlainObject} from '../types'; import {filter} from '../utils/tpl'; import cx from 'classnames'; +import {Icon} from '../components/icons'; export interface StatusProps extends RendererProps { className?: string; @@ -15,8 +16,8 @@ export class StatusField extends React.Component { static defaultProps: Partial = { placeholder: '-', map: { - 0: 'fa fa-times text-danger', - 1: 'fa fa-check text-success' + 0: 'svg-success', + 1: 'svg-fail' }, labelMap: { // 0: '失败', @@ -47,10 +48,25 @@ export class StatusField extends React.Component { } wrapClassName = `StatusField--${value}`; - viewValue = ( - + let itemClassName = map[value]; + let svgIcon: string = ''; + + itemClassName = itemClassName.replace( + /\bsvg-(.*)\b/, + (_: string, icon: string) => { + svgIcon = icon; + return 'icon'; + } ); + if (svgIcon) { + viewValue = ( + + ); + } else { + viewValue = ; + } + if (labelMap && labelMap[value]) { viewValue = [ viewValue, diff --git a/src/renderers/Tasks.tsx b/src/renderers/Tasks.tsx index f8de39d2..7924d354 100644 --- a/src/renderers/Tasks.tsx +++ b/src/renderers/Tasks.tsx @@ -7,6 +7,7 @@ import {Api, ApiObject, Payload} from '../types'; import update from 'react-addons-update'; import {isEffectiveApi, isApiOutdated} from '../utils/api'; import {ScopedContext, IScopedContext} from '../Scoped'; +import Spinner from '../components/Spinner'; export interface TaskProps extends RendererProps { className?: string; @@ -297,7 +298,11 @@ export default class Task extends React.Component { {item.label} {item.status == loadingStatusCode ? ( - + ) : item.status == canRetryStatusCode ? ( this.submitTask(item, key, true)}