Pārlūkot izejas kodu

added PopinFixed + removed test code

Skylsmoi 6 gadus atpakaļ
vecāks
revīzija
8fae872f6f

+ 44 - 0
src/Component/PopinFixed/PopinFixed.jsx Parādīt failu

@@ -0,0 +1,44 @@
1
+import React from 'react'
2
+import classnames from 'classnames'
3
+import PropTypes from 'prop-types'
4
+import PopinFixedHeader from './PopinFixedHeader.jsx'
5
+import PopinFixedOption from './PopinFixedOption.jsx'
6
+import PopinFixedContent from './PopinFixedContent.jsx'
7
+
8
+require('../../css/PopinFixed.styl')
9
+
10
+const PopinFixed = props => {
11
+  return (
12
+    <div className={classnames('wsFileGeneric', props.customClass, {'visible': props.visible})}>
13
+      {props.children}
14
+    </div>
15
+  )
16
+}
17
+
18
+export default PopinFixed
19
+
20
+PopinFixed.propTypes = {
21
+  customClass: PropTypes.string,
22
+  visible: PropTypes.bool
23
+}
24
+
25
+PopinFixed.propTypes = {
26
+  // from http://www.mattzabriskie.com/blog/react-validating-children
27
+  children: PropTypes.arrayOf((children, key, componentName /* , location, propFullName */) => {
28
+    if (
29
+      children.length > 3 ||
30
+      children[0].type !== PopinFixedHeader ||
31
+      children[1].type !== PopinFixedOption ||
32
+      children[2].type !== PopinFixedContent
33
+    ) {
34
+      return new Error(`PropType Error: childrens of ${componentName} must be: 1 PopinFixedHeader, 1 PopinFixedOption and 1 PopinFixedContent.`)
35
+    }
36
+  }).isRequired,
37
+  customClass: PropTypes.string,
38
+  visible: PropTypes.bool
39
+}
40
+
41
+PopinFixed.defaultProps = {
42
+  customClass: '',
43
+  visible: true
44
+}

+ 32 - 0
src/Component/PopinFixed/PopinFixedContent.jsx Parādīt failu

@@ -0,0 +1,32 @@
1
+import React from 'react'
2
+import classnames from 'classnames'
3
+import PropTypes from 'prop-types'
4
+
5
+const PopinFixedContent = props => {
6
+  return props.children.length === 2
7
+    ? (
8
+      <div className={classnames('wsFileGeneric__content', `${props.customClass}__content`)}>
9
+        <div className={classnames('wsFileGeneric__content__left', `${props.customClass}__content__left`)}>
10
+          {props.children[0]}
11
+        </div>
12
+
13
+        <div className={classnames('wsFileGeneric__content__right', `${props.customClass}__content__right`)}>
14
+          {props.children[1]}
15
+        </div>
16
+      </div>
17
+    )
18
+    : (
19
+      <div className={classnames('wsFileGeneric__content', `${props.customClass}__content`)}>
20
+        { props.children }
21
+      </div>
22
+    )
23
+}
24
+
25
+export default PopinFixedContent
26
+
27
+PopinFixedContent.propTypes = {
28
+  customClass: PropTypes.string,
29
+  children: PropTypes.arrayOf((children, key, componentName /* , location, propFullName */) =>
30
+    children.length !== 2 && new Error(`PropType Error: ${componentName} must have 2 children.`)
31
+  ).isRequired
32
+}

+ 42 - 0
src/Component/PopinFixed/PopinFixedHeader.jsx Parādīt failu

@@ -0,0 +1,42 @@
1
+import React from 'react'
2
+import classnames from 'classnames'
3
+import PropTypes from 'prop-types'
4
+
5
+const PopinFixedHeader = props => {
6
+  return (
7
+    <div className={classnames('wsFileGeneric__header', `${props.customClass}__header`)}>
8
+      <div className={classnames('wsFileGeneric__header__icon', `${props.customClass}__header__icon`)}>
9
+        <i className={props.icon} />
10
+      </div>
11
+
12
+      <div className={classnames('wsFileGeneric__header__title mr-auto', `${props.customClass}__header__title`)}>
13
+        {props.name}
14
+      </div>
15
+
16
+      <div className={classnames('wsFileGeneric__header__edittitle', `${props.customClass}__header__changetitle`)}>
17
+        <i className='fa fa-pencil' />
18
+      </div>
19
+
20
+      <div
21
+        className={classnames('wsFileGeneric__header__close', `${props.customClass}__header__close`)}
22
+        onClick={props.onClickCloseBtn}
23
+      >
24
+        <i className='fa fa-times' />
25
+      </div>
26
+    </div>
27
+  )
28
+}
29
+
30
+export default PopinFixedHeader
31
+
32
+PopinFixedHeader.propTypes = {
33
+  icon: PropTypes.string.isRequired,
34
+  onClickCloseBtn: PropTypes.func.isRequired,
35
+  customClass: PropTypes.string,
36
+  name: PropTypes.string
37
+}
38
+
39
+PopinFixedHeader.defaultProps = {
40
+  customClass: '',
41
+  name: ''
42
+}

+ 67 - 0
src/Component/PopinFixed/PopinFixedOption.jsx Parādīt failu

@@ -0,0 +1,67 @@
1
+import React from 'react'
2
+// import classnames from 'classnames'
3
+// import PropTypes from 'prop-types'
4
+
5
+const PopinFixedOption = props => {
6
+  return (
7
+    <div className='wsFileGeneric__option'>
8
+      <div className='wsFileGeneric__option__menu'>
9
+
10
+        <div className='wsFileFile__option__menu__addversion btn mr-auto'>
11
+          Nouvelle version
12
+          <i className='fa fa-plus-circle' />
13
+        </div>
14
+
15
+        <div className='wsFileGeneric__option__menu__status dropdown'>
16
+          <button className='wsFileGeneric__option__menu__status__dropdownbtn check btn dropdown-toggle' type='button' id='dropdownMenu2' data-toggle='dropdown' aria-haspopup='true' aria-expanded='false'>
17
+            Validé
18
+            <div className='wsFileGeneric__option__menu__status__dropdownbtn__icon'>
19
+              <i className='fa fa-check' />
20
+            </div>
21
+          </button>
22
+
23
+          <div className='wsFileGeneric__option__menu__status__submenu dropdown-menu' aria-labelledby='dropdownMenu2'>
24
+            <h6 className='dropdown-header'>Statut du fichier</h6>
25
+            <div className='dropdown-divider' />
26
+            <button className='wsFileGeneric__option__menu__status__submenu__item current  dropdown-item' type='button'>
27
+              En cours
28
+              <div className='wsFileGeneric__option__menu__status__submenu__item__icon'>
29
+                <i className='fa fa-gears' />
30
+              </div>
31
+            </button>
32
+            <button className='wsFileGeneric__option__menu__status__submenu__item check dropdown-item' type='button'>
33
+              Validé
34
+              <div className='wsFileGeneric__option__menu__status__submenu__item__icon'>
35
+                <i className='fa fa-check' />
36
+              </div>
37
+            </button>
38
+            <button className='wsFileGeneric__option__menu__status__submenu__item invalid dropdown-item' type='button'>
39
+              Invalidé
40
+              <div className='wsFileGeneric__option__menu__status__submenu__item__icon'>
41
+                <i className='fa fa-times' />
42
+              </div>
43
+            </button>
44
+            <button className='wsFileGeneric__option__menu__status__submenu__item ban dropdown-item' type='button'>
45
+              Obsolète
46
+              <div className='wsFileGeneric__option__menu__status__submenu__item__icon'>
47
+                <i className='fa fa-ban' />
48
+              </div>
49
+            </button>
50
+          </div>
51
+        </div>
52
+        <div className='wsFileGeneric__option__menu__action'>
53
+          <i className='fa fa-archive' />
54
+        </div>
55
+        <div className='wsFileGeneric__option__menu__action'>
56
+          <i className='fa fa-trash' />
57
+        </div>
58
+      </div>
59
+    </div>
60
+  )
61
+}
62
+
63
+export default PopinFixedOption
64
+
65
+PopinFixedOption.propTypes = {
66
+
67
+}

+ 100 - 0
src/css/PopinFixed.styl Parādīt failu

@@ -0,0 +1,100 @@
1
+.wsFileGeneric
2
+  position fixed
3
+  top 85px
4
+  right 0
5
+  border 1px solid grey
6
+  height 100%
7
+  background-color lightGrey
8
+  box-shadow shadow-page
9
+  visibility hidden
10
+  z-index 1
11
+  &.visible
12
+    visibility visible
13
+  &__header
14
+    display flex
15
+    align-items center
16
+    padding 15px
17
+    height 64px
18
+    &__icon
19
+      margin-right 15px
20
+      font-size 22px
21
+      color white
22
+    &__title
23
+      margin-right 15px
24
+      color white
25
+      text-overflow ellipsis
26
+      overflow hidden
27
+      white-space nowrap
28
+    &__edittitle
29
+      margin 0 15px
30
+      color white
31
+      font-size 20px
32
+      cursor pointer
33
+      &:hover , &:focus
34
+        border 1px solid off-white
35
+        padding 0 10px
36
+        border-radius 5px
37
+    &__close
38
+      border 1px solid white
39
+      border-radius 5px
40
+      padding 2px 5px
41
+      cursor pointer
42
+      & > i
43
+        color white
44
+        font-size 20px
45
+  &__option
46
+    border-bottom 1px solid grey
47
+    padding 10px
48
+    height 58px
49
+    background-color off-white
50
+    & > i
51
+      vertical-align middle
52
+      margin-right 15px
53
+      font-size 25px
54
+      cursor pointer
55
+    &__menu
56
+      display flex
57
+      align-items center
58
+      &__status
59
+        margin-right 20px
60
+        .current
61
+          color blue
62
+        .check
63
+          color green
64
+        .invalid
65
+          color red
66
+        .ban
67
+          color grey
68
+        &__dropdownbtn
69
+          border 1px solid grey
70
+          width 150px
71
+          background-color transparent
72
+          cursor pointer
73
+          &::after
74
+            color fontColor
75
+          &:hover
76
+            background-color transparent
77
+          &__icon
78
+            display inline-block
79
+            margin 0 15px
80
+        &__submenu
81
+          &__item
82
+            display flex
83
+            justify-content space-between
84
+            margin 5px 0
85
+            cursor pointer
86
+            &:active
87
+              background-color transparent
88
+      &__action
89
+        margin 5px 10px 0 0
90
+        font-size 18px
91
+        cursor pointer
92
+        &:hover , &:focus
93
+          font-size 22px
94
+          color blue
95
+  &__content
96
+    display flex
97
+    &__left
98
+      width 55%
99
+    &__right
100
+      width 45%

+ 8 - 24
src/index.js Parādīt failu

@@ -1,26 +1,10 @@
1 1
 import React from 'react'
2
+import libPopinFixed from './Component/PopinFixed/PopinFixed.jsx'
3
+import libPopinFixedHeader from './Component/PopinFixed/PopinFixedHeader.jsx'
4
+import libPopinFixedOption from './Component/PopinFixed/PopinFixedOption.jsx'
5
+import libPopinFixedContent from './Component/PopinFixed/PopinFixedContent.jsx'
2 6
 
3
-export function bonjour () {
4
-  console.log('bonjour ?!')
5
-}
6
-
7
-export const Woot = props => (
8
-  <div>woot</div>
9
-)
10
-
11
-export class reactClass extends React.Component {
12
-  constructor (props) {
13
-    super(props)
14
-    this.state = {
15
-      id: 'ok'
16
-    }
17
-  }
18
-  render () {
19
-    return (
20
-      <div>
21
-        <Woot />
22
-        <span>{this.state.id}</span>
23
-      </div>
24
-    )
25
-  }
26
-}
7
+export const PopinFixed = libPopinFixed
8
+export const PopinFixedHeader = libPopinFixedHeader
9
+export const PopinFixedOption = libPopinFixedOption
10
+export const PopinFixedContent = libPopinFixedContent

+ 3 - 6
webpack.config.js Parādīt failu

@@ -13,12 +13,9 @@ module.exports = {
13 13
     umdNamedDefine: true
14 14
   },
15 15
   externals: {
16
-    react: {
17
-      commonjs: 'react',
18
-      commonjs2: 'react',
19
-      amd: 'react',
20
-      root: '_'
21
-    }
16
+    react: {commonjs: 'react', commonjs2: 'react', amd: 'react', root: '_'},
17
+    classnames: {commonjs: 'classnames', commonjs2: 'classnames', amd: 'classnames', root: '_'},
18
+    'prop-types': {commonjs: 'prop-types', commonjs2: 'prop-types', amd: 'prop-types', root: '_'}
22 19
   },
23 20
   devServer: {
24 21
     contentBase: path.join(__dirname, 'dist/'),