Browse Source

refactored with proper color management

Skylsmoi 6 years ago
parent
commit
1331c99220

+ 1 - 0
package.json View File

29
     "file-loader": "^1.1.5",
29
     "file-loader": "^1.1.5",
30
     "i18next": "^10.5.0",
30
     "i18next": "^10.5.0",
31
     "prop-types": "^15.6.0",
31
     "prop-types": "^15.6.0",
32
+    "radium": "^0.24.1",
32
     "react": "^16.0.0",
33
     "react": "^16.0.0",
33
     "react-dom": "^16.0.0",
34
     "react-dom": "^16.0.0",
34
     "react-i18next": "^7.5.0",
35
     "react-i18next": "^7.5.0",

+ 26 - 4
src/component/Input/TextAreaApp/TextAreaApp.jsx View File

1
 import React from 'react'
1
 import React from 'react'
2
 import PropTypes from 'prop-types'
2
 import PropTypes from 'prop-types'
3
+import Radium from 'radium'
3
 
4
 
4
 require('./TextAreaApp.styl')
5
 require('./TextAreaApp.styl')
5
 
6
 
15
     <div className={`${props.customClass}__button editionmode__button`}>
16
     <div className={`${props.customClass}__button editionmode__button`}>
16
       <button
17
       <button
17
         type='button'
18
         type='button'
18
-        className={`${props.customClass}__cancel editionmode__button__cancel btn btn-outline-primary mr-3`}
19
+        className={`${props.customClass}__cancel editionmode__button__cancel btn mr-3`}
19
         onClick={props.onClickCancelBtn}
20
         onClick={props.onClickCancelBtn}
21
+        style={{
22
+          backgroundColor: '#fdfdfd',
23
+          color: props.customColor,
24
+          borderColor: props.customColor,
25
+          ':hover': {
26
+            backgroundColor: props.customColor,
27
+            color: '#fdfdfd'
28
+          }
29
+        }}
30
+        key='TextAreaApp__cancel'
20
       >
31
       >
21
         Annuler
32
         Annuler
22
       </button>
33
       </button>
23
 
34
 
24
       <button
35
       <button
25
         type='button'
36
         type='button'
26
-        className={`${props.customClass}__submit editionmode__button__submit btn btn-outline-primary`}
37
+        className={`${props.customClass}__submit editionmode__button__submit btn`}
27
         onClick={props.onClickValidateBtn}
38
         onClick={props.onClickValidateBtn}
39
+        style={{
40
+          backgroundColor: '#fdfdfd',
41
+          color: props.customColor,
42
+          borderColor: props.customColor,
43
+          ':hover': {
44
+            backgroundColor: props.customColor,
45
+            color: '#fdfdfd'
46
+          }
47
+        }}
48
+        key='TextAreaApp__validate'
28
       >
49
       >
29
         Valider
50
         Valider
30
       </button>
51
       </button>
31
     </div>
52
     </div>
32
   </form>
53
   </form>
33
 
54
 
34
-export default TextAreaApp
55
+export default Radium(TextAreaApp)
35
 
56
 
36
 TextAreaApp.propTypes = {
57
 TextAreaApp.propTypes = {
37
   text: PropTypes.string.isRequired,
58
   text: PropTypes.string.isRequired,
39
   onClickCancelBtn: PropTypes.func.isRequired,
60
   onClickCancelBtn: PropTypes.func.isRequired,
40
   onClickValidateBtn: PropTypes.func.isRequired,
61
   onClickValidateBtn: PropTypes.func.isRequired,
41
   id: PropTypes.string,
62
   id: PropTypes.string,
42
-  customClass: PropTypes.string
63
+  customClass: PropTypes.string,
64
+  customColor: PropTypes.string
43
 }
65
 }

+ 14 - 1
src/component/OptionComponent/ArchiveDeleteContent.jsx View File

1
 import React from 'react'
1
 import React from 'react'
2
+import Radium from 'radium'
2
 
3
 
3
 const ArchiveDeleteContent = props => {
4
 const ArchiveDeleteContent = props => {
5
+  const styleColorBtn = {
6
+    backgroundColor: '#fdfdfd',
7
+    color: '#333',
8
+    ':hover': {
9
+      color: props.customColor
10
+    }
11
+  }
12
+
4
   return (
13
   return (
5
     <div className='d-flex align-items-center'>
14
     <div className='d-flex align-items-center'>
6
       <button
15
       <button
9
         onClick={props.onClickArchiveBtn}
18
         onClick={props.onClickArchiveBtn}
10
         disabled={props.disabled}
19
         disabled={props.disabled}
11
         title='Archiver'
20
         title='Archiver'
21
+        style={styleColorBtn}
22
+        key={'archiveDeleteContent__archive'}
12
       >
23
       >
13
         <i className='fa fa-fw fa-archive' />
24
         <i className='fa fa-fw fa-archive' />
14
       </button>
25
       </button>
18
         onClick={props.onClickDeleteBtn}
29
         onClick={props.onClickDeleteBtn}
19
         disabled={props.disabled}
30
         disabled={props.disabled}
20
         title='Supprimer'
31
         title='Supprimer'
32
+        style={styleColorBtn}
33
+        key={'archiveDeleteContent__delete'}
21
       >
34
       >
22
         <i className='fa fa-fw fa-trash' />
35
         <i className='fa fa-fw fa-trash' />
23
       </button>
36
       </button>
25
   )
38
   )
26
 }
39
 }
27
 
40
 
28
-export default ArchiveDeleteContent
41
+export default Radium(ArchiveDeleteContent)

+ 13 - 2
src/component/OptionComponent/NewVersionBtn.jsx View File

1
 import React from 'react'
1
 import React from 'react'
2
+import Radium from 'radium'
2
 
3
 
3
 const NewVersionBtn = props => {
4
 const NewVersionBtn = props => {
4
   return (
5
   return (
5
     <button
6
     <button
6
-      className='wsContentGeneric__option__menu__addversion newversionbtn btn btn-outline-primary'
7
+      className='wsContentGeneric__option__menu__addversion newversionbtn btn'
7
       onClick={props.onClickNewVersionBtn}
8
       onClick={props.onClickNewVersionBtn}
8
       disabled={props.disabled}
9
       disabled={props.disabled}
10
+      style={{
11
+        backgroundColor: '#fdfdfd',
12
+        color: '#333',
13
+        border: '1px solid',
14
+        borderColor: props.customColor,
15
+        ':hover': {
16
+          backgroundColor: props.customColor,
17
+          color: '#fdfdfd'
18
+        }
19
+      }}
9
     >
20
     >
10
       Modifier
21
       Modifier
11
       <i className='fa fa-plus-circle ml-3' />
22
       <i className='fa fa-plus-circle ml-3' />
13
   )
24
   )
14
 }
25
 }
15
 
26
 
16
-export default NewVersionBtn
27
+export default Radium(NewVersionBtn)

+ 4 - 2
src/component/PopinFixed/PopinFixedHeader.jsx View File

27
   }
27
   }
28
 
28
 
29
   render () {
29
   render () {
30
-    const { customClass, faIcon, title, onClickCloseBtn } = this.props
30
+    const { customClass, customColor, faIcon, title, onClickCloseBtn } = this.props
31
 
31
 
32
     return (
32
     return (
33
-      <div className={classnames('wsContentGeneric__header', `${customClass}__header`)}>
33
+      <div className={classnames('wsContentGeneric__header', `${customClass}__header`)} style={{backgroundColor: customColor}}>
34
         <div className={classnames('wsContentGeneric__header__icon', `${customClass}__header__icon`)}>
34
         <div className={classnames('wsContentGeneric__header__icon', `${customClass}__header__icon`)}>
35
           <i className={`fa fa-${faIcon}`} />
35
           <i className={`fa fa-${faIcon}`} />
36
         </div>
36
         </div>
66
   faIcon: PropTypes.string.isRequired,
66
   faIcon: PropTypes.string.isRequired,
67
   onClickCloseBtn: PropTypes.func.isRequired,
67
   onClickCloseBtn: PropTypes.func.isRequired,
68
   customClass: PropTypes.string,
68
   customClass: PropTypes.string,
69
+  customColor: PropTypes.string,
69
   title: PropTypes.string,
70
   title: PropTypes.string,
70
   onValidateChangeTitle: PropTypes.func
71
   onValidateChangeTitle: PropTypes.func
71
 }
72
 }
72
 
73
 
73
 PopinFixedHeader.defaultProps = {
74
 PopinFixedHeader.defaultProps = {
74
   customClass: '',
75
   customClass: '',
76
+  customColor: '',
75
   title: '',
77
   title: '',
76
   onChangeTitle: () => {}
78
   onChangeTitle: () => {}
77
 }
79
 }

+ 35 - 22
src/component/Timeline/Comment.jsx View File

1
 import React from 'react'
1
 import React from 'react'
2
 import classnames from 'classnames'
2
 import classnames from 'classnames'
3
 
3
 
4
-const Comment = props => (
5
-  <li className={classnames(
6
-    `${props.customClass}__messagelist__item`,
7
-    'timeline__body__messagelist__item', {
8
-      'received': props.fromMe, // @FIXME : invert names of class (received should be !fromMe)
9
-      'sended': !props.fromMe
10
-    }
11
-  )}>
12
-    <div className={classnames(`${props.customClass}__messagelist__item__wrapper`, 'timeline__body__messagelist__item__wrapper')}>
13
-      <div className={classnames(`${props.customClass}__messagelist__item__avatar`, 'timeline__body__messagelist__item__avatar')}>
14
-        {props.avatar ? <img src={props.avatar} /> : ''}
4
+const Comment = props => {
5
+  const styleSent = {
6
+    color: '#fdfdfd',
7
+    backgroundColor: props.customColor
8
+  }
9
+
10
+  const styleReceived = {
11
+    color: '#333',
12
+    backgroundColor: '#fdfdfd'
13
+  }
14
+
15
+  return (
16
+    <li className={classnames(
17
+      `${props.customClass}__messagelist__item`,
18
+      'timeline__body__messagelist__item', {
19
+        'sent': props.fromMe,
20
+        'received': !props.fromMe
21
+      }
22
+    )}>
23
+      <div className={classnames(`${props.customClass}__messagelist__item__wrapper`, 'timeline__body__messagelist__item__wrapper')}>
24
+        <div className={classnames(`${props.customClass}__messagelist__item__avatar`, 'timeline__body__messagelist__item__avatar')}>
25
+          {props.avatar ? <img src={props.avatar} /> : ''}
26
+        </div>
27
+      </div>
28
+      <div
29
+        className={classnames(`${props.customClass}__messagelist__item__createhour`, 'timeline__body__messagelist__item__createhour')}>
30
+        {props.createdAt}
15
       </div>
31
       </div>
16
-    </div>
17
-    <div
18
-      className={classnames(`${props.customClass}__messagelist__item__createhour`, 'timeline__body__messagelist__item__createhour')}>
19
-      {props.createdAt}
20
-    </div>
21
-    <div
22
-      className={classnames(`${props.customClass}__messagelist__item__content`, 'timeline__body__messagelist__item__content')}
23
-      dangerouslySetInnerHTML={{__html: props.text}}
24
-    />
25
-  </li>
26
-)
32
+      <div
33
+        className={classnames(`${props.customClass}__messagelist__item__content`, 'timeline__body__messagelist__item__content')}
34
+        style={props.fromMe ? styleSent : styleReceived}
35
+        dangerouslySetInnerHTML={{__html: props.text}}
36
+      />
37
+    </li>
38
+  )
39
+}
27
 
40
 
28
 export default Comment
41
 export default Comment

+ 10 - 1
src/component/Timeline/Revision.jsx View File

1
 import React from 'react'
1
 import React from 'react'
2
 import classnames from 'classnames'
2
 import classnames from 'classnames'
3
+import Radium from 'radium'
4
+import color from 'color'
3
 
5
 
4
 const Revision = props => (
6
 const Revision = props => (
5
   <li className={classnames(`${props.customClass}__messagelist__version`, 'timeline__body__messagelist__version')} >
7
   <li className={classnames(`${props.customClass}__messagelist__version`, 'timeline__body__messagelist__version')} >
7
       type='button'
9
       type='button'
8
       className={classnames(`${props.customClass}__messagelist__version__btn`, 'timeline__body__messagelist__version__btn btn')}
10
       className={classnames(`${props.customClass}__messagelist__version__btn`, 'timeline__body__messagelist__version__btn btn')}
9
       onClick={props.onClickRevision}
11
       onClick={props.onClickRevision}
12
+      style={{
13
+        backgroundColor: props.customColor,
14
+        color: '#fdfdfd',
15
+        ':hover': {
16
+          backgroundColor: color(props.customColor).darken(0.15).hexString()
17
+        }
18
+      }}
10
     >
19
     >
11
       <i className='fa fa-code-fork' />
20
       <i className='fa fa-code-fork' />
12
       version {props.number}
21
       version {props.number}
18
   </li>
27
   </li>
19
 )
28
 )
20
 
29
 
21
-export default Revision
30
+export default Radium(Revision)

+ 26 - 2
src/component/Timeline/Timeline.jsx View File

1
 import React from 'react'
1
 import React from 'react'
2
 import PropTypes from 'prop-types'
2
 import PropTypes from 'prop-types'
3
 import classnames from 'classnames'
3
 import classnames from 'classnames'
4
+import Radium from 'radium'
5
+import color from 'color'
4
 import Comment from './Comment.jsx'
6
 import Comment from './Comment.jsx'
5
 import Revision from './Revision.jsx'
7
 import Revision from './Revision.jsx'
6
 
8
 
43
                 case 'comment':
45
                 case 'comment':
44
                   return <Comment
46
                   return <Comment
45
                     customClass={props.customClass}
47
                     customClass={props.customClass}
48
+                    customColor={props.customColor}
46
                     avatar={content.author.avatar_url}
49
                     avatar={content.author.avatar_url}
47
                     createdAt={content.created}
50
                     createdAt={content.created}
48
                     text={content.raw_content}
51
                     text={content.raw_content}
53
                 case 'revision':
56
                 case 'revision':
54
                   return <Revision
57
                   return <Revision
55
                     customClass={props.customClass}
58
                     customClass={props.customClass}
59
+                    customColor={props.customColor}
56
                     createdAt={content.created}
60
                     createdAt={content.created}
57
                     number={content.number}
61
                     number={content.number}
58
                     key={`revision_${content.revision_id}`}
62
                     key={`revision_${content.revision_id}`}
79
                 <button
83
                 <button
80
                   type='button'
84
                   type='button'
81
                   className={classnames(
85
                   className={classnames(
82
-                    `${props.customClass}__texteditor__advancedtext__btn timeline__body__texteditor__advancedtext__btn btn btn-outline-primary`
86
+                    `${props.customClass}__texteditor__advancedtext__btn timeline__body__texteditor__advancedtext__btn btn`
83
                   )}
87
                   )}
84
                   onClick={props.onClickWysiwygBtn}
88
                   onClick={props.onClickWysiwygBtn}
85
                   disabled={props.disableComment}
89
                   disabled={props.disableComment}
90
+                  style={{
91
+                    backgroundColor: 'transparent',
92
+                    color: '#333',
93
+                    borderColor: props.customColor,
94
+                    ':hover': {
95
+                      backgroundColor: props.customColor,
96
+                      color: '#fdfdfd'
97
+                    }
98
+                  }}
99
+                  key={'timeline__comment__advancedtext'}
86
                 >
100
                 >
87
                   {props.wysiwyg ? 'Texte Simple' : 'Texte Avancé'}
101
                   {props.wysiwyg ? 'Texte Simple' : 'Texte Avancé'}
88
                 </button>
102
                 </button>
94
                   className={classnames(`${props.customClass}__texteditor__submit__btn`, 'timeline__body__texteditor__submit__btn btn')}
108
                   className={classnames(`${props.customClass}__texteditor__submit__btn`, 'timeline__body__texteditor__submit__btn btn')}
95
                   onClick={props.onClickValidateNewCommentBtn}
109
                   onClick={props.onClickValidateNewCommentBtn}
96
                   disabled={props.disableComment}
110
                   disabled={props.disableComment}
111
+                  style={{
112
+                    backgroundColor: props.customColor,
113
+                    color: '#fdfdfd',
114
+                    ':hover': {
115
+                      backgroundColor: color(props.customColor).darken(0.15).hexString()
116
+                    }
117
+                  }}
118
+                  key={'timeline__comment__send'}
97
                 >
119
                 >
98
                   Envoyer
120
                   Envoyer
99
                   <div
121
                   <div
110
   }
132
   }
111
 }
133
 }
112
 
134
 
113
-export default Timeline
135
+export default Radium(Timeline)
114
 
136
 
115
 Timeline.propTypes = {
137
 Timeline.propTypes = {
116
   timelineData: PropTypes.array.isRequired,
138
   timelineData: PropTypes.array.isRequired,
119
   onClickValidateNewCommentBtn: PropTypes.func.isRequired,
141
   onClickValidateNewCommentBtn: PropTypes.func.isRequired,
120
   disableComment: PropTypes.bool,
142
   disableComment: PropTypes.bool,
121
   customClass: PropTypes.string,
143
   customClass: PropTypes.string,
144
+  customColor: PropTypes.string,
122
   loggedUser: PropTypes.object,
145
   loggedUser: PropTypes.object,
123
   wysiwyg: PropTypes.bool,
146
   wysiwyg: PropTypes.bool,
124
   onClickWysiwygBtn: PropTypes.func,
147
   onClickWysiwygBtn: PropTypes.func,
130
 Timeline.defaultProps = {
153
 Timeline.defaultProps = {
131
   disableComment: false,
154
   disableComment: false,
132
   customClass: '',
155
   customClass: '',
156
+  customColor: '',
133
   loggedUser: {
157
   loggedUser: {
134
     id: '',
158
     id: '',
135
     name: '',
159
     name: '',

+ 1 - 3
src/component/Timeline/Timeline.styl View File

107
             display inline-block
107
             display inline-block
108
             margin-left 20px
108
             margin-left 20px
109
 
109
 
110
-.received
110
+.sent
111
   text-align right
111
   text-align right
112
   .timeline__body__messagelist__item
112
   .timeline__body__messagelist__item
113
     &__wrapper
113
     &__wrapper
118
     &__createhour
118
     &__createhour
119
       margin-left 0
119
       margin-left 0
120
       margin-right 35px
120
       margin-right 35px
121
-    &__content
122
-      color white
123
 
121
 
124
 
122
 
125
 .mce-btn-group:not(:first-child)
123
 .mce-btn-group:not(:first-child)

+ 7 - 1
src/index.dev.js View File

17
 import CardPopup from './component/CardPopup/CardPopup.jsx'
17
 import CardPopup from './component/CardPopup/CardPopup.jsx'
18
 import CardPopupCreateContent from './component/CardPopup/CardPopupCreateContent.jsx'
18
 import CardPopupCreateContent from './component/CardPopup/CardPopupCreateContent.jsx'
19
 
19
 
20
+import NewVersionButton from './component/OptionComponent/NewVersionBtn.jsx'
21
+import ArchiveDeleteContent from './component/OptionComponent/ArchiveDeleteContent.jsx'
22
+
20
 ReactDOM.render(
23
 ReactDOM.render(
21
   <div style={{width: '1200px'}}>
24
   <div style={{width: '1200px'}}>
22
     <PopinFixed customClass={`${'randomClass'}`}>
25
     <PopinFixed customClass={`${'randomClass'}`}>
69
 
72
 
70
       <PopinFixedContent customClass={`${'randomClass'}__contentpage`}>
73
       <PopinFixedContent customClass={`${'randomClass'}__contentpage`}>
71
         <div>
74
         <div>
75
+          <NewVersionButton customColor='#3f52e3' />
76
+          <ArchiveDeleteContent customColor='#3f52e3' />
72
           <Delimiter />
77
           <Delimiter />
73
           <span>Here will be the app content. Style is handled by the app (obviously)</span>
78
           <span>Here will be the app content. Style is handled by the app (obviously)</span>
74
           <BtnSwitch />
79
           <BtnSwitch />
77
 
82
 
78
         <Timeline
83
         <Timeline
79
           customClass={`${'randomClass'}__contentpage`}
84
           customClass={`${'randomClass'}__contentpage`}
85
+          customColor={'#3f52e3'}
80
           loggedUser={{
86
           loggedUser={{
81
-            user_id: 5,
87
+            user_id: 1,
82
             username: 'Smoi',
88
             username: 'Smoi',
83
             firstname: 'Côme',
89
             firstname: 'Côme',
84
             lastname: 'Stoilenom',
90
             lastname: 'Stoilenom',