Skip to content

Commit ddce275

Browse files
committed
Fix #337: Use glyphicons for buttons by default.
1 parent 84434be commit ddce275

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

src/components/fields/ArrayField.js

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ function ArrayFieldDescription({DescriptionField, idSchema, description}) {
3535
return <DescriptionField id={id} description={description}/>;
3636
}
3737

38+
function IconBtn(props) {
39+
const {type="default", icon, className, ...otherProps} = props;
40+
return (
41+
<button type="button" className={`btn btn-${type} ${className}`} {...otherProps}>
42+
<i className={`glyphicon glyphicon-${icon}`}/>
43+
</button>
44+
);
45+
}
46+
3847
class ArrayField extends Component {
3948
static defaultProps = {
4049
uiSchema: {},
@@ -349,7 +358,7 @@ class ArrayField extends Component {
349358

350359
return (
351360
<div key={index} className="array-item">
352-
<div className={hasToolbar ? "col-xs-10" : "col-xs-12"}>
361+
<div className={hasToolbar ? "col-xs-9" : "col-xs-12"}>
353362
<SchemaField
354363
schema={itemSchema}
355364
uiSchema={itemUiSchema}
@@ -365,28 +374,28 @@ class ArrayField extends Component {
365374
</div>
366375
{
367376
hasToolbar ?
368-
<div className="col-xs-2 array-item-toolbox text-right">
369-
<div className="btn-group" style={{display: "flex"}}>
377+
<div className="col-xs-3 array-item-toolbox">
378+
<div className="btn-group" style={{display: "flex", justifyContent: "space-around"}}>
370379
{_canMoveUp || _canMoveDown ?
371-
<button type="button" className="btn btn-default array-item-move-up"
372-
style={btnStyle}
380+
<IconBtn icon="arrow-up" className="array-item-move-up"
373381
tabIndex="-1"
382+
style={btnStyle}
374383
disabled={disabled || readonly || !_canMoveUp}
375-
onClick={this.onReorderClick(index, index - 1)}></button>
384+
onClick={this.onReorderClick(index, index - 1)}/>
376385
: null}
377386
{_canMoveUp || _canMoveDown ?
378-
<button type="button" className="btn btn-default array-item-move-down"
379-
style={btnStyle}
387+
<IconBtn icon="arrow-down" className="array-item-move-down"
380388
tabIndex="-1"
389+
style={btnStyle}
381390
disabled={disabled || readonly || !_canMoveDown}
382-
onClick={this.onReorderClick(index, index + 1)}></button>
391+
onClick={this.onReorderClick(index, index + 1)}/>
383392
: null}
384393
{removable ?
385-
<button type="button" className="btn btn-danger array-item-remove"
386-
style={btnStyle}
394+
<IconBtn type="danger" icon="remove" className="array-item-remove"
387395
tabIndex="-1"
396+
style={btnStyle}
388397
disabled={disabled || readonly}
389-
onClick={this.onDropIndexClick(index)}></button>
398+
onClick={this.onDropIndexClick(index)}/>
390399
: null}
391400
</div>
392401
</div>
@@ -400,10 +409,10 @@ class ArrayField extends Component {
400409
function AddButton({onClick, disabled}) {
401410
return (
402411
<div className="row">
403-
<p className="col-xs-2 col-xs-offset-10 array-item-add text-right">
404-
<button type="button" className="btn btn-info col-xs-12"
405-
tabIndex="-1" onClick={onClick}
406-
disabled={disabled} style={{fontWeight: "bold"}}></button>
412+
<p className="col-xs-3 col-xs-offset-9 array-item-add text-right">
413+
<IconBtn type="info" icon="plus" className="btn-add col-xs-12"
414+
tabIndex="-1" onClick={onClick}
415+
disabled={disabled}/>
407416
</p>
408417
</div>
409418
);

0 commit comments

Comments
 (0)