@pareto-engineering/design-system 4.0.0-alpha.54 → 4.0.0-alpha.56
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/dist/cjs/a/SnapScroller/styles.scss +2 -1
- package/dist/cjs/a/ToggleSwitch/ToggleSwitch.js +82 -0
- package/dist/cjs/a/ToggleSwitch/index.js +13 -0
- package/dist/cjs/a/ToggleSwitch/styles.scss +51 -0
- package/dist/cjs/a/index.js +8 -1
- package/dist/cjs/b/ThemeSelector/ThemeSelector.js +4 -10
- package/dist/es/a/SnapScroller/styles.scss +2 -1
- package/dist/es/a/ToggleSwitch/ToggleSwitch.js +74 -0
- package/dist/es/a/ToggleSwitch/index.js +2 -0
- package/dist/es/a/ToggleSwitch/styles.scss +51 -0
- package/dist/es/a/index.js +2 -1
- package/dist/es/b/ThemeSelector/ThemeSelector.js +5 -11
- package/package.json +3 -3
- package/src/stories/a/ToggleSwitch.stories.jsx +22 -0
- package/src/ui/a/SnapScroller/styles.scss +2 -1
- package/src/ui/a/ToggleSwitch/ToggleSwitch.jsx +95 -0
- package/src/ui/a/ToggleSwitch/index.js +2 -0
- package/src/ui/a/ToggleSwitch/styles.scss +51 -0
- package/src/ui/a/index.js +1 -0
- package/src/ui/b/ThemeSelector/ThemeSelector.jsx +2 -9
- package/tests/__snapshots__/Storyshots.test.js.snap +26 -0
|
@@ -42,10 +42,11 @@ $default-spacing: var(--gap);
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
@include mixins.media($from: $sm-md) {
|
|
45
|
+
scroll-snap-type: none;
|
|
46
|
+
|
|
45
47
|
&.desktop-no-scroll {
|
|
46
48
|
overflow: auto;
|
|
47
49
|
-ms-overflow-style: unset;
|
|
48
|
-
scroll-snap-type: none;
|
|
49
50
|
scrollbar-width: unset;
|
|
50
51
|
|
|
51
52
|
&::after {
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _exports = _interopRequireDefault(require("@pareto-engineering/bem/exports"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
12
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } /* @pareto-engineering/generator-front 1.0.12 */
|
|
13
|
+
// Local Definitions
|
|
14
|
+
|
|
15
|
+
const baseClassName = _exports.default.base;
|
|
16
|
+
const componentClassName = 'toggle-switch';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* This is the component description.
|
|
20
|
+
*/
|
|
21
|
+
const ToggleSwitch = _ref => {
|
|
22
|
+
let {
|
|
23
|
+
id,
|
|
24
|
+
className: userClassName,
|
|
25
|
+
style,
|
|
26
|
+
handleOnClick,
|
|
27
|
+
checked,
|
|
28
|
+
size
|
|
29
|
+
// ...otherProps
|
|
30
|
+
} = _ref;
|
|
31
|
+
(0, React.useInsertionEffect)(() => {
|
|
32
|
+
Promise.resolve().then(() => _interopRequireWildcard(require("./styles.scss")));
|
|
33
|
+
}, []);
|
|
34
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
35
|
+
id: id,
|
|
36
|
+
className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
|
|
37
|
+
style: {
|
|
38
|
+
'--size': size,
|
|
39
|
+
...style
|
|
40
|
+
},
|
|
41
|
+
onClick: handleOnClick,
|
|
42
|
+
type: "button"
|
|
43
|
+
// {...otherProps}
|
|
44
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
45
|
+
type: "checkbox",
|
|
46
|
+
id: "switch",
|
|
47
|
+
checked: checked
|
|
48
|
+
}), /*#__PURE__*/React.createElement("label", {
|
|
49
|
+
htmlFor: "switch"
|
|
50
|
+
}));
|
|
51
|
+
};
|
|
52
|
+
ToggleSwitch.propTypes = {
|
|
53
|
+
/**
|
|
54
|
+
* The HTML id for this element
|
|
55
|
+
*/
|
|
56
|
+
id: _propTypes.default.string,
|
|
57
|
+
/**
|
|
58
|
+
* The HTML class names for this element
|
|
59
|
+
*/
|
|
60
|
+
className: _propTypes.default.string,
|
|
61
|
+
/**
|
|
62
|
+
* The React-written, css properties for this element.
|
|
63
|
+
*/
|
|
64
|
+
style: _propTypes.default.objectOf(_propTypes.default.string),
|
|
65
|
+
/**
|
|
66
|
+
* The onClick handler for this element
|
|
67
|
+
*/
|
|
68
|
+
handleOnClick: _propTypes.default.func,
|
|
69
|
+
/**
|
|
70
|
+
* The checked state of this element
|
|
71
|
+
*/
|
|
72
|
+
checked: _propTypes.default.bool,
|
|
73
|
+
/**
|
|
74
|
+
* The size of this element
|
|
75
|
+
*/
|
|
76
|
+
size: _propTypes.default.string
|
|
77
|
+
};
|
|
78
|
+
ToggleSwitch.defaultProps = {
|
|
79
|
+
// someProp:false,
|
|
80
|
+
};
|
|
81
|
+
var _default = ToggleSwitch;
|
|
82
|
+
exports.default = _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "ToggleSwitch", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _ToggleSwitch.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _ToggleSwitch = _interopRequireDefault(require("./ToggleSwitch"));
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
2
|
+
|
|
3
|
+
@use "@pareto-engineering/bem";
|
|
4
|
+
|
|
5
|
+
$default-border-radius: var(--theme-default-border-radius);
|
|
6
|
+
$default-size: var(--size, 1.2em);
|
|
7
|
+
$default-slider-color: var(--slider-color, var(--background-far));
|
|
8
|
+
$default-slider-border-color: var(--slider-border-color, var(--ui-lines));
|
|
9
|
+
$default-background-color: var(--slider-background-color, var(--interactive));
|
|
10
|
+
|
|
11
|
+
.#{bem.$base}.toggle-switch {
|
|
12
|
+
background: transparent;
|
|
13
|
+
border: none;
|
|
14
|
+
cursor: pointer;
|
|
15
|
+
display: flex;
|
|
16
|
+
|
|
17
|
+
>input {
|
|
18
|
+
height: 0;
|
|
19
|
+
visibility: hidden;
|
|
20
|
+
width: 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
>label {
|
|
24
|
+
background: $default-background-color;
|
|
25
|
+
border-radius: $default-border-radius;
|
|
26
|
+
cursor: pointer;
|
|
27
|
+
display: block;
|
|
28
|
+
height: $default-size;
|
|
29
|
+
position: relative;
|
|
30
|
+
width: calc($default-size * 2);
|
|
31
|
+
|
|
32
|
+
&::after {
|
|
33
|
+
background: $default-slider-color;
|
|
34
|
+
border: 1px solid $default-slider-border-color;
|
|
35
|
+
border-radius: $default-border-radius;
|
|
36
|
+
content: "";
|
|
37
|
+
height: $default-size;
|
|
38
|
+
left: 0;
|
|
39
|
+
position: absolute;
|
|
40
|
+
top: 0;
|
|
41
|
+
transition: .3s;
|
|
42
|
+
width: $default-size;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
>input:checked + label::after {
|
|
47
|
+
left: $default-size;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
package/dist/cjs/a/index.js
CHANGED
|
@@ -153,6 +153,12 @@ Object.defineProperty(exports, "Tip", {
|
|
|
153
153
|
return _Tip.Tip;
|
|
154
154
|
}
|
|
155
155
|
});
|
|
156
|
+
Object.defineProperty(exports, "ToggleSwitch", {
|
|
157
|
+
enumerable: true,
|
|
158
|
+
get: function () {
|
|
159
|
+
return _ToggleSwitch.ToggleSwitch;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
156
162
|
Object.defineProperty(exports, "useApp", {
|
|
157
163
|
enumerable: true,
|
|
158
164
|
get: function () {
|
|
@@ -188,4 +194,5 @@ var _AnimatedBlobs = require("./AnimatedBlobs");
|
|
|
188
194
|
var _Tip = require("./Tip");
|
|
189
195
|
var _AnimatedGradient = require("./AnimatedGradient");
|
|
190
196
|
var _TextSteps = require("./TextSteps");
|
|
191
|
-
var _Removable = require("./Removable");
|
|
197
|
+
var _Removable = require("./Removable");
|
|
198
|
+
var _ToggleSwitch = require("./ToggleSwitch");
|
|
@@ -43,16 +43,10 @@ const ThemeSelector = _ref => {
|
|
|
43
43
|
style: style
|
|
44
44
|
}, /*#__PURE__*/React.createElement("span", {
|
|
45
45
|
className: "c-x x-paragraph"
|
|
46
|
-
}, userTheme && userTheme[0].toUpperCase() + userTheme.slice(1), ' ', "Theme"), /*#__PURE__*/React.createElement(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
type: "checkbox",
|
|
51
|
-
id: "switch",
|
|
52
|
-
checked: userTheme === 'dark'
|
|
53
|
-
}), /*#__PURE__*/React.createElement("label", {
|
|
54
|
-
htmlFor: "switch"
|
|
55
|
-
})));
|
|
46
|
+
}, userTheme && userTheme[0].toUpperCase() + userTheme.slice(1), ' ', "Theme"), /*#__PURE__*/React.createElement(_a.ToggleSwitch, {
|
|
47
|
+
checked: userTheme === 'dark',
|
|
48
|
+
handleOnClick: loopThemes
|
|
49
|
+
}));
|
|
56
50
|
};
|
|
57
51
|
ThemeSelector.propTypes = {
|
|
58
52
|
/**
|
|
@@ -42,10 +42,11 @@ $default-spacing: var(--gap);
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
@include mixins.media($from: $sm-md) {
|
|
45
|
+
scroll-snap-type: none;
|
|
46
|
+
|
|
45
47
|
&.desktop-no-scroll {
|
|
46
48
|
overflow: auto;
|
|
47
49
|
-ms-overflow-style: unset;
|
|
48
|
-
scroll-snap-type: none;
|
|
49
50
|
scrollbar-width: unset;
|
|
50
51
|
|
|
51
52
|
&::after {
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useInsertionEffect } from 'react';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import styleNames from '@pareto-engineering/bem/exports';
|
|
6
|
+
|
|
7
|
+
// Local Definitions
|
|
8
|
+
|
|
9
|
+
const baseClassName = styleNames.base;
|
|
10
|
+
const componentClassName = 'toggle-switch';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* This is the component description.
|
|
14
|
+
*/
|
|
15
|
+
const ToggleSwitch = ({
|
|
16
|
+
id,
|
|
17
|
+
className: userClassName,
|
|
18
|
+
style,
|
|
19
|
+
handleOnClick,
|
|
20
|
+
checked,
|
|
21
|
+
size
|
|
22
|
+
// ...otherProps
|
|
23
|
+
}) => {
|
|
24
|
+
useInsertionEffect(() => {
|
|
25
|
+
import("./styles.scss");
|
|
26
|
+
}, []);
|
|
27
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
28
|
+
id: id,
|
|
29
|
+
className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
|
|
30
|
+
style: {
|
|
31
|
+
'--size': size,
|
|
32
|
+
...style
|
|
33
|
+
},
|
|
34
|
+
onClick: handleOnClick,
|
|
35
|
+
type: "button"
|
|
36
|
+
// {...otherProps}
|
|
37
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
38
|
+
type: "checkbox",
|
|
39
|
+
id: "switch",
|
|
40
|
+
checked: checked
|
|
41
|
+
}), /*#__PURE__*/React.createElement("label", {
|
|
42
|
+
htmlFor: "switch"
|
|
43
|
+
}));
|
|
44
|
+
};
|
|
45
|
+
ToggleSwitch.propTypes = {
|
|
46
|
+
/**
|
|
47
|
+
* The HTML id for this element
|
|
48
|
+
*/
|
|
49
|
+
id: PropTypes.string,
|
|
50
|
+
/**
|
|
51
|
+
* The HTML class names for this element
|
|
52
|
+
*/
|
|
53
|
+
className: PropTypes.string,
|
|
54
|
+
/**
|
|
55
|
+
* The React-written, css properties for this element.
|
|
56
|
+
*/
|
|
57
|
+
style: PropTypes.objectOf(PropTypes.string),
|
|
58
|
+
/**
|
|
59
|
+
* The onClick handler for this element
|
|
60
|
+
*/
|
|
61
|
+
handleOnClick: PropTypes.func,
|
|
62
|
+
/**
|
|
63
|
+
* The checked state of this element
|
|
64
|
+
*/
|
|
65
|
+
checked: PropTypes.bool,
|
|
66
|
+
/**
|
|
67
|
+
* The size of this element
|
|
68
|
+
*/
|
|
69
|
+
size: PropTypes.string
|
|
70
|
+
};
|
|
71
|
+
ToggleSwitch.defaultProps = {
|
|
72
|
+
// someProp:false,
|
|
73
|
+
};
|
|
74
|
+
export default ToggleSwitch;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
2
|
+
|
|
3
|
+
@use "@pareto-engineering/bem";
|
|
4
|
+
|
|
5
|
+
$default-border-radius: var(--theme-default-border-radius);
|
|
6
|
+
$default-size: var(--size, 1.2em);
|
|
7
|
+
$default-slider-color: var(--slider-color, var(--background-far));
|
|
8
|
+
$default-slider-border-color: var(--slider-border-color, var(--ui-lines));
|
|
9
|
+
$default-background-color: var(--slider-background-color, var(--interactive));
|
|
10
|
+
|
|
11
|
+
.#{bem.$base}.toggle-switch {
|
|
12
|
+
background: transparent;
|
|
13
|
+
border: none;
|
|
14
|
+
cursor: pointer;
|
|
15
|
+
display: flex;
|
|
16
|
+
|
|
17
|
+
>input {
|
|
18
|
+
height: 0;
|
|
19
|
+
visibility: hidden;
|
|
20
|
+
width: 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
>label {
|
|
24
|
+
background: $default-background-color;
|
|
25
|
+
border-radius: $default-border-radius;
|
|
26
|
+
cursor: pointer;
|
|
27
|
+
display: block;
|
|
28
|
+
height: $default-size;
|
|
29
|
+
position: relative;
|
|
30
|
+
width: calc($default-size * 2);
|
|
31
|
+
|
|
32
|
+
&::after {
|
|
33
|
+
background: $default-slider-color;
|
|
34
|
+
border: 1px solid $default-slider-border-color;
|
|
35
|
+
border-radius: $default-border-radius;
|
|
36
|
+
content: "";
|
|
37
|
+
height: $default-size;
|
|
38
|
+
left: 0;
|
|
39
|
+
position: absolute;
|
|
40
|
+
top: 0;
|
|
41
|
+
transition: .3s;
|
|
42
|
+
width: $default-size;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
>input:checked + label::after {
|
|
47
|
+
left: $default-size;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
package/dist/es/a/index.js
CHANGED
|
@@ -21,4 +21,5 @@ export { AnimatedBlobs } from "./AnimatedBlobs";
|
|
|
21
21
|
export { Tip } from "./Tip";
|
|
22
22
|
export { AnimatedGradient } from "./AnimatedGradient";
|
|
23
23
|
export { TextSteps } from "./TextSteps";
|
|
24
|
-
export { Removable } from "./Removable";
|
|
24
|
+
export { Removable } from "./Removable";
|
|
25
|
+
export { ToggleSwitch } from "./ToggleSwitch";
|
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import { useInsertionEffect, useCallback } from 'react';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import styleNames from '@pareto-engineering/bem/exports';
|
|
6
|
-
import { useApp } from "../../a";
|
|
6
|
+
import { useApp, ToggleSwitch } from "../../a";
|
|
7
7
|
|
|
8
8
|
// Local Definitions
|
|
9
9
|
|
|
@@ -36,16 +36,10 @@ const ThemeSelector = ({
|
|
|
36
36
|
style: style
|
|
37
37
|
}, /*#__PURE__*/React.createElement("span", {
|
|
38
38
|
className: "c-x x-paragraph"
|
|
39
|
-
}, userTheme && userTheme[0].toUpperCase() + userTheme.slice(1), ' ', "Theme"), /*#__PURE__*/React.createElement(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
type: "checkbox",
|
|
44
|
-
id: "switch",
|
|
45
|
-
checked: userTheme === 'dark'
|
|
46
|
-
}), /*#__PURE__*/React.createElement("label", {
|
|
47
|
-
htmlFor: "switch"
|
|
48
|
-
})));
|
|
39
|
+
}, userTheme && userTheme[0].toUpperCase() + userTheme.slice(1), ' ', "Theme"), /*#__PURE__*/React.createElement(ToggleSwitch, {
|
|
40
|
+
checked: userTheme === 'dark',
|
|
41
|
+
handleOnClick: loopThemes
|
|
42
|
+
}));
|
|
49
43
|
};
|
|
50
44
|
ThemeSelector.propTypes = {
|
|
51
45
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pareto-engineering/design-system",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.56",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/es/index.js",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@lexical/react": "^0.11.3",
|
|
54
54
|
"@pareto-engineering/assets": "^4.0.0-alpha.54",
|
|
55
55
|
"@pareto-engineering/bem": "^4.0.0-alpha.20",
|
|
56
|
-
"@pareto-engineering/styles": "^4.0.0-alpha.
|
|
56
|
+
"@pareto-engineering/styles": "^4.0.0-alpha.55",
|
|
57
57
|
"@pareto-engineering/utils": "^4.0.0-alpha.46",
|
|
58
58
|
"date-fns": "^2.29.3",
|
|
59
59
|
"downshift": "^6.1.12",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"relay-test-utils": "^15.0.0"
|
|
71
71
|
},
|
|
72
72
|
"browserslist": "> 2%",
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "b6da07b4268743142591d63580db20da7581ee8b"
|
|
74
74
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
2
|
+
import * as React from 'react'
|
|
3
|
+
|
|
4
|
+
import { ToggleSwitch } from 'ui'
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title :'a/ToggleSwitch',
|
|
8
|
+
component :ToggleSwitch,
|
|
9
|
+
subcomponents:{
|
|
10
|
+
// Item:ToggleSwitch.Item
|
|
11
|
+
},
|
|
12
|
+
decorators:[
|
|
13
|
+
// storyfn => <div className="">{ storyfn() }</div>,
|
|
14
|
+
],
|
|
15
|
+
argTypes:{
|
|
16
|
+
size:{ control: 'string' },
|
|
17
|
+
},
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const Base = () => (
|
|
21
|
+
<ToggleSwitch />
|
|
22
|
+
)
|
|
@@ -42,10 +42,11 @@ $default-spacing: var(--gap);
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
@include mixins.media($from: $sm-md) {
|
|
45
|
+
scroll-snap-type: none;
|
|
46
|
+
|
|
45
47
|
&.desktop-no-scroll {
|
|
46
48
|
overflow: auto;
|
|
47
49
|
-ms-overflow-style: unset;
|
|
48
|
-
scroll-snap-type: none;
|
|
49
50
|
scrollbar-width: unset;
|
|
50
51
|
|
|
51
52
|
&::after {
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
2
|
+
import * as React from 'react'
|
|
3
|
+
|
|
4
|
+
import { useInsertionEffect } from 'react'
|
|
5
|
+
|
|
6
|
+
import PropTypes from 'prop-types'
|
|
7
|
+
|
|
8
|
+
import styleNames from '@pareto-engineering/bem/exports'
|
|
9
|
+
|
|
10
|
+
// Local Definitions
|
|
11
|
+
|
|
12
|
+
const baseClassName = styleNames.base
|
|
13
|
+
|
|
14
|
+
const componentClassName = 'toggle-switch'
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* This is the component description.
|
|
18
|
+
*/
|
|
19
|
+
const ToggleSwitch = ({
|
|
20
|
+
id,
|
|
21
|
+
className:userClassName,
|
|
22
|
+
style,
|
|
23
|
+
handleOnClick,
|
|
24
|
+
checked,
|
|
25
|
+
size,
|
|
26
|
+
// ...otherProps
|
|
27
|
+
}) => {
|
|
28
|
+
useInsertionEffect(() => {
|
|
29
|
+
import('./styles.scss')
|
|
30
|
+
}, [])
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<button
|
|
34
|
+
id={id}
|
|
35
|
+
className={[
|
|
36
|
+
|
|
37
|
+
baseClassName,
|
|
38
|
+
|
|
39
|
+
componentClassName,
|
|
40
|
+
userClassName,
|
|
41
|
+
]
|
|
42
|
+
.filter((e) => e)
|
|
43
|
+
.join(' ')}
|
|
44
|
+
style={{
|
|
45
|
+
'--size':size,
|
|
46
|
+
...style,
|
|
47
|
+
}}
|
|
48
|
+
onClick={handleOnClick}
|
|
49
|
+
type="button"
|
|
50
|
+
// {...otherProps}
|
|
51
|
+
>
|
|
52
|
+
<input type="checkbox" id="switch" checked={checked} />
|
|
53
|
+
{/* eslint-disable-next-line jsx-a11y/label-has-associated-control */}
|
|
54
|
+
<label htmlFor="switch" />
|
|
55
|
+
</button>
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
ToggleSwitch.propTypes = {
|
|
60
|
+
/**
|
|
61
|
+
* The HTML id for this element
|
|
62
|
+
*/
|
|
63
|
+
id:PropTypes.string,
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The HTML class names for this element
|
|
67
|
+
*/
|
|
68
|
+
className:PropTypes.string,
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The React-written, css properties for this element.
|
|
72
|
+
*/
|
|
73
|
+
style:PropTypes.objectOf(PropTypes.string),
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The onClick handler for this element
|
|
77
|
+
*/
|
|
78
|
+
handleOnClick:PropTypes.func,
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* The checked state of this element
|
|
82
|
+
*/
|
|
83
|
+
checked:PropTypes.bool,
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The size of this element
|
|
87
|
+
*/
|
|
88
|
+
size:PropTypes.string,
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
ToggleSwitch.defaultProps = {
|
|
92
|
+
// someProp:false,
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export default ToggleSwitch
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
2
|
+
|
|
3
|
+
@use "@pareto-engineering/bem";
|
|
4
|
+
|
|
5
|
+
$default-border-radius: var(--theme-default-border-radius);
|
|
6
|
+
$default-size: var(--size, 1.2em);
|
|
7
|
+
$default-slider-color: var(--slider-color, var(--background-far));
|
|
8
|
+
$default-slider-border-color: var(--slider-border-color, var(--ui-lines));
|
|
9
|
+
$default-background-color: var(--slider-background-color, var(--interactive));
|
|
10
|
+
|
|
11
|
+
.#{bem.$base}.toggle-switch {
|
|
12
|
+
background: transparent;
|
|
13
|
+
border: none;
|
|
14
|
+
cursor: pointer;
|
|
15
|
+
display: flex;
|
|
16
|
+
|
|
17
|
+
>input {
|
|
18
|
+
height: 0;
|
|
19
|
+
visibility: hidden;
|
|
20
|
+
width: 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
>label {
|
|
24
|
+
background: $default-background-color;
|
|
25
|
+
border-radius: $default-border-radius;
|
|
26
|
+
cursor: pointer;
|
|
27
|
+
display: block;
|
|
28
|
+
height: $default-size;
|
|
29
|
+
position: relative;
|
|
30
|
+
width: calc($default-size * 2);
|
|
31
|
+
|
|
32
|
+
&::after {
|
|
33
|
+
background: $default-slider-color;
|
|
34
|
+
border: 1px solid $default-slider-border-color;
|
|
35
|
+
border-radius: $default-border-radius;
|
|
36
|
+
content: "";
|
|
37
|
+
height: $default-size;
|
|
38
|
+
left: 0;
|
|
39
|
+
position: absolute;
|
|
40
|
+
top: 0;
|
|
41
|
+
transition: .3s;
|
|
42
|
+
width: $default-size;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
>input:checked + label::after {
|
|
47
|
+
left: $default-size;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
package/src/ui/a/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { useInsertionEffect, useCallback } from 'react'
|
|
|
4
4
|
import PropTypes from 'prop-types'
|
|
5
5
|
import styleNames from '@pareto-engineering/bem/exports'
|
|
6
6
|
|
|
7
|
-
import { useApp } from 'ui/a'
|
|
7
|
+
import { useApp, ToggleSwitch } from 'ui/a'
|
|
8
8
|
|
|
9
9
|
// Local Definitions
|
|
10
10
|
|
|
@@ -53,14 +53,7 @@ const ThemeSelector = ({
|
|
|
53
53
|
{' '}
|
|
54
54
|
Theme
|
|
55
55
|
</span>
|
|
56
|
-
<
|
|
57
|
-
type="button"
|
|
58
|
-
onClick={loopThemes}
|
|
59
|
-
>
|
|
60
|
-
<input type="checkbox" id="switch" checked={userTheme === 'dark'} />
|
|
61
|
-
{/* eslint-disable-next-line jsx-a11y/label-has-associated-control */}
|
|
62
|
-
<label htmlFor="switch" />
|
|
63
|
-
</button>
|
|
56
|
+
<ToggleSwitch checked={userTheme === 'dark'} handleOnClick={loopThemes} />
|
|
64
57
|
</div>
|
|
65
58
|
)
|
|
66
59
|
}
|
|
@@ -3238,6 +3238,26 @@ exports[`Storyshots a/Tip Base 1`] = `
|
|
|
3238
3238
|
</p>
|
|
3239
3239
|
`;
|
|
3240
3240
|
|
|
3241
|
+
exports[`Storyshots a/ToggleSwitch Base 1`] = `
|
|
3242
|
+
<button
|
|
3243
|
+
className="base toggle-switch"
|
|
3244
|
+
style={
|
|
3245
|
+
{
|
|
3246
|
+
"--size": undefined,
|
|
3247
|
+
}
|
|
3248
|
+
}
|
|
3249
|
+
type="button"
|
|
3250
|
+
>
|
|
3251
|
+
<input
|
|
3252
|
+
id="switch"
|
|
3253
|
+
type="checkbox"
|
|
3254
|
+
/>
|
|
3255
|
+
<label
|
|
3256
|
+
htmlFor="switch"
|
|
3257
|
+
/>
|
|
3258
|
+
</button>
|
|
3259
|
+
`;
|
|
3260
|
+
|
|
3241
3261
|
exports[`Storyshots b/Button Arrow Left 1`] = `
|
|
3242
3262
|
[
|
|
3243
3263
|
<button
|
|
@@ -13937,7 +13957,13 @@ exports[`Storyshots b/ThemeSelector Base 1`] = `
|
|
|
13937
13957
|
Theme
|
|
13938
13958
|
</span>
|
|
13939
13959
|
<button
|
|
13960
|
+
className="base toggle-switch"
|
|
13940
13961
|
onClick={[Function]}
|
|
13962
|
+
style={
|
|
13963
|
+
{
|
|
13964
|
+
"--size": undefined,
|
|
13965
|
+
}
|
|
13966
|
+
}
|
|
13941
13967
|
type="button"
|
|
13942
13968
|
>
|
|
13943
13969
|
<input
|