@flodesk/grain 5.7.0 → 5.7.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/es/components/switch.js +8 -13
- package/package.json +1 -1
package/es/components/switch.js
CHANGED
|
@@ -6,7 +6,7 @@ import "core-js/modules/es.array.index-of.js";
|
|
|
6
6
|
import "core-js/modules/es.symbol.js";
|
|
7
7
|
var _excluded = ["isDisabled", "isActive", "label", "id", "onChange"];
|
|
8
8
|
|
|
9
|
-
var _templateObject, _templateObject2, _templateObject3
|
|
9
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
10
10
|
|
|
11
11
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
12
12
|
|
|
@@ -24,16 +24,15 @@ var trackWidth = 40;
|
|
|
24
24
|
var trackHeight = knobSizePx + trackOffset * 2;
|
|
25
25
|
var trackInactiveColor = getColor('grey3');
|
|
26
26
|
var trackActiveColor = getColor('content');
|
|
27
|
-
var Input = styled.input(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n
|
|
27
|
+
var Input = styled.input(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n appearance: none;\n height: ", "px;\n width: ", "px;\n background-color: ", ";\n display: block;\n border-radius: 1000px;\n transition: ", ";\n cursor: pointer;\n margin: 0;\n\n &:checked {\n background-color: ", ";\n\n & ~ .Knob {\n transform: translateX(", "px);\n }\n }\n"])), trackHeight, trackWidth, function (p) {
|
|
28
|
+
return p.isDisabled ? getColor('backgroundDisabled') : trackInactiveColor;
|
|
29
|
+
}, getTransition('xFast'), function (p) {
|
|
28
30
|
return p.disabled ? getColor('backgroundDisabled') : trackActiveColor;
|
|
29
31
|
}, trackWidth - knobSizePx - trackOffset * 2);
|
|
30
|
-
var
|
|
31
|
-
return p.isDisabled ? getColor('backgroundDisabled') : trackInactiveColor;
|
|
32
|
-
});
|
|
33
|
-
var Knob = styled.span(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n position: absolute;\n left: ", "px;\n top: ", "px;\n height: ", "px;\n width: ", "px;\n border-radius: 100%;\n background-color: ", ";\n display: block;\n transition: ", ";\n"])), trackOffset, trackOffset, knobSizePx, knobSizePx, function (p) {
|
|
32
|
+
var Knob = styled.span(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: absolute;\n left: ", "px;\n top: ", "px;\n height: ", "px;\n width: ", "px;\n border-radius: 100%;\n background-color: ", ";\n display: block;\n transition: ", ";\n pointer-events: none;\n"])), trackOffset, trackOffset, knobSizePx, knobSizePx, function (p) {
|
|
34
33
|
return p.isDisabled ? getColor('contentDisabled') : 'white';
|
|
35
34
|
}, getTransition('xFast'));
|
|
36
|
-
var Wrapper = styled.div(
|
|
35
|
+
var Wrapper = styled.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: grid;\n grid-auto-flow: column;\n align-items: center;\n width: fit-content;\n gap: 8px;\n position: relative;\n"])));
|
|
37
36
|
export var Switch = function Switch(_ref) {
|
|
38
37
|
var isDisabled = _ref.isDisabled,
|
|
39
38
|
isActive = _ref.isActive,
|
|
@@ -48,14 +47,10 @@ export var Switch = function Switch(_ref) {
|
|
|
48
47
|
id: id,
|
|
49
48
|
checked: isActive,
|
|
50
49
|
onChange: onChange
|
|
51
|
-
}), /*#__PURE__*/React.createElement(
|
|
52
|
-
htmlFor: id,
|
|
53
|
-
className: "Track",
|
|
54
|
-
isDisabled: isDisabled
|
|
55
|
-
}, /*#__PURE__*/React.createElement(Knob, {
|
|
50
|
+
}), /*#__PURE__*/React.createElement(Knob, {
|
|
56
51
|
className: "Knob",
|
|
57
52
|
isDisabled: isDisabled
|
|
58
|
-
})
|
|
53
|
+
}), label && /*#__PURE__*/React.createElement("label", {
|
|
59
54
|
htmlFor: id
|
|
60
55
|
}, label));
|
|
61
56
|
};
|