@@ -2,6 +2,9 @@ import React from 'react'
22import tinycolor from 'tinycolor2'
33import Icon from '@conveyal/woonerf/components/icon'
44
5+ import ConfirmModal from '../../common/components/ConfirmModal'
6+ import { LabelEditorModal } from '../../manager/components/LabelEditor'
7+
58const getComplementaryColor = ( cssHex , strength ) => {
69 const color = tinycolor ( cssHex )
710
@@ -11,20 +14,51 @@ const getComplementaryColor = (cssHex, strength) => {
1114 return complementary . toHexString ( )
1215}
1316
14- export default function Label ( props ) {
15- const { name, color, small, adminOnly } = props
16-
17- return (
18- < span
19- className = { `feedLabel ${ small ? 'small' : '' } ` }
20- style = { {
21- backgroundColor : color ,
22- color : getComplementaryColor ( color , 45 ) ,
23- borderColor : getComplementaryColor ( color , 10 )
24- } }
25- >
26- { adminOnly ? < Icon type = 'lock' /> : '' }
27- { name }
28- </ span >
29- )
17+ export default class FeedLabel extends React . Component {
18+ _onConfirmDelete = ( ) => {
19+ this . props . deleteLabel ( this . props )
20+ }
21+
22+ _onClickDelete = ( ) => {
23+ this . refs . deleteModal . open ( )
24+ }
25+
26+ _onClickEdit = ( ) => {
27+ this . refs . editModal . open ( )
28+ }
29+
30+ render ( ) {
31+ const { name, color, small, adminOnly } = this . props
32+
33+ return (
34+ < div
35+ className = { `feedLabel ${ small ? 'small' : '' } ` }
36+ style = { {
37+ backgroundColor : color ,
38+ color : getComplementaryColor ( color , 40 ) ,
39+ borderColor : getComplementaryColor ( color , 10 )
40+ } }
41+ >
42+
43+ < div className = 'labelName' >
44+ { adminOnly ? < Icon type = 'lock' /> : '' }
45+ < span > { name } </ span >
46+ </ div >
47+ { small ? ''
48+ : < div className = 'actionButtons small' >
49+ < ConfirmModal
50+ ref = 'deleteModal'
51+ title = 'Delete Label?'
52+ body = { `Are you sure you want to delete the label ${ name } ?` }
53+ onConfirm = { this . _onConfirmDelete }
54+ />
55+ < LabelEditorModal ref = 'editModal' label = { { ...this . props } } />
56+
57+ < button onClick = { ( ) => this . _onClickEdit ( ) } > Edit</ button >
58+ < button onClick = { ( ) => this . _onClickDelete ( ) } > Delete</ button >
59+ </ div >
60+ }
61+ </ div >
62+ )
63+ }
3064}
0 commit comments