diff --git a/.storybook/__storyshots__/Toggle.shot b/.storybook/__storyshots__/Toggle.shot index e497ae7aa..c5e16a455 100644 --- a/.storybook/__storyshots__/Toggle.shot +++ b/.storybook/__storyshots__/Toggle.shot @@ -267,7 +267,7 @@ exports[`Checked`] = ` - checked + name other @@ -293,6 +293,20 @@ exports[`Checked`] = ` - + + + checked + + + other + + + no + + + - + + cols @@ -351,7 +365,7 @@ exports[`Checked`] = ` - name + required other @@ -365,7 +379,21 @@ exports[`Checked`] = ` - required + statusOff + + + other + + + no + + + - + + + + + statusOn other @@ -822,7 +850,7 @@ exports[`Controlled with knobs`] = ` - checked + name other @@ -848,6 +876,20 @@ exports[`Controlled with knobs`] = ` - + + + checked + + + other + + + no + + + - + + cols @@ -906,7 +948,7 @@ exports[`Controlled with knobs`] = ` - name + required other @@ -920,7 +962,21 @@ exports[`Controlled with knobs`] = ` - required + statusOff + + + other + + + no + + + - + + + + + statusOn other @@ -1231,7 +1287,7 @@ exports[`Default`] = ` - checked + name other @@ -1257,6 +1313,20 @@ exports[`Default`] = ` - + + + checked + + + other + + + no + + + - + + cols @@ -1315,7 +1385,7 @@ exports[`Default`] = ` - name + required other @@ -1329,7 +1399,21 @@ exports[`Default`] = ` - required + statusOff + + + other + + + no + + + - + + + + + statusOn other @@ -1648,7 +1732,7 @@ exports[`Disabled`] = ` - checked + name other @@ -1674,6 +1758,20 @@ exports[`Disabled`] = ` - + + + checked + + + other + + + no + + + - + + cols @@ -1732,7 +1830,7 @@ exports[`Disabled`] = ` - name + required other @@ -1746,7 +1844,506 @@ exports[`Disabled`] = ` - required + statusOff + + + other + + + no + + + - + + + + + statusOn + + + other + + + no + + + - + + + + + totalCols + + + other + + + no + + + - + + + + + value + + + other + + + no + + + - + + + + + + + + + + +`; + +exports[`Status`] = ` +
+
+
+
+
+

+ Toggle +

+

+ Status +

+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+

+ Toggle control with status of Off/On +

+
+
+

+ Story Source +

+
+            
+ + < + Toggle + + + + + + onChange + + + = + + + { + + anonymous() + + } + + + + + + + + statusOff + + + = + + + \" + Off + \" + + + + + + + + statusOn + + + = + + + \" + On + \" + + + + + + + + /> + +
+
+
+
+

+ Prop Types +

+
+

+ \" + Toggle + \" Component +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ property + + propType + + required + + default +
+ name + + other + + no + + - +
+ className + + other + + no + + - +
+ checked + + other + + no + + - +
+ cols + + other + + no + + - +
+ defaultChecked + + other + + no + + - +
+ error + + other + + no + + - +
+ label + + other + + no + + - +
+ required + + other + + no + + - +
+ statusOff + + other + + no + + - +
+ statusOn other diff --git a/NODE_ENV.cmd b/NODE_ENV.cmd new file mode 100644 index 000000000..a4d4237aa --- /dev/null +++ b/NODE_ENV.cmd @@ -0,0 +1 @@ +@set NODE_ENV=%1 diff --git a/package.json b/package.json index bd28fa2ad..bdd04cb20 100644 --- a/package.json +++ b/package.json @@ -22,13 +22,13 @@ "scripts": { "storybook": "start-storybook -s ./node_modules/@salesforce-ux/design-system -p 9001 -c .storybook", "test": "npm-run-all test:jest test:storyshots", - "test:storyshots": "NODE_ENV=test storyshots", + "test:storyshots": "NODE_ENV=test && storyshots", "test:jest": "jest", "prepublish": "npm run build", "lint": "npm run lint:src && npm run lint:stories && npm run lint:test", - "lint:src": "eslint --ext .js src/scripts/**", - "lint:stories": "eslint --ext .js stories/**", - "lint:test": "eslint --ext .js test/**", + "lint:src": "eslint --fix --ext .js src/scripts/**", + "lint:stories": "eslint --fix --ext .js stories/**", + "lint:test": "eslint --fix --ext .js test/**", "build": "babel -d lib/ src/", "build:assets": "cp -r node_modules/@salesforce-ux/design-system/assets public", "build:storybook": "build-storybook -o public", diff --git a/public/.gitignore b/public/.gitignore index ca83fcf2a..f004ad09a 100644 --- a/public/.gitignore +++ b/public/.gitignore @@ -1,4 +1,4 @@ *.html *.ico assets -static +static \ No newline at end of file diff --git a/src/scripts/Toggle.js b/src/scripts/Toggle.js index d1aae6eee..9d0ef20d8 100644 --- a/src/scripts/Toggle.js +++ b/src/scripts/Toggle.js @@ -5,7 +5,7 @@ import classnames from 'classnames'; import FormElement from './FormElement'; export default class Toggle extends Component { - renderToggle({ className, label, ...props }) { + renderToggle({ className, label, statusOff, statusOn, ...props }) { const toggleClassNames = classnames(className, 'slds-checkbox--toggle slds-grid'); return ( ); @@ -57,4 +57,6 @@ Toggle.propTypes = { ]), checked: PropTypes.bool, defaultChecked: PropTypes.bool, + statusOff: PropTypes.string, + statusOn: PropTypes.string, }; diff --git a/stories/ToggleStories.js b/stories/ToggleStories.js index b1d722499..6311992c2 100644 --- a/stories/ToggleStories.js +++ b/stories/ToggleStories.js @@ -23,4 +23,7 @@ storiesOf('Toggle', module) .addWithInfo('Disabled', 'Toggle control with disabled status', () => ( )) + .addWithInfo('Status', 'Toggle control with status of Off/On', () => ( + + )) ;