@pie-lib/correct-answer-toggle 2.5.12-next.1 → 2.6.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,7 +3,7 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [2.5.11](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.5.10...@pie-lib/correct-answer-toggle@2.5.11) (2023-10-03)
6
+ # [2.6.0-beta.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.5.11...@pie-lib/correct-answer-toggle@2.6.0-beta.1) (2025-07-20)
7
7
 
8
8
  **Note:** Version bump only for package @pie-lib/correct-answer-toggle
9
9
 
@@ -11,7 +11,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
11
11
 
12
12
 
13
13
 
14
- ## [2.5.10](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.5.9...@pie-lib/correct-answer-toggle@2.5.10) (2023-10-01)
14
+ # [2.6.0-beta.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.5.11...@pie-lib/correct-answer-toggle@2.6.0-beta.0) (2025-07-20)
15
15
 
16
16
  **Note:** Version bump only for package @pie-lib/correct-answer-toggle
17
17
 
@@ -19,124 +19,82 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
19
19
 
20
20
 
21
21
 
22
- ## [2.5.9](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.5.8...@pie-lib/correct-answer-toggle@2.5.9) (2023-09-27)
22
+ # [2.7.0-beta.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.5.11...@pie-lib/correct-answer-toggle@2.7.0-beta.0) (2025-07-15)
23
23
 
24
24
  **Note:** Version bump only for package @pie-lib/correct-answer-toggle
25
25
 
26
+ # [2.6.0-beta.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.5.11...@pie-lib/correct-answer-toggle@2.6.0-beta.0) (2025-07-15)
26
27
 
28
+ **Note:** Version bump only for package @pie-lib/correct-answer-toggle
27
29
 
30
+ ## [2.5.11](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.5.10...@pie-lib/correct-answer-toggle@2.5.11) (2023-10-03)
28
31
 
32
+ **Note:** Version bump only for package @pie-lib/correct-answer-toggle
29
33
 
30
- ## [2.5.8](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.5.7...@pie-lib/correct-answer-toggle@2.5.8) (2023-09-27)
34
+ ## [2.5.10](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.5.9...@pie-lib/correct-answer-toggle@2.5.10) (2023-10-01)
31
35
 
32
36
  **Note:** Version bump only for package @pie-lib/correct-answer-toggle
33
37
 
38
+ ## [2.5.9](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.5.8...@pie-lib/correct-answer-toggle@2.5.9) (2023-09-27)
34
39
 
40
+ **Note:** Version bump only for package @pie-lib/correct-answer-toggle
35
41
 
42
+ ## [2.5.8](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.5.7...@pie-lib/correct-answer-toggle@2.5.8) (2023-09-27)
36
43
 
44
+ **Note:** Version bump only for package @pie-lib/correct-answer-toggle
37
45
 
38
46
  ## [2.5.7](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.5.6...@pie-lib/correct-answer-toggle@2.5.7) (2023-09-25)
39
47
 
40
48
  **Note:** Version bump only for package @pie-lib/correct-answer-toggle
41
49
 
42
-
43
-
44
-
45
-
46
50
  ## [2.5.6](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.5.5...@pie-lib/correct-answer-toggle@2.5.6) (2023-09-20)
47
51
 
48
52
  **Note:** Version bump only for package @pie-lib/correct-answer-toggle
49
53
 
50
-
51
-
52
-
53
-
54
54
  ## [2.5.5](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.5.4...@pie-lib/correct-answer-toggle@2.5.5) (2023-09-20)
55
55
 
56
56
  **Note:** Version bump only for package @pie-lib/correct-answer-toggle
57
57
 
58
-
59
-
60
-
61
-
62
58
  ## [2.5.4](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.5.3...@pie-lib/correct-answer-toggle@2.5.4) (2023-09-18)
63
59
 
64
60
  **Note:** Version bump only for package @pie-lib/correct-answer-toggle
65
61
 
66
-
67
-
68
-
69
-
70
62
  ## [2.5.3](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.5.2...@pie-lib/correct-answer-toggle@2.5.3) (2023-09-14)
71
63
 
72
64
  **Note:** Version bump only for package @pie-lib/correct-answer-toggle
73
65
 
74
-
75
-
76
-
77
-
78
66
  ## [2.5.2](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.5.1...@pie-lib/correct-answer-toggle@2.5.2) (2023-08-21)
79
67
 
80
68
  **Note:** Version bump only for package @pie-lib/correct-answer-toggle
81
69
 
82
-
83
-
84
-
85
-
86
70
  ## [2.5.1](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.5.0...@pie-lib/correct-answer-toggle@2.5.1) (2023-08-15)
87
71
 
88
72
  **Note:** Version bump only for package @pie-lib/correct-answer-toggle
89
73
 
90
-
91
-
92
-
93
-
94
74
  # [2.5.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.4.0...@pie-lib/correct-answer-toggle@2.5.0) (2023-08-14)
95
75
 
96
-
97
76
  ### Features
98
77
 
99
- * update language on props change PD-2802 ([000dae9](https://github.com/pie-framework/pie-lib/commit/000dae927ed4a650bfc3fa007b2a5d891079aafd))
100
-
101
-
102
-
103
-
78
+ - update language on props change PD-2802 ([000dae9](https://github.com/pie-framework/pie-lib/commit/000dae927ed4a650bfc3fa007b2a5d891079aafd))
104
79
 
105
80
  # [2.4.0](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.3.79...@pie-lib/correct-answer-toggle@2.4.0) (2023-08-07)
106
81
 
107
-
108
82
  ### Features
109
83
 
110
- * **correct-answer-toggle:** add translations PD-2802 ([b53b653](https://github.com/pie-framework/pie-lib/commit/b53b653246deea3f67328b37feeb17787181e590))
111
-
112
-
113
-
114
-
84
+ - **correct-answer-toggle:** add translations PD-2802 ([b53b653](https://github.com/pie-framework/pie-lib/commit/b53b653246deea3f67328b37feeb17787181e590))
115
85
 
116
86
  ## [2.3.79](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.3.78...@pie-lib/correct-answer-toggle@2.3.79) (2023-07-24)
117
87
 
118
88
  **Note:** Version bump only for package @pie-lib/correct-answer-toggle
119
89
 
120
-
121
-
122
-
123
-
124
90
  ## [2.3.78](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.3.77...@pie-lib/correct-answer-toggle@2.3.78) (2023-06-24)
125
91
 
126
92
  **Note:** Version bump only for package @pie-lib/correct-answer-toggle
127
93
 
128
-
129
-
130
-
131
-
132
94
  ## [2.3.77](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.3.76...@pie-lib/correct-answer-toggle@2.3.77) (2023-06-13)
133
95
 
134
96
  **Note:** Version bump only for package @pie-lib/correct-answer-toggle
135
97
 
136
-
137
-
138
-
139
-
140
98
  ## [2.3.76](https://github.com/pie-framework/pie-lib/compare/@pie-lib/correct-answer-toggle@2.3.75...@pie-lib/correct-answer-toggle@2.3.76) (2023-06-12)
141
99
 
142
100
  **Note:** Version bump only for package @pie-lib/correct-answer-toggle
@@ -0,0 +1 @@
1
+ []
package/lib/expander.js CHANGED
@@ -57,14 +57,16 @@ var _default = (0, _styles.withStyles)(function () {
57
57
  enter: {
58
58
  transition: transition,
59
59
  opacity: 1,
60
- height: '25px',
60
+ height: 'auto',
61
61
  width: 'auto',
62
- visibility: 'visible'
62
+ visibility: 'visible',
63
+ minHeight: '25px'
63
64
  },
64
65
  enterDone: {
65
- height: '25px',
66
+ height: 'auto',
66
67
  visibility: 'visible',
67
- width: 'auto'
68
+ width: 'auto',
69
+ minHeight: '25px'
68
70
  },
69
71
  exit: {
70
72
  transition: transition,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/expander.jsx"],"names":["Expander","props","classes","show","children","expander","propTypes","PropTypes","bool","isRequired","className","string","object","oneOfType","arrayOf","node","transition","position","height","overflow","display","visibility","width","enter","opacity","enterDone","exit","exitDone"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,QAAQ,GAAG,SAAXA,QAAW,CAACC,KAAD,EAAW;AAC1B,MAAQC,OAAR,GAAoCD,KAApC,CAAQC,OAAR;AAAA,MAAiBC,IAAjB,GAAoCF,KAApC,CAAiBE,IAAjB;AAAA,MAAuBC,QAAvB,GAAoCH,KAApC,CAAuBG,QAAvB;AAEA,sBACE,gCAAC,mCAAD;AAAe,UAAID,IAAnB;AAAyB,IAAA,MAAM,EAAE,IAAjC;AAAuC,IAAA,YAAY,EAAE,KAArD;AAA4D,IAAA,OAAO,EAAE,GAArE;AAA0E,IAAA,UAAU,oBAAOD,OAAP;AAApF,kBACE;AAAK,IAAA,SAAS,EAAEA,OAAO,CAACG;AAAxB,KAAmCD,QAAnC,CADF,CADF;AAKD,CARD;;AAUAJ,QAAQ,CAACM,SAAT,GAAqB;AACnBH,EAAAA,IAAI,EAAEI,sBAAUC,IAAV,CAAeC,UADF;AAEnBC,EAAAA,SAAS,EAAEH,sBAAUI,MAFF;AAGnBT,EAAAA,OAAO,EAAEK,sBAAUK,MAHA;AAInBR,EAAAA,QAAQ,EAAEG,sBAAUM,SAAV,CAAoB,CAACN,sBAAUO,OAAV,CAAkBP,sBAAUQ,IAA5B,CAAD,EAAoCR,sBAAUQ,IAA9C,CAApB,EAAyEN;AAJhE,CAArB;AAOA,IAAMO,UAAU,GAAG,6CAAnB;;eAEe,wBAAW;AAAA,SAAO;AAC/BX,IAAAA,QAAQ,EAAE;AACRY,MAAAA,QAAQ,EAAE,UADF;AAERC,MAAAA,MAAM,EAAE,CAFA;AAGRC,MAAAA,QAAQ,EAAE,QAHF;AAIRC,MAAAA,OAAO,EAAE,MAJD;AAKRC,MAAAA,UAAU,EAAE,QALJ;AAMRC,MAAAA,KAAK,EAAE;AANC,KADqB;AAS/BC,IAAAA,KAAK,EAAE;AACLP,MAAAA,UAAU,EAAVA,UADK;AAELQ,MAAAA,OAAO,EAAE,CAFJ;AAGLN,MAAAA,MAAM,EAAE,MAHH;AAILI,MAAAA,KAAK,EAAE,MAJF;AAKLD,MAAAA,UAAU,EAAE;AALP,KATwB;AAgB/BI,IAAAA,SAAS,EAAE;AACTP,MAAAA,MAAM,EAAE,MADC;AAETG,MAAAA,UAAU,EAAE,SAFH;AAGTC,MAAAA,KAAK,EAAE;AAHE,KAhBoB;AAqB/BI,IAAAA,IAAI,EAAE;AACJV,MAAAA,UAAU,EAAVA,UADI;AAEJQ,MAAAA,OAAO,EAAE,CAFL;AAGJN,MAAAA,MAAM,EAAE,CAHJ;AAIJG,MAAAA,UAAU,EAAE,SAJR;AAKJC,MAAAA,KAAK,EAAE;AALH,KArByB;AA4B/BK,IAAAA,QAAQ,EAAE;AACRH,MAAAA,OAAO,EAAE,CADD;AAERH,MAAAA,UAAU,EAAE,QAFJ;AAGRH,MAAAA,MAAM,EAAE,CAHA;AAIRI,MAAAA,KAAK,EAAE;AAJC;AA5BqB,GAAP;AAAA,CAAX,EAkCXtB,QAlCW,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport { CSSTransition } from 'react-transition-group';\n\nconst Expander = (props) => {\n const { classes, show, children } = props;\n\n return (\n <CSSTransition in={show} appear={true} mountOnEnter={false} timeout={300} classNames={{ ...classes }}>\n <div className={classes.expander}>{children}</div>\n </CSSTransition>\n );\n};\n\nExpander.propTypes = {\n show: PropTypes.bool.isRequired,\n className: PropTypes.string,\n classes: PropTypes.object,\n children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,\n};\n\nconst transition = 'height ease-in 300ms, opacity ease-in 300ms';\n\nexport default withStyles(() => ({\n expander: {\n position: 'relative',\n height: 0,\n overflow: 'hidden',\n display: 'flex',\n visibility: 'hidden',\n width: 0,\n },\n enter: {\n transition,\n opacity: 1,\n height: '25px',\n width: 'auto',\n visibility: 'visible',\n },\n enterDone: {\n height: '25px',\n visibility: 'visible',\n width: 'auto',\n },\n exit: {\n transition,\n opacity: 0,\n height: 0,\n visibility: 'visible',\n width: 0,\n },\n exitDone: {\n opacity: 0,\n visibility: 'hidden',\n height: 0,\n width: 0,\n },\n}))(Expander);\n"],"file":"expander.js"}
1
+ {"version":3,"sources":["../src/expander.jsx"],"names":["Expander","props","classes","show","children","expander","propTypes","PropTypes","bool","isRequired","className","string","object","oneOfType","arrayOf","node","transition","position","height","overflow","display","visibility","width","enter","opacity","minHeight","enterDone","exit","exitDone"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,QAAQ,GAAG,SAAXA,QAAW,CAACC,KAAD,EAAW;AAC1B,MAAQC,OAAR,GAAoCD,KAApC,CAAQC,OAAR;AAAA,MAAiBC,IAAjB,GAAoCF,KAApC,CAAiBE,IAAjB;AAAA,MAAuBC,QAAvB,GAAoCH,KAApC,CAAuBG,QAAvB;AAEA,sBACE,gCAAC,mCAAD;AAAe,UAAID,IAAnB;AAAyB,IAAA,MAAM,EAAE,IAAjC;AAAuC,IAAA,YAAY,EAAE,KAArD;AAA4D,IAAA,OAAO,EAAE,GAArE;AAA0E,IAAA,UAAU,oBAAOD,OAAP;AAApF,kBACE;AAAK,IAAA,SAAS,EAAEA,OAAO,CAACG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EAAE;AALH,KAvByB;AA8B/BM,IAAAA,QAAQ,EAAE;AACRJ,MAAAA,OAAO,EAAE,CADD;AAERH,MAAAA,UAAU,EAAE,QAFJ;AAGRH,MAAAA,MAAM,EAAE,CAHA;AAIRI,MAAAA,KAAK,EAAE;AAJC;AA9BqB,GAAP;AAAA,CAAX,EAoCXtB,QApCW,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport { CSSTransition } from 'react-transition-group';\n\nconst Expander = (props) => {\n const { classes, show, children } = props;\n\n return (\n <CSSTransition in={show} appear={true} mountOnEnter={false} timeout={300} classNames={{ ...classes }}>\n <div className={classes.expander}>{children}</div>\n </CSSTransition>\n );\n};\n\nExpander.propTypes = {\n show: PropTypes.bool.isRequired,\n className: PropTypes.string,\n classes: PropTypes.object,\n children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,\n};\n\nconst transition = 'height ease-in 300ms, opacity ease-in 300ms';\n\nexport default withStyles(() => ({\n expander: {\n position: 'relative',\n height: 0,\n overflow: 'hidden',\n display: 'flex',\n visibility: 'hidden',\n width: 0,\n },\n enter: {\n transition,\n opacity: 1,\n height: 'auto',\n width: 'auto',\n visibility: 'visible',\n minHeight: '25px',\n },\n enterDone: {\n height: 'auto',\n visibility: 'visible',\n width: 'auto',\n minHeight: '25px',\n },\n exit: {\n transition,\n opacity: 0,\n height: 0,\n visibility: 'visible',\n width: 0,\n },\n exitDone: {\n opacity: 0,\n visibility: 'hidden',\n height: 0,\n width: 0,\n },\n}))(Expander);\n"],"file":"expander.js"}
package/lib/index.js CHANGED
@@ -82,6 +82,13 @@ var CorrectAnswerToggle = /*#__PURE__*/function (_React$Component) {
82
82
  this.props.onToggle(!this.props.toggled);
83
83
  }
84
84
  }, {
85
+ key: "onTouch",
86
+ value: function onTouch(event) {
87
+ event.preventDefault(); // Prevents the default action (click event)
88
+
89
+ this.props.onToggle(!this.props.toggled);
90
+ }
91
+ }, {
85
92
  key: "UNSAFE_componentWillReceiveProps",
86
93
  value: function UNSAFE_componentWillReceiveProps(nextProps) {
87
94
  var _this$props;
@@ -117,7 +124,8 @@ var CorrectAnswerToggle = /*#__PURE__*/function (_React$Component) {
117
124
  className: classes.expander
118
125
  }, /*#__PURE__*/_react["default"].createElement("div", {
119
126
  className: classes.content,
120
- onClick: this.onClick.bind(this)
127
+ onClick: this.onClick.bind(this),
128
+ onTouchEnd: this.onTouch.bind(this)
121
129
  }, /*#__PURE__*/_react["default"].createElement("div", {
122
130
  className: classes.iconHolder
123
131
  }, /*#__PURE__*/_react["default"].createElement(_CSSTransition["default"], {
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.jsx"],"names":["translator","Translator","CorrectAnswerToggle","props","state","show","defaultProps","showMessage","t","lng","language","hideMessage","onToggle","toggled","nextProps","setState","classes","className","root","expander","content","onClick","bind","iconHolder","icon","label","React","Component","PropTypes","func","bool","string","object","isRequired","styles"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAQA,UAAR,GAAuBC,sBAAvB,CAAQD,UAAR;AAEA;AACA;AACA;;IACaE,mB;;;;;AAmBX,+BAAYC,KAAZ,EAAmB;AAAA;;AAAA;AACjB,8BAAMA,KAAN;AACA,UAAKC,KAAL,GAAa;AACXC,MAAAA,IAAI,EAAEF,KAAK,CAACE;AADD,KAAb;AAIAH,IAAAA,mBAAmB,CAACI,YAApB,mCACKJ,mBAAmB,CAACI,YADzB;AAEEC,MAAAA,WAAW,EAAEP,UAAU,CAACQ,CAAX,CAAa,0BAAb,EAAyC;AAAEC,QAAAA,GAAG,EAAEN,KAAK,CAACO;AAAb,OAAzC,CAFf;AAGEC,MAAAA,WAAW,EAAEX,UAAU,CAACQ,CAAX,CAAa,0BAAb,EAAyC;AAAEC,QAAAA,GAAG,EAAEN,KA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Q,EAAEkB,sBAAUG;AARH,C;iCADR7B,mB,kBAYW;AACpBK,EAAAA,WAAW,EAAE,qBADO;AAEpBI,EAAAA,WAAW,EAAE,qBAFO;AAGpBN,EAAAA,IAAI,EAAE,KAHc;AAIpBQ,EAAAA,OAAO,EAAE;AAJW,C;;eAiET,yBAAWqB,kBAAX,EAAmBhC,mBAAnB,C","sourcesContent":["import styles from './styles';\nimport { withStyles } from '@material-ui/core/styles';\nimport CSSTransition from 'react-transition-group/CSSTransition';\nimport { CorrectResponse } from '@pie-lib/icons';\nimport { Readable } from '@pie-lib/render-ui';\nimport Expander from './expander';\nimport React from 'react';\nimport classNames from 'classnames';\nimport PropTypes from 'prop-types';\nimport Translator from '@pie-lib/translator';\n\nconst { translator } = Translator;\n\n/**\n * We export the raw unstyled class for testability. For public use please use the default export.\n */\nexport class CorrectAnswerToggle extends React.Component {\n static propTypes = {\n onToggle: PropTypes.func,\n toggled: PropTypes.bool,\n show: PropTypes.bool,\n hideMessage: PropTypes.string,\n showMessage: PropTypes.string,\n classes: PropTypes.object.isRequired,\n className: PropTypes.string,\n language: PropTypes.string,\n };\n\n static defaultProps = {\n showMessage: 'Show correct answer',\n hideMessage: 'Hide correct answer',\n show: false,\n toggled: false,\n };\n\n constructor(props) {\n super(props);\n this.state = {\n show: props.show,\n };\n\n CorrectAnswerToggle.defaultProps = {\n ...CorrectAnswerToggle.defaultProps,\n showMessage: translator.t('common:showCorrectAnswer', { lng: props.language }),\n hideMessage: translator.t('common:hideCorrectAnswer', { lng: props.language }),\n };\n }\n\n onClick() {\n this.props.onToggle(!this.props.toggled);\n }\n\n UNSAFE_componentWillReceiveProps(nextProps) {\n this.setState({\n show: nextProps.show,\n });\n\n if (nextProps.language !== this.props?.language) {\n CorrectAnswerToggle.defaultProps = {\n ...CorrectAnswerToggle.defaultProps,\n showMessage: translator.t('common:showCorrectAnswer', { lng: nextProps.language }),\n hideMessage: translator.t('common:hideCorrectAnswer', { lng: nextProps.language }),\n };\n }\n }\n\n render() {\n const { classes, className, toggled, hideMessage, showMessage } = this.props;\n\n return (\n <div className={classNames(classes.root, className)}>\n <Expander show={this.state.show} className={classes.expander}>\n <div className={classes.content} onClick={this.onClick.bind(this)}>\n <div className={classes.iconHolder}>\n <CSSTransition timeout={400} in={toggled} exit={!toggled} classNames={classes}>\n <CorrectResponse open={toggled} key=\"correct-open\" className={classes.icon} />\n </CSSTransition>\n <CSSTransition timeout={5000} in={!toggled} exit={toggled} classNames={classes}>\n <CorrectResponse open={toggled} key=\"correct-closed\" className={classes.icon} />\n </CSSTransition>\n </div>\n <Readable false>\n <div className={classes.label} aria-hidden={!this.state.show}>\n {toggled ? hideMessage : showMessage}\n </div>\n </Readable>\n </div>\n </Expander>\n </div>\n );\n }\n}\n\nexport default withStyles(styles)(CorrectAnswerToggle);\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.jsx"],"names":["translator","Translator","CorrectAnswerToggle","props","state","show","defaultProps","showMessage","t","lng","language","hideMessage","onToggle","toggled","event","preventDefault","nextProps","setState","classes","className","root","expander","content","onClick","bind","onTouch","iconHolder","icon","label","React","Component","PropTypes","func","bool","string","object","isRequired","styles"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAQA,UAAR,GAAuBC,sBAAvB,CAAQD,UAAR;AAEA;AACA;AACA;;IACaE,mB;;;;;AAmBX,+BAAYC,KAAZ,EAAmB;AAAA;;AAAA;AACjB,8BAAMA,KAAN;AACA,UAAKC,KAAL,GAAa;AACXC,MAAAA,IAAI,EAAEF,KAAK,CAACE;AADD,KAAb;AAIAH,IAAAA,mBAAmB,CAACI,YAApB,mCACKJ,mBAAmB,CAACI,YADzB;AAEEC,MAAAA,WAAW,EAAEP,UAAU,CAACQ,CAAX,CAAa,0BAAb,EAAyC;AAAEC,QAAAA,GAAG,EAAEN,KAAK,CAACO;AAAb,OAAzC,CAFf;A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BAAUC,IADH;AAEjBnB,EAAAA,OAAO,EAAEkB,sBAAUE,IAFF;AAGjB5B,EAAAA,IAAI,EAAE0B,sBAAUE,IAHC;AAIjBtB,EAAAA,WAAW,EAAEoB,sBAAUG,MAJN;AAKjB3B,EAAAA,WAAW,EAAEwB,sBAAUG,MALN;AAMjBhB,EAAAA,OAAO,EAAEa,sBAAUI,MAAV,CAAiBC,UANT;AAOjBjB,EAAAA,SAAS,EAAEY,sBAAUG,MAPJ;AAQjBxB,EAAAA,QAAQ,EAAEqB,sBAAUG;AARH,C;iCADRhC,mB,kBAYW;AACpBK,EAAAA,WAAW,EAAE,qBADO;AAEpBI,EAAAA,WAAW,EAAE,qBAFO;AAGpBN,EAAAA,IAAI,EAAE,KAHc;AAIpBQ,EAAAA,OAAO,EAAE;AAJW,C;;eAqET,yBAAWwB,kBAAX,EAAmBnC,mBAAnB,C","sourcesContent":["import styles from './styles';\nimport { withStyles } from '@material-ui/core/styles';\nimport CSSTransition from 'react-transition-group/CSSTransition';\nimport { CorrectResponse } from '@pie-lib/icons';\nimport { Readable } from '@pie-lib/render-ui';\nimport Expander from './expander';\nimport React from 'react';\nimport classNames from 'classnames';\nimport PropTypes from 'prop-types';\nimport Translator from '@pie-lib/translator';\n\nconst { translator } = Translator;\n\n/**\n * We export the raw unstyled class for testability. For public use please use the default export.\n */\nexport class CorrectAnswerToggle extends React.Component {\n static propTypes = {\n onToggle: PropTypes.func,\n toggled: PropTypes.bool,\n show: PropTypes.bool,\n hideMessage: PropTypes.string,\n showMessage: PropTypes.string,\n classes: PropTypes.object.isRequired,\n className: PropTypes.string,\n language: PropTypes.string,\n };\n\n static defaultProps = {\n showMessage: 'Show correct answer',\n hideMessage: 'Hide correct answer',\n show: false,\n toggled: false,\n };\n\n constructor(props) {\n super(props);\n this.state = {\n show: props.show,\n };\n\n CorrectAnswerToggle.defaultProps = {\n ...CorrectAnswerToggle.defaultProps,\n showMessage: translator.t('common:showCorrectAnswer', { lng: props.language }),\n hideMessage: translator.t('common:hideCorrectAnswer', { lng: props.language }),\n };\n }\n\n onClick() {\n this.props.onToggle(!this.props.toggled);\n }\n onTouch(event) {\n event.preventDefault(); // Prevents the default action (click event)\n this.props.onToggle(!this.props.toggled);\n }\n\n UNSAFE_componentWillReceiveProps(nextProps) {\n this.setState({\n show: nextProps.show,\n });\n\n if (nextProps.language !== this.props?.language) {\n CorrectAnswerToggle.defaultProps = {\n ...CorrectAnswerToggle.defaultProps,\n showMessage: translator.t('common:showCorrectAnswer', { lng: nextProps.language }),\n hideMessage: translator.t('common:hideCorrectAnswer', { lng: nextProps.language }),\n };\n }\n }\n\n render() {\n const { classes, className, toggled, hideMessage, showMessage } = this.props;\n\n return (\n <div className={classNames(classes.root, className)}>\n <Expander show={this.state.show} className={classes.expander}>\n <div className={classes.content} onClick={this.onClick.bind(this)} onTouchEnd={this.onTouch.bind(this)}>\n <div className={classes.iconHolder}>\n <CSSTransition timeout={400} in={toggled} exit={!toggled} classNames={classes}>\n <CorrectResponse open={toggled} key=\"correct-open\" className={classes.icon} />\n </CSSTransition>\n <CSSTransition timeout={5000} in={!toggled} exit={toggled} classNames={classes}>\n <CorrectResponse open={toggled} key=\"correct-closed\" className={classes.icon} />\n </CSSTransition>\n </div>\n <Readable false>\n <div className={classes.label} aria-hidden={!this.state.show}>\n {toggled ? hideMessage : showMessage}\n </div>\n </Readable>\n </div>\n </Expander>\n </div>\n );\n }\n}\n\nexport default withStyles(styles)(CorrectAnswerToggle);\n"],"file":"index.js"}
package/lib/styles.js CHANGED
@@ -30,11 +30,9 @@ var _default = {
30
30
  minWidth: '140px',
31
31
  // eslint-disable-next-line
32
32
  fontFamily: "'Roboto', sans-serif",
33
- height: '25px',
34
- lineHeight: '25px',
33
+ alignSelf: 'center',
35
34
  verticalAlign: 'middle',
36
35
  color: "var(--correct-answer-toggle-label-color, ".concat(_renderUi.color.text(), ")"),
37
- fontSize: '15px',
38
36
  fontWeight: 'normal'
39
37
  }, noTouch),
40
38
  icon: {
@@ -43,7 +41,9 @@ var _default = {
43
41
  },
44
42
  iconHolder: {
45
43
  width: '25px',
46
- marginRight: '5px'
44
+ marginRight: '5px',
45
+ display: 'flex',
46
+ alignItems: 'center'
47
47
  },
48
48
  enter: {
49
49
  opacity: '0'
package/lib/styles.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/styles.js"],"names":["noTouch","root","width","cursor","content","margin","textAlign","display","label","Object","assign","minWidth","fontFamily","height","lineHeight","verticalAlign","color","text","fontSize","fontWeight","icon","position","iconHolder","marginRight","enter","opacity","enterActive","transition","exit","exitActive","animationStyles"],"mappings":";;;;;;;AAAA;;AAEA,IAAMA,OAAO,GAAG;AACd,2BAAyB,MADX;AAEd,yBAAuB,MAFT;AAGd,wBAAsB,MAHR;AAId,sBAAoB,MAJN;AAKd,qBAAmB,MALL;AAMd,iBAAe;AAND,CAAhB;eASe;AACbC,EAAAA,IAAI,EAAE;AACJC,IAAAA,KAAK,EAAE,MADH;AAEJC,IAAAA,MAAM,EAAE;AAFJ,GADO;AAKbC,EAAAA,OAAO,EAAE;AACPC,IAAAA,MAAM,EAAE,QADD;AAEPC,IAAAA,SAAS,EAAE,QAFJ;AAGPC,IAAAA,OAAO,EAAE;AAHF,GALI;AAUbC,EAAAA,KAAK,EAAEC,MAAM,CAACC,MAAP,CACL;AACER,IAAAA,KAAK,EAAE,aADT;AAEES,IAAAA,QAAQ,EAAE,OAFZ;AAGE;AACAC,IAAAA,UAAU,EAAE,sBAJd;AAKEC,IAAAA,MAAM,EAAE,MALV;AAMEC,IAAAA,UAAU,EAAE,MANd;AAOEC,IAAAA,aAAa,EAAE,QAPjB;AAQEC,IAAAA,KAAK,sDAA+CA,gBAAMC,IAAN,EAA/C,MARP;AASEC,IAAAA,QAAQ,EAAE,MATZ;AAUEC,IAAAA,UAAU,EAAE;AAVd,GADK,EAaLnB,OAbK,CAVM;AAyBboB,EAAAA,IAAI,EAAE;AACJC,IAAAA,QAAQ,EAAE,UADN;AAEJnB,IAAAA,KAAK,EAAE;AAFH,GAzBO;AA6BboB,EAAAA,UAAU,EAAE;AACVpB,IAAAA,KAAK,EAAE,MADG;AAEVqB,IAAAA,WAAW,EAAE;AAFH,GA7BC;AAiCbC,EAAAA,KAAK,EAAE;AACLC,IAAAA,OAAO,EAAE;AADJ,GAjCM;AAoCbC,EAAAA,WAAW,EAAE;AACXD,IAAAA,OAAO,EAAE,GADE;AAEXE,IAAAA,UAAU,EAAE;AAFD,GApCA;AAwCbC,EAAAA,IAAI,EAAE;AACJH,IAAAA,OAAO,EAAE;AADL,GAxCO;AA2CbI,EAAAA,UAAU,EAAE;AACVJ,IAAAA,OAAO,EAAE,GADC;AAEVE,IAAAA,UAAU,EAAE;AAFF;AA3CC,C;;AAiDR,IAAMG,eAAe,GAAG,EAAxB","sourcesContent":["import { color } from '@pie-lib/render-ui';\n\nconst noTouch = {\n '-webkit-touchCcallout': 'none',\n '-webkit-user-select': 'none',\n '-khtml-user-select': 'none',\n '-moz-user-select': 'none',\n '-ms-user-select': 'none',\n 'user-select': 'none',\n};\n\nexport default {\n root: {\n width: '100%',\n cursor: 'pointer',\n },\n content: {\n margin: '0 auto',\n textAlign: 'center',\n display: 'flex',\n },\n label: Object.assign(\n {\n width: 'fit-content',\n minWidth: '140px',\n // eslint-disable-next-line\n fontFamily: \"'Roboto', sans-serif\",\n height: '25px',\n lineHeight: '25px',\n verticalAlign: 'middle',\n color: `var(--correct-answer-toggle-label-color, ${color.text()})`,\n fontSize: '15px',\n fontWeight: 'normal',\n },\n noTouch,\n ),\n icon: {\n position: 'absolute',\n width: '25px',\n },\n iconHolder: {\n width: '25px',\n marginRight: '5px',\n },\n enter: {\n opacity: '0',\n },\n enterActive: {\n opacity: '1',\n transition: 'opacity 0.3s ease-in',\n },\n exit: {\n opacity: '1',\n },\n exitActive: {\n opacity: '0',\n transition: 'opacity 0.3s ease-in',\n },\n};\n\nexport const animationStyles = {};\n"],"file":"styles.js"}
1
+ {"version":3,"sources":["../src/styles.js"],"names":["noTouch","root","width","cursor","content","margin","textAlign","display","label","Object","assign","minWidth","fontFamily","alignSelf","verticalAlign","color","text","fontWeight","icon","position","iconHolder","marginRight","alignItems","enter","opacity","enterActive","transition","exit","exitActive","animationStyles"],"mappings":";;;;;;;AAAA;;AAEA,IAAMA,OAAO,GAAG;AACd,2BAAyB,MADX;AAEd,yBAAuB,MAFT;AAGd,wBAAsB,MAHR;AAId,sBAAoB,MAJN;AAKd,qBAAmB,MALL;AAMd,iBAAe;AAND,CAAhB;eASe;AACbC,EAAAA,IAAI,EAAE;AACJC,IAAAA,KAAK,EAAE,MADH;AAEJC,IAAAA,MAAM,EAAE;AAFJ,GADO;AAKbC,EAAAA,OAAO,EAAE;AACPC,IAAAA,MAAM,EAAE,QADD;AAEPC,IAAAA,SAAS,EAAE,QAFJ;AAGPC,IAAAA,OAAO,EAAE;AAHF,GALI;AAUbC,EAAAA,KAAK,EAAEC,MAAM,CAACC,MAAP,CACL;AACER,IAAAA,KAAK,EAAE,aADT;AAEES,IAAAA,QAAQ,EAAE,OAFZ;AAGE;AACAC,IAAAA,UAAU,EAAE,sBAJd;AAKEC,IAAAA,SAAS,EAAE,QALb;AAMEC,IAAAA,aAAa,EAAE,QANjB;AAOEC,IAAAA,KAAK,sDAA+CA,gBAAMC,IAAN,EAA/C,MAPP;AAQEC,IAAAA,UAAU,EAAE;AARd,GADK,EAWLjB,OAXK,CAVM;AAuBbkB,EAAAA,IAAI,EAAE;AACJC,IAAAA,QAAQ,EAAE,UADN;AAEJjB,IAAAA,KAAK,EAAE;AAFH,GAvBO;AA2BbkB,EAAAA,UAAU,EAAE;AACVlB,IAAAA,KAAK,EAAE,MADG;AAEVmB,IAAAA,WAAW,EAAE,KAFH;AAGVd,IAAAA,OAAO,EAAE,MAHC;AAIVe,IAAAA,UAAU,EAAE;AAJF,GA3BC;AAiCbC,EAAAA,KAAK,EAAE;AACLC,IAAAA,OAAO,EAAE;AADJ,GAjCM;AAoCbC,EAAAA,WAAW,EAAE;AACXD,IAAAA,OAAO,EAAE,GADE;AAEXE,IAAAA,UAAU,EAAE;AAFD,GApCA;AAwCbC,EAAAA,IAAI,EAAE;AACJH,IAAAA,OAAO,EAAE;AADL,GAxCO;AA2CbI,EAAAA,UAAU,EAAE;AACVJ,IAAAA,OAAO,EAAE,GADC;AAEVE,IAAAA,UAAU,EAAE;AAFF;AA3CC,C;;AAiDR,IAAMG,eAAe,GAAG,EAAxB","sourcesContent":["import { color } from '@pie-lib/render-ui';\n\nconst noTouch = {\n '-webkit-touchCcallout': 'none',\n '-webkit-user-select': 'none',\n '-khtml-user-select': 'none',\n '-moz-user-select': 'none',\n '-ms-user-select': 'none',\n 'user-select': 'none',\n};\n\nexport default {\n root: {\n width: '100%',\n cursor: 'pointer',\n },\n content: {\n margin: '0 auto',\n textAlign: 'center',\n display: 'flex',\n },\n label: Object.assign(\n {\n width: 'fit-content',\n minWidth: '140px',\n // eslint-disable-next-line\n fontFamily: \"'Roboto', sans-serif\",\n alignSelf: 'center',\n verticalAlign: 'middle',\n color: `var(--correct-answer-toggle-label-color, ${color.text()})`,\n fontWeight: 'normal',\n },\n noTouch,\n ),\n icon: {\n position: 'absolute',\n width: '25px',\n },\n iconHolder: {\n width: '25px',\n marginRight: '5px',\n display: 'flex',\n alignItems: 'center',\n },\n enter: {\n opacity: '0',\n },\n enterActive: {\n opacity: '1',\n transition: 'opacity 0.3s ease-in',\n },\n exit: {\n opacity: '1',\n },\n exitActive: {\n opacity: '0',\n transition: 'opacity 0.3s ease-in',\n },\n};\n\nexport const animationStyles = {};\n"],"file":"styles.js"}
package/package.json CHANGED
@@ -11,15 +11,15 @@
11
11
  "publishConfig": {
12
12
  "access": "public"
13
13
  },
14
- "version": "2.5.12-next.1+23991a09",
14
+ "version": "2.6.0-beta.1",
15
15
  "main": "lib/index.js",
16
16
  "module": "src/index.jsx",
17
17
  "scripts": {},
18
18
  "dependencies": {
19
19
  "@material-ui/core": "^3.8.3",
20
- "@pie-lib/icons": "^2.4.43",
21
- "@pie-lib/render-ui": "^4.15.10-next.1+23991a09",
22
- "@pie-lib/translator": "^2.3.0",
20
+ "@pie-lib/icons": "latest",
21
+ "@pie-lib/render-ui": "latest",
22
+ "@pie-lib/translator": "latest",
23
23
  "classnames": "^2.2.6",
24
24
  "lodash": "^4.17.11",
25
25
  "prop-types": "^15.6.2",
@@ -33,5 +33,5 @@
33
33
  "react": "^16.8.1",
34
34
  "react-dom": "^16.8.1"
35
35
  },
36
- "gitHead": "23991a09b77492c24dcb5235049667cdcc211d80"
36
+ "gitHead": "e2aa3ddac60f49bcb8c2562370f496323642f453"
37
37
  }
@@ -0,0 +1,99 @@
1
+ import { mount, shallow, configure } from 'enzyme';
2
+
3
+ import Expander from '../expander';
4
+ import React from 'react';
5
+ import { CorrectAnswerToggle } from '../index';
6
+ import Adapter from 'enzyme-adapter-react-16';
7
+
8
+ configure({ adapter: new Adapter() });
9
+
10
+ describe('CorrectAnswerToggle', () => {
11
+ let onToggle;
12
+ let wrapper;
13
+ let sheet;
14
+
15
+ let mkWrapper = (toggled, msgs) => {
16
+ toggled = toggled === false ? false : true;
17
+ msgs = msgs || {};
18
+ return shallow(
19
+ <CorrectAnswerToggle
20
+ toggled={toggled}
21
+ classes={{
22
+ root: 'root',
23
+ label: 'label',
24
+ }}
25
+ onToggle={onToggle}
26
+ hideMessage={msgs.hide}
27
+ showMessage={msgs.show}
28
+ sheet={sheet}
29
+ />,
30
+ {
31
+ context: {},
32
+ },
33
+ );
34
+ };
35
+
36
+ beforeEach(() => {
37
+ let iconStub = {};
38
+
39
+ sheet = {
40
+ classes: {
41
+ root: 'root',
42
+ label: 'label',
43
+ },
44
+ };
45
+ onToggle = jest.fn();
46
+ wrapper = mkWrapper();
47
+ });
48
+
49
+ describe('render', () => {
50
+ it('has the hide message', () => {
51
+ let holder = wrapper.find('.label');
52
+ expect(holder.text()).toEqual('Hide correct answer');
53
+ });
54
+
55
+ it('has show message when toggled is false', () => {
56
+ const w = mkWrapper(false);
57
+ let holder = w.find(`.label`);
58
+ expect(holder.text()).toEqual('Show correct answer');
59
+ });
60
+
61
+ it('sets a custom hide message', () => {
62
+ wrapper = mkWrapper(true, { hide: 'hide!' });
63
+ let holder = wrapper.find('.label');
64
+ expect(holder.text()).toEqual('hide!');
65
+ });
66
+
67
+ it('sets a custom show message', () => {
68
+ wrapper = mkWrapper(false, { show: 'show!' });
69
+ let holder = wrapper.find('.label');
70
+ expect(holder.text()).toEqual('show!');
71
+ });
72
+ });
73
+
74
+ describe('onClick', () => {
75
+ it('calls onToggle', () => {
76
+ wrapper
77
+ .find(Expander)
78
+ .childAt(0)
79
+ .simulate('click');
80
+ expect(onToggle.mock.calls[0][0]).toEqual(false);
81
+ });
82
+
83
+ it('calls onToggle with update state', () => {
84
+ onToggle.mockReset();
85
+ wrapper
86
+ .find(Expander)
87
+ .childAt(0)
88
+ .simulate('click');
89
+ expect(onToggle.mock.calls[0][0]).toEqual(false);
90
+ //simulate updating the toggled prop
91
+ wrapper.setProps({ toggled: false });
92
+ wrapper
93
+ .find(Expander)
94
+ .childAt(0)
95
+ .simulate('click');
96
+ expect(onToggle.mock.calls[1][0]).toEqual(true);
97
+ });
98
+ });
99
+ });
package/src/expander.jsx CHANGED
@@ -34,14 +34,16 @@ export default withStyles(() => ({
34
34
  enter: {
35
35
  transition,
36
36
  opacity: 1,
37
- height: '25px',
37
+ height: 'auto',
38
38
  width: 'auto',
39
39
  visibility: 'visible',
40
+ minHeight: '25px',
40
41
  },
41
42
  enterDone: {
42
- height: '25px',
43
+ height: 'auto',
43
44
  visibility: 'visible',
44
45
  width: 'auto',
46
+ minHeight: '25px',
45
47
  },
46
48
  exit: {
47
49
  transition,
package/src/index.jsx CHANGED
@@ -49,6 +49,10 @@ export class CorrectAnswerToggle extends React.Component {
49
49
  onClick() {
50
50
  this.props.onToggle(!this.props.toggled);
51
51
  }
52
+ onTouch(event) {
53
+ event.preventDefault(); // Prevents the default action (click event)
54
+ this.props.onToggle(!this.props.toggled);
55
+ }
52
56
 
53
57
  UNSAFE_componentWillReceiveProps(nextProps) {
54
58
  this.setState({
@@ -70,7 +74,7 @@ export class CorrectAnswerToggle extends React.Component {
70
74
  return (
71
75
  <div className={classNames(classes.root, className)}>
72
76
  <Expander show={this.state.show} className={classes.expander}>
73
- <div className={classes.content} onClick={this.onClick.bind(this)}>
77
+ <div className={classes.content} onClick={this.onClick.bind(this)} onTouchEnd={this.onTouch.bind(this)}>
74
78
  <div className={classes.iconHolder}>
75
79
  <CSSTransition timeout={400} in={toggled} exit={!toggled} classNames={classes}>
76
80
  <CorrectResponse open={toggled} key="correct-open" className={classes.icon} />
package/src/styles.js CHANGED
@@ -25,11 +25,9 @@ export default {
25
25
  minWidth: '140px',
26
26
  // eslint-disable-next-line
27
27
  fontFamily: "'Roboto', sans-serif",
28
- height: '25px',
29
- lineHeight: '25px',
28
+ alignSelf: 'center',
30
29
  verticalAlign: 'middle',
31
30
  color: `var(--correct-answer-toggle-label-color, ${color.text()})`,
32
- fontSize: '15px',
33
31
  fontWeight: 'normal',
34
32
  },
35
33
  noTouch,
@@ -41,6 +39,8 @@ export default {
41
39
  iconHolder: {
42
40
  width: '25px',
43
41
  marginRight: '5px',
42
+ display: 'flex',
43
+ alignItems: 'center',
44
44
  },
45
45
  enter: {
46
46
  opacity: '0',
package/README.md DELETED
@@ -1,64 +0,0 @@
1
- # corespring-correct-answer-toggle
2
-
3
- [![Build Status](https://travis-ci.org/PieLabs/corespring-correct-answer-toggle.svg?branch=develop)](https://travis-ci.org/PieLabs/corespring-correct-answer-toggle)
4
-
5
- A toggle with an icon and a label.
6
-
7
- ![Preview](preview.png)
8
-
9
- # Usage
10
-
11
- You need to include this in another library that builds react aka (babel).
12
-
13
- ## Webpack
14
-
15
- We assume that you have a loader that will load in `.less`. In the demo we use `style-loader!css-loader!less-loader`.
16
-
17
- ## Install
18
-
19
- ```shell
20
- npm install
21
- ```
22
- ## Test
23
-
24
- ```
25
- npm test
26
- ```
27
-
28
- ## Demo
29
-
30
- ```shell
31
- cd demo
32
- ../node_modules/.bin/webpack-dev-server --hot --inline
33
- # go to http://localhost:8080
34
- ```
35
-
36
- ### Usage
37
- ```javascript
38
-
39
- import Toggle from 'corespring-correct-answer-toggle';
40
-
41
- function onToggle(toggled){
42
- console.log('on toggle: ', toggled);
43
- }
44
-
45
- const MyComp = (props) => {
46
- return <div>
47
- <Toggle
48
- show={props.show}
49
- onToggle={onToggle}
50
- initialValue={false}/>
51
- </div>;
52
- }
53
- ```
54
-
55
- ## Release
56
-
57
- ```shell
58
- gulp release
59
- git checkout master
60
- npm publish
61
- ```
62
-
63
-
64
-
package/preview.png DELETED
Binary file