-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bouton.tsx
72 lines (57 loc) · 1.63 KB
/
Bouton.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import * as React from 'react';
import * as classNames from 'classnames';
export interface BoutonProps {
value: string,
add?: boolean,
delete?: boolean,
primary?: boolean,
className?: string,
submit?: boolean,
disabled?: boolean,
load?: boolean,
ok?: boolean,
onClick: (e: React.MouseEvent, b: Bouton) => void
}
interface BoutonState {
disabled?: boolean,
load?: boolean
}
export class Bouton extends React.Component<BoutonProps, BoutonState> {
public constructor(props: BoutonProps, context?: BoutonState) {
super(props, context);
this.state = {disabled: this.props.disabled, load: this.props.load};
}
public render() {
return <button className={classNames('but', {
'primary': this.props.primary,
'add': this.props.add,
'delete error': this.props.delete,
'load': this.props.load,
'disabled': this.state.disabled || this.props.disabled
}, this.props.className)
} type={this.props.submit ? 'submit' : 'button'} onClick={e =>
this.props.onClick(e, this)
} disabled={this.state.disabled || this.props.disabled}>
{this.props.value}
{this.props.ok ? <span className='glyphicon glyphicon-ok'></span> : ''}
</button>
}
}
export interface BoutonAddProps {
primary?: boolean;
className?: string;
submit?: boolean;
disabled?: boolean;
load?: boolean;
onClick: (e: React.SyntheticEvent) => void;
}
export class BoutonAdd extends React.Component<BoutonAddProps, BoutonState> {
public render() {
return <Bouton value='' add {...this.props} />
}
}
export class BoutonDelete extends React.Component<BoutonAddProps, BoutonState> {
public render() {
return <Bouton value='' delete {...this.props} />
}
}