sag_components 1.0.2 → 1.0.4

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/App.js CHANGED
@@ -5,10 +5,13 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
8
9
  var _logo = _interopRequireDefault(require("./logo.svg"));
9
10
  require("./App.css");
10
- var _Button = require("./stories/Button");
11
- var _Dropdown = _interopRequireDefault(require("./stories/Dropdown"));
11
+ var _react = require("react");
12
+ var _Button = _interopRequireDefault(require("./stories/components/Button"));
13
+ var _Dropdown = _interopRequireDefault(require("./stories/components/Dropdown"));
14
+ var _SegmentedButton = _interopRequireDefault(require("./stories/components/SegmentedButton"));
12
15
  var onChangehandler = function onChangehandler(event, newValue) {
13
16
  console.log("Dropdown onChange event returned:");
14
17
  console.log(newValue);
@@ -46,6 +49,34 @@ function App() {
46
49
  id: "9",
47
50
  label: "South Eastern Grocers"
48
51
  }];
52
+ var segmentsArr1 = [{
53
+ label: "Complete",
54
+ value: "complete"
55
+ }, {
56
+ label: "Incomplete",
57
+ value: "incomplete"
58
+ }, {
59
+ label: "Pending",
60
+ value: "pending"
61
+ }];
62
+ var segmentsArr2 = [{
63
+ label: "First",
64
+ value: "first"
65
+ }, {
66
+ label: "Second",
67
+ value: "second"
68
+ }, {
69
+ label: "Third",
70
+ value: "third"
71
+ }];
72
+ var _useState = (0, _react.useState)("complete"),
73
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
74
+ selectedValue1 = _useState2[0],
75
+ setSelectedValue1 = _useState2[1];
76
+ var _useState3 = (0, _react.useState)("complete"),
77
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
78
+ selectedValue2 = _useState4[0],
79
+ setSelectedValue2 = _useState4[1];
49
80
  return /*#__PURE__*/React.createElement("div", {
50
81
  className: "App"
51
82
  }, /*#__PURE__*/React.createElement(_Dropdown.default, {
@@ -66,7 +97,24 @@ function App() {
66
97
  shape: "round",
67
98
  onChange: onChangehandler,
68
99
  onInputChange: onInputChangeHandler
69
- }));
100
+ }), /*#__PURE__*/React.createElement(_SegmentedButton.default, {
101
+ name: "group1",
102
+ onClick: function onClick(val) {
103
+ return setSelectedValue1(val);
104
+ },
105
+ segments: segmentsArr1
106
+ }), /*#__PURE__*/React.createElement("p", {
107
+ className: "selected-item"
108
+ }, "Selected: ", selectedValue1), /*#__PURE__*/React.createElement(_SegmentedButton.default, {
109
+ name: "group2",
110
+ onClick: function onClick(val) {
111
+ return setSelectedValue2(val);
112
+ },
113
+ defaultIndex: 1,
114
+ segments: segmentsArr2
115
+ }), /*#__PURE__*/React.createElement("p", {
116
+ className: "selected-item"
117
+ }, "Selected: ", selectedValue2));
70
118
  }
71
119
  var _default = App;
72
120
  exports.default = _default;
package/dist/index.js CHANGED
@@ -5,10 +5,10 @@ var _react = _interopRequireDefault(require("react"));
5
5
  var _client = _interopRequireDefault(require("react-dom/client"));
6
6
  require("./index.css");
7
7
  var _App = _interopRequireDefault(require("./App"));
8
- require("@fontsource/roboto/300.css");
9
- require("@fontsource/roboto/400.css");
10
- require("@fontsource/roboto/500.css");
11
- require("@fontsource/roboto/700.css");
8
+ // import '@fontsource/roboto/300.css';
9
+ // import '@fontsource/roboto/400.css';
10
+ // import '@fontsource/roboto/500.css';
11
+ // import '@fontsource/roboto/700.css';
12
12
  var root = _client.default.createRoot(document.getElementById('root'));
13
13
  root.render( /*#__PURE__*/_react.default.createElement(_react.default.StrictMode, null, /*#__PURE__*/_react.default.createElement(_App.default, null)));
14
14
 
@@ -9,7 +9,7 @@ var _react = _interopRequireDefault(require("react"));
9
9
  var _Button = require("./components/Button");
10
10
  // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction
11
11
  var _default = {
12
- title: "SAG BI/Button",
12
+ title: "SAG/Button",
13
13
  component: _Button.Button,
14
14
  tags: ["autodocs"],
15
15
  argTypes: {
@@ -21,12 +21,20 @@ var _default = {
21
21
  description: "text inside of the button",
22
22
  defaultValue: ""
23
23
  },
24
- style: {
24
+ shape: {
25
25
  control: {
26
26
  type: "radio"
27
27
  },
28
28
  options: ["contained", "outlined", "text"],
29
- description: "style of the button"
29
+ description: "shape of the button"
30
+ },
31
+ radius: {
32
+ name: "radius",
33
+ control: {
34
+ type: "number"
35
+ },
36
+ description: "radius of the button",
37
+ defaultValue: 50
30
38
  },
31
39
  size: {
32
40
  control: {
@@ -43,6 +51,20 @@ var _default = {
43
51
  description: "changes the button to be enabled/disabled",
44
52
  defaultValue: ""
45
53
  },
54
+ backgroundColor: {
55
+ control: {
56
+ type: "color",
57
+ presetColors: ["#ffffff", "#ff0000", "#00ff00", "#0000ff"],
58
+ description: "Sets Background Color"
59
+ }
60
+ },
61
+ textColor: {
62
+ control: {
63
+ type: "select"
64
+ },
65
+ options: ["none", "inherit", "black", "green", "red", "yellow", "blue", "white"],
66
+ description: "text color of the button"
67
+ },
46
68
  onClick: {
47
69
  action: "onClick",
48
70
  description: "returns an event click object when user clicks on a button"
@@ -57,8 +79,10 @@ var SmallContainedStyle = Template.bind({});
57
79
  exports.SmallContainedStyle = SmallContainedStyle;
58
80
  SmallContainedStyle.args = {
59
81
  text: "Confirm",
60
- style: "contained",
82
+ shape: "contained",
83
+ radius: 50,
61
84
  size: "small",
85
+ textColor: "none",
62
86
  disabled: false
63
87
  };
64
88
  var DisabledContainedStyle = Template.bind({});
@@ -66,7 +90,9 @@ exports.DisabledContainedStyle = DisabledContainedStyle;
66
90
  DisabledContainedStyle.args = {
67
91
  size: "small",
68
92
  text: "Confirm",
69
- style: "contained",
93
+ shape: "contained",
94
+ radius: 50,
95
+ textColor: "inherit",
70
96
  disabled: true
71
97
  };
72
98
  var MediumOutlinedStyle = Template.bind({});
@@ -74,7 +100,9 @@ exports.MediumOutlinedStyle = MediumOutlinedStyle;
74
100
  MediumOutlinedStyle.args = {
75
101
  text: "Confirm",
76
102
  size: "medium",
77
- style: "outlined",
103
+ radius: 50,
104
+ shape: "outlined",
105
+ textColor: "",
78
106
  disabled: false
79
107
  };
80
108
  var LargeTextStyle = Template.bind({});
@@ -82,6 +110,8 @@ exports.LargeTextStyle = LargeTextStyle;
82
110
  LargeTextStyle.args = {
83
111
  text: "Confirm",
84
112
  size: "large",
85
- style: "text",
113
+ radius: 50,
114
+ shape: "text",
115
+ textColor: "inherit",
86
116
  disabled: false
87
117
  };
@@ -38,7 +38,7 @@ var options = [{
38
38
 
39
39
  // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction
40
40
  var _default = {
41
- title: "SAG BI/Dropdown",
41
+ title: "SAG/Dropdown",
42
42
  component: _Dropdown.Dropdown,
43
43
  tags: ["autodocs"],
44
44
  argTypes: {
@@ -0,0 +1,187 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = exports.SegmentedFilter = exports.Period = exports.DollarsOrUnits = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _SegmentedButton = require("./components/SegmentedButton");
10
+ var arrSegmentedFilters = [{
11
+ value: "Total"
12
+ }, {
13
+ value: "Ecommerce"
14
+ }, {
15
+ value: "In Store"
16
+ }];
17
+ var arrDollarsOrUnits = [{
18
+ value: "Dollars"
19
+ }, {
20
+ value: "Units"
21
+ }];
22
+ var arrPeriod = [{
23
+ value: "52 w"
24
+ }, {
25
+ value: "26 w"
26
+ }, {
27
+ value: "13 w"
28
+ }];
29
+ var _default = {
30
+ title: "SAG/SegmentedButton",
31
+ component: _SegmentedButton.SegmentedButton,
32
+ tags: ["autodocs"],
33
+ argTypes: {
34
+ name: {
35
+ name: "name",
36
+ control: {
37
+ type: "text"
38
+ },
39
+ description: "name of the object"
40
+ },
41
+ backgroundColor: {
42
+ name: "backgroundColor",
43
+ description: "Sets Background Color",
44
+ control: {
45
+ type: "color",
46
+ presetColors: ["#ffffff", "#ff0000", "#00ff00", "#0000ff"]
47
+ }
48
+ },
49
+ selectedSegmentColor: {
50
+ name: "selectedSegmentColor",
51
+ description: "Sets selected Segment Color Color",
52
+ control: {
53
+ type: "color",
54
+ presetColors: ["#ffffff", "#ff0000", "#00ff00", "#0000ff"]
55
+ }
56
+ },
57
+ selectedTextColor: {
58
+ name: "selectedTextColor",
59
+ description: "Sets selected text Color",
60
+ control: {
61
+ type: "color",
62
+ presetColors: ["#000000", "#ffffff", "#ff0000", "#00ff00", "#0000ff"]
63
+ }
64
+ },
65
+ unselectedTextColor: {
66
+ name: "unselectedTextColor",
67
+ description: "Sets unselected text Color",
68
+ control: {
69
+ type: "color",
70
+ presetColors: ["#000000", "#ffffff", "#ff0000", "#00ff00", "#0000ff"]
71
+ }
72
+ },
73
+ defaultIndex: {
74
+ name: "defaultIndex",
75
+ control: {
76
+ type: "number",
77
+ min: 0,
78
+ max: 20
79
+ },
80
+ description: "set default index to init segmented button component (in px)"
81
+ },
82
+ segmentWidth: {
83
+ name: "segmentWidth",
84
+ control: {
85
+ type: "number",
86
+ min: 0,
87
+ max: 300
88
+ },
89
+ description: "width of the segment in the control (in px)"
90
+ },
91
+ controlRadius: {
92
+ name: "controlRadius",
93
+ control: {
94
+ type: "number",
95
+ min: 0,
96
+ max: 40
97
+ },
98
+ description: "radius of the control corners (in px) "
99
+ },
100
+ segmentRadius: {
101
+ name: "segmentRadius",
102
+ control: {
103
+ type: "number",
104
+ min: 0,
105
+ max: 40
106
+ },
107
+ description: "radius of the selected segment corners (in px)"
108
+ },
109
+ segmentHeigth: {
110
+ name: "segmentHeigth",
111
+ control: {
112
+ type: "number",
113
+ min: 0,
114
+ max: 100
115
+ },
116
+ description: "height of the segments "
117
+ },
118
+ fontSize: {
119
+ name: "fontSize",
120
+ control: {
121
+ type: "number",
122
+ min: 9,
123
+ max: 40
124
+ },
125
+ description: "font size (in px)"
126
+ },
127
+ options: {
128
+ description: "array [] of objects: {value: string } to fill segmented buttons "
129
+ },
130
+ onClick: {
131
+ action: "onClick",
132
+ description: "onClick event - returns an object of selected button {index: number, value: string} "
133
+ }
134
+ }
135
+ };
136
+ exports.default = _default;
137
+ var Template = function Template(args) {
138
+ return /*#__PURE__*/_react.default.createElement(_SegmentedButton.SegmentedButton, args);
139
+ };
140
+ var SegmentedFilter = Template.bind({});
141
+ exports.SegmentedFilter = SegmentedFilter;
142
+ SegmentedFilter.args = {
143
+ name: "segmentedFilter",
144
+ options: arrSegmentedFilters,
145
+ defaultIndex: 0,
146
+ segmentWidth: 120,
147
+ controlRadius: 8,
148
+ segmentRadius: 8,
149
+ segmentHeigth: 30,
150
+ fontSize: 16,
151
+ backgroundColor: "rgb(232, 237, 247)",
152
+ selectedSegmentColor: '#fcfcfc',
153
+ selectedTextColor: '#000000',
154
+ unselectedTextColor: '#000000'
155
+ };
156
+ var DollarsOrUnits = Template.bind({});
157
+ exports.DollarsOrUnits = DollarsOrUnits;
158
+ DollarsOrUnits.args = {
159
+ name: "segmentedDollarsOrUnits",
160
+ options: arrDollarsOrUnits,
161
+ defaultIndex: 1,
162
+ segmentWidth: 100,
163
+ controlRadius: 8,
164
+ segmentRadius: 8,
165
+ segmentHeigth: 30,
166
+ fontSize: 16,
167
+ backgroundColor: "rgb(232, 237, 247)",
168
+ selectedSegmentColor: 'rgba(61, 154, 242, 0.83)',
169
+ selectedTextColor: '#ffffff',
170
+ unselectedTextColor: '#000000'
171
+ };
172
+ var Period = Template.bind({});
173
+ exports.Period = Period;
174
+ Period.args = {
175
+ name: "period",
176
+ options: arrPeriod,
177
+ defaultIndex: 1,
178
+ segmentWidth: 60,
179
+ controlRadius: 8,
180
+ segmentRadius: 8,
181
+ segmentHeigth: 30,
182
+ fontSize: 16,
183
+ backgroundColor: "rgb(232, 237, 247)",
184
+ selectedSegmentColor: 'rgba(61, 154, 242, 0.83)',
185
+ selectedTextColor: '#ffffff',
186
+ unselectedTextColor: '#000000'
187
+ };
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.SegmentLabel = exports.Segment = exports.ControlsInput = exports.ControlsContainer = exports.Controls = void 0;
8
+ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/taggedTemplateLiteral"));
9
+ var _styledComponents = _interopRequireDefault(require("styled-components"));
10
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
11
+ var ControlsContainer = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: flex; \n font: ", "; \n margin: 100px 0 25px;\n --highlight-width: auto;\n --highlight-x-pos: 0;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n"])), function (props) {
12
+ var _props$fontSize;
13
+ return (_props$fontSize = props.fontSize) === null || _props$fontSize === void 0 ? void 0 : _props$fontSize.toString().concat("", "px Lato, sans-serif");
14
+ });
15
+ exports.ControlsContainer = ControlsContainer;
16
+ var Controls = _styledComponents.default.div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n display: inline-flex;\n justify-content: space-between; \n background: ", ";\n box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);\n border-radius: ", "; //12px\n // max-width: 500px; //use this to limit max lenght of the control \n padding: 6px; \n margin: auto;\n overflow: hidden;\n position: relative;\n &.controls::before {\n content: \"\";\n background: ", "; /* #3a9df9; #5465ff;*/\n box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);\n border-radius: ", "; //12px\n width: var(--highlight-width);\n transform: translateX(var(--highlight-x-pos));\n position: absolute;\n top: 6px;\n bottom: 6px;\n left: 0;\n z-index: 0;\n }\n &.controls.ready::before {\n transition: transform 0.3s ease, width 0.3s ease;\n }\n"])), function (props) {
17
+ return props.backgroundColor;
18
+ }, function (props) {
19
+ return props.controlRadius.toString().concat("", "px");
20
+ }, function (props) {
21
+ return props.selectedSegmentColor;
22
+ }, function (props) {
23
+ return props.segmentRadius.toString().concat("", "px");
24
+ });
25
+ exports.Controls = Controls;
26
+ var ControlsInput = _styledComponents.default.input(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n opacity: 0;\n margin: 0;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n position: absolute;\n width: 100%;\n cursor: pointer;\n height: 100%;\n"])));
27
+ exports.ControlsInput = ControlsInput;
28
+ var Segment = _styledComponents.default.div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n /* width: 100%; uncomment for each segment to have matching width */ \n min-width: ", "; //120px;\n position: relative;\n text-align: center;\n z-index: 1; \n"])), function (props) {
29
+ return props.segmentWidth.toString().concat("", "px");
30
+ });
31
+ exports.Segment = Segment;
32
+ var SegmentLabel = _styledComponents.default.label(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n cursor: pointer;\n display: block;\n //font-weight: 550;\n padding: ", "; //10px;\n transition: color 0.5s ease;\n &.active {\n color: ", ";\n }\n &.inactive {\n color: ", ";\n }\n"])), function (props) {
33
+ return props.segmentHeigth.toString().concat("", "px");
34
+ }, function (props) {
35
+ return props.selectedTextColor;
36
+ }, function (props) {
37
+ return props.unselectedTextColor;
38
+ });
39
+ exports.SegmentLabel = SegmentLabel;
@@ -10,22 +10,43 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
10
10
  var React = _interopRequireWildcard(require("react"));
11
11
  var _Button = _interopRequireDefault(require("@mui/material/Button"));
12
12
  var _Stack = _interopRequireDefault(require("@mui/material/Stack"));
13
- var _excluded = ["text", "style", "size", "disabled", "onClick"];
13
+ var _excluded = ["text", "shape", "size", "disabled", "radius", "textColor", "backgroundColor", "onClick"];
14
14
  var Button = function Button(_ref) {
15
15
  var text = _ref.text,
16
- style = _ref.style,
16
+ shape = _ref.shape,
17
17
  size = _ref.size,
18
18
  disabled = _ref.disabled,
19
+ radius = _ref.radius,
20
+ textColor = _ref.textColor,
21
+ backgroundColor = _ref.backgroundColor,
19
22
  _onClick = _ref.onClick,
20
23
  props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
24
+ var getTextColor = function getTextColor() {
25
+ if (!textColor || textColor == "" || textColor == "none") {
26
+ //default when parameter was not set
27
+ if (shape === "contained") {
28
+ return "white";
29
+ } else {
30
+ return "black";
31
+ }
32
+ } else {
33
+ return textColor;
34
+ }
35
+ };
21
36
  return /*#__PURE__*/React.createElement(_Stack.default, {
22
37
  direction: "row",
23
38
  spacing: 2
24
39
  }, /*#__PURE__*/React.createElement(_Button.default, {
25
40
  sx: {
26
- textTransform: 'none'
41
+ textTransform: "none",
42
+ borderRadius: radius * 0.05,
43
+ color: getTextColor(),
44
+ // shape === "contained" ? "white" : "black",
45
+ backgroundColor: {
46
+ backgroundColor: backgroundColor
47
+ }
27
48
  },
28
- variant: style,
49
+ variant: shape,
29
50
  size: size,
30
51
  disabled: disabled ? true : false,
31
52
  onClick: function onClick(event) {
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = exports.SegmentedButton = void 0;
9
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
10
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
11
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectWithoutProperties"));
12
+ var _react = _interopRequireWildcard(require("react"));
13
+ var _SegmentedButtonStyle = require("../SegmentedButton.style.js");
14
+ var _excluded = ["name", "options", "segmentWidth", "segmentHeigth", "controlRadius", "segmentRadius", "fontSize", "backgroundColor", "selectedSegmentColor", "selectedTextColor", "unselectedTextColor", "defaultIndex", "onClick"];
15
+ var SegmentedButton = function SegmentedButton(_ref) {
16
+ var name = _ref.name,
17
+ options = _ref.options,
18
+ _ref$segmentWidth = _ref.segmentWidth,
19
+ segmentWidth = _ref$segmentWidth === void 0 ? 120 : _ref$segmentWidth,
20
+ _ref$segmentHeigth = _ref.segmentHeigth,
21
+ segmentHeigth = _ref$segmentHeigth === void 0 ? 40 : _ref$segmentHeigth,
22
+ _ref$controlRadius = _ref.controlRadius,
23
+ controlRadius = _ref$controlRadius === void 0 ? 8 : _ref$controlRadius,
24
+ _ref$segmentRadius = _ref.segmentRadius,
25
+ segmentRadius = _ref$segmentRadius === void 0 ? 8 : _ref$segmentRadius,
26
+ _ref$fontSize = _ref.fontSize,
27
+ fontSize = _ref$fontSize === void 0 ? 16 : _ref$fontSize,
28
+ _ref$backgroundColor = _ref.backgroundColor,
29
+ backgroundColor = _ref$backgroundColor === void 0 ? "rgb(232, 237, 247)" : _ref$backgroundColor,
30
+ _ref$selectedSegmentC = _ref.selectedSegmentColor,
31
+ selectedSegmentColor = _ref$selectedSegmentC === void 0 ? "#3a9df9" : _ref$selectedSegmentC,
32
+ _ref$selectedTextColo = _ref.selectedTextColor,
33
+ selectedTextColor = _ref$selectedTextColo === void 0 ? "white" : _ref$selectedTextColo,
34
+ _ref$unselectedTextCo = _ref.unselectedTextColor,
35
+ unselectedTextColor = _ref$unselectedTextCo === void 0 ? "black" : _ref$unselectedTextCo,
36
+ _ref$defaultIndex = _ref.defaultIndex,
37
+ defaultIndex = _ref$defaultIndex === void 0 ? 0 : _ref$defaultIndex,
38
+ onClick = _ref.onClick,
39
+ props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
40
+ var _useState = (0, _react.useState)(defaultIndex),
41
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
42
+ activeIndex = _useState2[0],
43
+ setActiveIndex = _useState2[1];
44
+ var controlRef = (0, _react.useRef)();
45
+ var componentReady = (0, _react.useRef)();
46
+ var optionsRef = options.map(function (item, i) {
47
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, item), {}, {
48
+ id: i,
49
+ ref: (0, _react.useRef)()
50
+ });
51
+ });
52
+
53
+ // Determine when the component is "ready"
54
+ (0, _react.useEffect)(function () {
55
+ componentReady.current = true;
56
+ }, []);
57
+ (0, _react.useEffect)(function () {
58
+ if (defaultIndex >= 0 && defaultIndex < (options === null || options === void 0 ? void 0 : options.length)) {
59
+ setActiveIndex(defaultIndex);
60
+ }
61
+ }, [defaultIndex]);
62
+ (0, _react.useEffect)(function () {
63
+ var activeSegmentRef = optionsRef[activeIndex].ref;
64
+ var _activeSegmentRef$cur = activeSegmentRef.current,
65
+ offsetWidth = _activeSegmentRef$cur.offsetWidth,
66
+ offsetLeft = _activeSegmentRef$cur.offsetLeft;
67
+ var style = controlRef.current.style;
68
+ style.setProperty("--highlight-width", "".concat(offsetWidth, "px"));
69
+ style.setProperty("--highlight-x-pos", "".concat(offsetLeft, "px"));
70
+ }, [activeIndex, controlRef, optionsRef]);
71
+ var onInputChangeHandler = function onInputChangeHandler(value, index) {
72
+ setActiveIndex(index);
73
+ onClick({
74
+ index: index,
75
+ value: value
76
+ });
77
+ };
78
+ return /*#__PURE__*/_react.default.createElement(_SegmentedButtonStyle.ControlsContainer, {
79
+ fontSize: fontSize,
80
+ ref: controlRef
81
+ }, /*#__PURE__*/_react.default.createElement(_SegmentedButtonStyle.Controls, {
82
+ backgroundColor: backgroundColor,
83
+ selectedSegmentColor: selectedSegmentColor,
84
+ segmentRadius: segmentRadius,
85
+ controlRadius: controlRadius,
86
+ segmentHeigth: segmentHeigth / 4,
87
+ segmentWidth: segmentWidth,
88
+ className: "controls ".concat(componentReady.current ? "ready" : "idle")
89
+ }, optionsRef === null || optionsRef === void 0 ? void 0 : optionsRef.map(function (item, i) {
90
+ return /*#__PURE__*/_react.default.createElement(_SegmentedButtonStyle.Segment, {
91
+ key: item.id,
92
+ backgroundColor: backgroundColor,
93
+ selectedSegmentColor: selectedSegmentColor,
94
+ segmentRadius: segmentRadius,
95
+ controlRadius: controlRadius,
96
+ segmentHeigth: segmentHeigth / 4,
97
+ segmentWidth: segmentWidth,
98
+ className: "".concat(activeIndex === i ? "active" : "inactive"),
99
+ ref: item.ref
100
+ }, /*#__PURE__*/_react.default.createElement(_SegmentedButtonStyle.ControlsInput, {
101
+ type: "radio",
102
+ value: item.value,
103
+ id: item.id,
104
+ name: name,
105
+ onChange: function onChange() {
106
+ return onInputChangeHandler(item.value, item.id);
107
+ },
108
+ checked: i === activeIndex
109
+ }), /*#__PURE__*/_react.default.createElement(_SegmentedButtonStyle.SegmentLabel, {
110
+ selectedTextColor: selectedTextColor,
111
+ unselectedTextColor: unselectedTextColor,
112
+ segmentHeigth: segmentHeigth / 4,
113
+ className: "".concat(activeIndex === i ? "active" : "inactive", " "),
114
+ htmlFor: item.value
115
+ }, item.value));
116
+ })));
117
+ };
118
+ exports.SegmentedButton = SegmentedButton;
119
+ var _default = SegmentedButton;
120
+ exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sag_components",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -21,6 +21,7 @@
21
21
  "@storybook/addon-essentials": "^7.0.6",
22
22
  "@storybook/addon-interactions": "^7.0.6",
23
23
  "@storybook/addon-links": "^7.0.6",
24
+ "@storybook/addon-storysource": "^7.0.7",
24
25
  "@storybook/blocks": "^7.0.6",
25
26
  "@storybook/preset-scss": "^1.0.3",
26
27
  "@storybook/react": "^7.0.6",
@@ -46,8 +47,7 @@
46
47
  "@fortawesome/react-fontawesome": "^0.2.0",
47
48
  "@mui/icons-material": "^5.11.16",
48
49
  "@mui/material": "^5.13.0",
49
- "@mui/styled-engine-sc": "^5.12.0",
50
- "@storybook/addon-storysource": "^7.0.7",
50
+ "@mui/styled-engine-sc": "^5.12.0",
51
51
  "hoopy": "^0.1.4",
52
52
  "react-scripts": "5.0.1"
53
53
  },
package/src/App.css CHANGED
@@ -1,7 +1,6 @@
1
1
  .App {
2
2
  display: block;
3
- width: 300px;
3
+ width: 600px;
4
4
  padding-top: 5%;
5
5
  padding-left: 5%;
6
6
  }
7
-
package/src/App.js CHANGED
@@ -1,7 +1,10 @@
1
1
  import logo from "./logo.svg";
2
2
  import "./App.css";
3
- import { Button } from "./stories/Button";
4
- import Dropdown from "./stories/Dropdown";
3
+ import { useState } from "react";
4
+
5
+ import Button from "./stories/components/Button";
6
+ import Dropdown from "./stories/components/Dropdown";
7
+ import SegmentedButton from "./stories/components/SegmentedButton";
5
8
 
6
9
  const onChangehandler = (event, newValue) => {
7
10
  console.log("Dropdown onChange event returned:");
@@ -25,6 +28,40 @@ function App() {
25
28
  { id: "8", label: "Price Chopper" },
26
29
  { id: "9", label: "South Eastern Grocers" },
27
30
  ];
31
+
32
+ const segmentsArr1=[
33
+ {
34
+ label: "Complete",
35
+ value: "complete",
36
+ },
37
+ {
38
+ label: "Incomplete",
39
+ value: "incomplete",
40
+ },
41
+ {
42
+ label: "Pending",
43
+ value: "pending",
44
+ },
45
+ ];
46
+
47
+ const segmentsArr2=[
48
+ {
49
+ label: "First",
50
+ value: "first",
51
+ },
52
+ {
53
+ label: "Second",
54
+ value: "second",
55
+ },
56
+ {
57
+ label: "Third",
58
+ value: "third",
59
+ },
60
+ ]
61
+
62
+ const [selectedValue1, setSelectedValue1] = useState("complete");
63
+ const [selectedValue2, setSelectedValue2] = useState("complete");
64
+
28
65
  return (
29
66
  <div className="App">
30
67
  <Dropdown
@@ -37,7 +74,6 @@ function App() {
37
74
  onChange={onChangehandler}
38
75
  onInputChange={onInputChangeHandler}
39
76
  />
40
-
41
77
  <Dropdown
42
78
  width={400}
43
79
  size="small"
@@ -48,8 +84,24 @@ function App() {
48
84
  onChange={onChangehandler}
49
85
  onInputChange={onInputChangeHandler}
50
86
  />
87
+
88
+ <SegmentedButton
89
+ name="group1"
90
+ onClick={(val) => setSelectedValue1(val)}
91
+ segments={segmentsArr1}
92
+ />
93
+ <p className="selected-item">Selected: {selectedValue1}</p>
94
+ <SegmentedButton
95
+ name="group2"
96
+ onClick={(val) => setSelectedValue2(val)}
97
+ defaultIndex={1}
98
+ segments={segmentsArr2}
99
+ />
100
+ <p className="selected-item">Selected: {selectedValue2}</p>
101
+
51
102
  </div>
52
103
  );
53
104
  }
54
105
 
106
+
55
107
  export default App;
package/src/index.js CHANGED
@@ -2,10 +2,10 @@ import React from 'react';
2
2
  import ReactDOM from 'react-dom/client';
3
3
  import './index.css';
4
4
  import App from './App';
5
- import '@fontsource/roboto/300.css';
6
- import '@fontsource/roboto/400.css';
7
- import '@fontsource/roboto/500.css';
8
- import '@fontsource/roboto/700.css';
5
+ // import '@fontsource/roboto/300.css';
6
+ // import '@fontsource/roboto/400.css';
7
+ // import '@fontsource/roboto/500.css';
8
+ // import '@fontsource/roboto/700.css';
9
9
 
10
10
 
11
11
 
@@ -3,7 +3,7 @@ import { Button } from "./components/Button";
3
3
 
4
4
  // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction
5
5
  export default {
6
- title: "SAG BI/Button",
6
+ title: "SAG/Button",
7
7
  component: Button,
8
8
  tags: ["autodocs"],
9
9
 
@@ -15,10 +15,17 @@ export default {
15
15
  defaultValue: "",
16
16
  },
17
17
 
18
- style: {
18
+ shape: {
19
19
  control: { type: "radio" },
20
20
  options: ["contained", "outlined", "text"],
21
- description: "style of the button",
21
+ description: "shape of the button",
22
+ },
23
+
24
+ radius: {
25
+ name: "radius",
26
+ control: { type: "number" },
27
+ description: "radius of the button",
28
+ defaultValue: 50,
22
29
  },
23
30
 
24
31
  size: {
@@ -34,6 +41,29 @@ export default {
34
41
  defaultValue: "",
35
42
  },
36
43
 
44
+ backgroundColor: {
45
+ control: {
46
+ type: "color",
47
+ presetColors: ["#ffffff", "#ff0000", "#00ff00", "#0000ff"],
48
+ description: "Sets Background Color",
49
+ },
50
+ },
51
+
52
+ textColor: {
53
+ control: { type: "select" },
54
+ options: [
55
+ "none",
56
+ "inherit",
57
+ "black",
58
+ "green",
59
+ "red",
60
+ "yellow",
61
+ "blue",
62
+ "white",
63
+ ],
64
+ description: "text color of the button",
65
+ },
66
+
37
67
  onClick: {
38
68
  action: "onClick",
39
69
  description: "returns an event click object when user clicks on a button",
@@ -46,17 +76,20 @@ const Template = (args) => <Button {...args} />;
46
76
  export const SmallContainedStyle = Template.bind({});
47
77
  SmallContainedStyle.args = {
48
78
  text: "Confirm",
49
- style: "contained",
79
+ shape: "contained",
80
+ radius: 50,
50
81
  size: "small",
82
+ textColor: "none",
51
83
  disabled: false,
52
84
  };
53
85
 
54
-
55
86
  export const DisabledContainedStyle = Template.bind({});
56
87
  DisabledContainedStyle.args = {
57
88
  size: "small",
58
89
  text: "Confirm",
59
- style: "contained",
90
+ shape: "contained",
91
+ radius: 50,
92
+ textColor: "inherit",
60
93
  disabled: true,
61
94
  };
62
95
 
@@ -64,16 +97,18 @@ export const MediumOutlinedStyle = Template.bind({});
64
97
  MediumOutlinedStyle.args = {
65
98
  text: "Confirm",
66
99
  size: "medium",
67
- style: "outlined",
100
+ radius: 50,
101
+ shape: "outlined",
102
+ textColor: "",
68
103
  disabled: false,
69
104
  };
70
105
 
71
-
72
106
  export const LargeTextStyle = Template.bind({});
73
107
  LargeTextStyle.args = {
74
108
  text: "Confirm",
75
109
  size: "large",
76
- style: "text",
110
+ radius: 50,
111
+ shape: "text",
112
+ textColor: "inherit",
77
113
  disabled: false,
78
114
  };
79
-
@@ -15,7 +15,7 @@ const options = [
15
15
 
16
16
  // More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction
17
17
  export default {
18
- title: "SAG BI/Dropdown",
18
+ title: "SAG/Dropdown",
19
19
  component: Dropdown,
20
20
  tags: ["autodocs"],
21
21
 
@@ -0,0 +1,205 @@
1
+ import React from "react";
2
+ import { SegmentedButton } from "./components/SegmentedButton";
3
+
4
+
5
+
6
+
7
+ const arrSegmentedFilters=[
8
+ {
9
+ value: "Total",
10
+ },
11
+ {
12
+ value: "Ecommerce",
13
+ },
14
+ {
15
+ value: "In Store",
16
+ },
17
+ ];
18
+
19
+
20
+ const arrDollarsOrUnits=[
21
+ {
22
+ value: "Dollars",
23
+ },
24
+ {
25
+ value: "Units",
26
+ },
27
+ ];
28
+
29
+
30
+
31
+ const arrPeriod=[
32
+ {
33
+ value: "52 w",
34
+ },
35
+ {
36
+ value: "26 w",
37
+ },
38
+ {
39
+ value: "13 w",
40
+ },
41
+ ];
42
+
43
+
44
+ export default {
45
+ title: "SAG/SegmentedButton",
46
+ component: SegmentedButton,
47
+ tags: ["autodocs"],
48
+
49
+ argTypes: {
50
+ name: {
51
+ name: "name",
52
+ control: { type: "text" },
53
+ description: "name of the object",
54
+ },
55
+
56
+
57
+ backgroundColor: {
58
+ name: "backgroundColor",
59
+ description: "Sets Background Color",
60
+ control: {
61
+ type: "color",
62
+ presetColors: ["#ffffff", "#ff0000", "#00ff00", "#0000ff"],
63
+ },
64
+ },
65
+
66
+
67
+ selectedSegmentColor: {
68
+ name: "selectedSegmentColor",
69
+ description: "Sets selected Segment Color Color",
70
+ control: {
71
+ type: "color",
72
+ presetColors: ["#ffffff", "#ff0000", "#00ff00", "#0000ff"],
73
+ },
74
+ },
75
+
76
+ selectedTextColor: {
77
+ name: "selectedTextColor",
78
+ description: "Sets selected text Color",
79
+ control: {
80
+ type: "color",
81
+ presetColors: ["#000000","#ffffff", "#ff0000", "#00ff00", "#0000ff"],
82
+ },
83
+ },
84
+
85
+
86
+ unselectedTextColor: {
87
+ name: "unselectedTextColor",
88
+ description: "Sets unselected text Color",
89
+ control: {
90
+ type: "color",
91
+ presetColors: ["#000000","#ffffff", "#ff0000", "#00ff00", "#0000ff"],
92
+ },
93
+ },
94
+
95
+ defaultIndex: {
96
+ name: "defaultIndex",
97
+ control: { type: "number" , min:0, max:20},
98
+ description: "set default index to init segmented button component (in px)",
99
+ },
100
+
101
+
102
+ segmentWidth: {
103
+ name: "segmentWidth",
104
+ control: { type: "number", min:0, max:300 },
105
+ description: "width of the segment in the control (in px)",
106
+ },
107
+
108
+ controlRadius: {
109
+ name: "controlRadius",
110
+ control: { type: "number", min:0, max:40 },
111
+ description: "radius of the control corners (in px) ",
112
+ },
113
+
114
+
115
+ segmentRadius: {
116
+ name: "segmentRadius",
117
+ control: { type: "number", min:0, max:40 },
118
+ description: "radius of the selected segment corners (in px)",
119
+ },
120
+
121
+
122
+ segmentHeigth: {
123
+ name: "segmentHeigth",
124
+ control: { type: "number", min:0, max:100 },
125
+ description: "height of the segments ",
126
+ },
127
+
128
+
129
+ fontSize: {
130
+ name: "fontSize",
131
+ control: { type: "number", min:9, max:40 },
132
+ description: "font size (in px)",
133
+ },
134
+
135
+ options: {
136
+ description:
137
+ "array [] of objects: {value: string } to fill segmented buttons ",
138
+ },
139
+
140
+ onClick: {
141
+ action: "onClick",
142
+ description: "onClick event - returns an object of selected button {index: number, value: string} ",
143
+ },
144
+ },
145
+ };
146
+
147
+ const Template = (args) => <SegmentedButton {...args} />;
148
+
149
+
150
+ export const SegmentedFilter = Template.bind({});
151
+ SegmentedFilter.args = {
152
+
153
+ name: "segmentedFilter",
154
+ options: arrSegmentedFilters,
155
+ defaultIndex: 0,
156
+ segmentWidth: 120,
157
+ controlRadius: 8,
158
+ segmentRadius: 8,
159
+ segmentHeigth: 30,
160
+ fontSize: 16,
161
+ backgroundColor: "rgb(232, 237, 247)",
162
+ selectedSegmentColor: '#fcfcfc',
163
+ selectedTextColor: '#000000',
164
+ unselectedTextColor: '#000000',
165
+
166
+ };
167
+
168
+
169
+
170
+ export const DollarsOrUnits = Template.bind({});
171
+ DollarsOrUnits.args = {
172
+
173
+ name: "segmentedDollarsOrUnits",
174
+ options: arrDollarsOrUnits,
175
+ defaultIndex: 1,
176
+ segmentWidth: 100,
177
+ controlRadius: 8,
178
+ segmentRadius: 8,
179
+ segmentHeigth: 30,
180
+ fontSize: 16,
181
+ backgroundColor: "rgb(232, 237, 247)",
182
+ selectedSegmentColor: 'rgba(61, 154, 242, 0.83)',
183
+ selectedTextColor: '#ffffff',
184
+ unselectedTextColor: '#000000',
185
+
186
+ };
187
+
188
+
189
+ export const Period = Template.bind({});
190
+ Period.args = {
191
+
192
+ name: "period",
193
+ options: arrPeriod,
194
+ defaultIndex: 1,
195
+ segmentWidth: 60,
196
+ controlRadius: 8,
197
+ segmentRadius: 8,
198
+ segmentHeigth: 30,
199
+ fontSize: 16,
200
+ backgroundColor: "rgb(232, 237, 247)",
201
+ selectedSegmentColor: 'rgba(61, 154, 242, 0.83)',
202
+ selectedTextColor: '#ffffff',
203
+ unselectedTextColor: '#000000',
204
+
205
+ };
@@ -0,0 +1,76 @@
1
+ import styled from "styled-components";
2
+
3
+ export const ControlsContainer = styled.div`
4
+ display: flex;
5
+ font: ${(props) => { return props.fontSize?.toString().concat("", "px Lato, sans-serif")} };
6
+ margin: 100px 0 25px;
7
+ --highlight-width: auto;
8
+ --highlight-x-pos: 0;
9
+ -webkit-font-smoothing: antialiased;
10
+ -moz-osx-font-smoothing: grayscale;
11
+ `;
12
+
13
+ export const Controls = styled.div`
14
+ display: inline-flex;
15
+ justify-content: space-between;
16
+ background: ${(props) => props.backgroundColor};
17
+ box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
18
+ border-radius: ${(props) => { return props.controlRadius.toString().concat("", "px")} }; //12px
19
+ // max-width: 500px; //use this to limit max lenght of the control
20
+ padding: 6px;
21
+ margin: auto;
22
+ overflow: hidden;
23
+ position: relative;
24
+ &.controls::before {
25
+ content: "";
26
+ background: ${(props) => props.selectedSegmentColor}; /* #3a9df9; #5465ff;*/
27
+ box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
28
+ border-radius: ${(props) => {return props.segmentRadius.toString().concat("", "px")} }; //12px
29
+ width: var(--highlight-width);
30
+ transform: translateX(var(--highlight-x-pos));
31
+ position: absolute;
32
+ top: 6px;
33
+ bottom: 6px;
34
+ left: 0;
35
+ z-index: 0;
36
+ }
37
+ &.controls.ready::before {
38
+ transition: transform 0.3s ease, width 0.3s ease;
39
+ }
40
+ `;
41
+
42
+ export const ControlsInput = styled.input`
43
+ opacity: 0;
44
+ margin: 0;
45
+ top: 0;
46
+ right: 0;
47
+ bottom: 0;
48
+ left: 0;
49
+ position: absolute;
50
+ width: 100%;
51
+ cursor: pointer;
52
+ height: 100%;
53
+ `;
54
+
55
+ export const Segment = styled.div`
56
+ /* width: 100%; uncomment for each segment to have matching width */
57
+ min-width: ${(props) => {return props.segmentWidth.toString().concat("", "px")} }; //120px;
58
+ position: relative;
59
+ text-align: center;
60
+ z-index: 1;
61
+ `;
62
+
63
+ export const SegmentLabel = styled.label`
64
+ cursor: pointer;
65
+ display: block;
66
+ //font-weight: 550;
67
+ padding: ${(props) => {return props.segmentHeigth.toString().concat("", "px")} }; //10px;
68
+ transition: color 0.5s ease;
69
+ &.active {
70
+ color: ${(props) => props.selectedTextColor};
71
+ }
72
+ &.inactive {
73
+ color: ${(props) => props.unselectedTextColor};
74
+ }
75
+ `;
76
+
@@ -2,13 +2,43 @@ import * as React from "react";
2
2
  import MUIButton from "@mui/material/Button";
3
3
  import Stack from "@mui/material/Stack";
4
4
 
5
- export const Button = ({text, style, size, disabled, onClick, ...props}) => {
6
-
5
+ export const Button = ({
6
+ text,
7
+ shape,
8
+ size,
9
+ disabled,
10
+ radius,
11
+ textColor,
12
+ backgroundColor,
13
+ onClick,
14
+ ...props
15
+ }) => {
16
+ const getTextColor = () => {
17
+
18
+ if (!textColor || textColor == "" || textColor == "none") {
19
+ //default when parameter was not set
20
+ if (shape === "contained") {
21
+ return "white";
22
+ } else {
23
+ return "black";
24
+ }
25
+ }
26
+ else{
27
+ return textColor;
28
+ }
29
+ };
30
+
7
31
  return (
8
32
  <Stack direction="row" spacing={2}>
9
- <MUIButton
10
- sx={{ textTransform: 'none'}}
11
- variant={style}
33
+ <MUIButton
34
+ sx={{
35
+ textTransform: "none",
36
+ borderRadius: radius * 0.05,
37
+ color: getTextColor(), // shape === "contained" ? "white" : "black",
38
+ backgroundColor: { backgroundColor },
39
+ }}
40
+
41
+ variant={shape}
12
42
  size={size}
13
43
  disabled={disabled ? true : false}
14
44
  onClick={(event) => {
@@ -0,0 +1,111 @@
1
+ import React from "react";
2
+ import { useState, useEffect, useRef } from "react";
3
+
4
+ import {
5
+ ControlsContainer,
6
+ Controls,
7
+ ControlsInput,
8
+ Segment,
9
+ SegmentLabel,
10
+ } from "../SegmentedButton.style.js";
11
+
12
+ export const SegmentedButton = ({
13
+ name,
14
+ options,
15
+ segmentWidth = 120,
16
+ segmentHeigth = 40,
17
+ controlRadius = 8,
18
+ segmentRadius = 8,
19
+ fontSize = 16,
20
+ backgroundColor = "rgb(232, 237, 247)",
21
+ selectedSegmentColor = "#3a9df9",
22
+ selectedTextColor = "white",
23
+ unselectedTextColor = "black",
24
+ defaultIndex = 0,
25
+ onClick,
26
+ ...props
27
+ }) => {
28
+ const [activeIndex, setActiveIndex] = useState(defaultIndex);
29
+
30
+ const controlRef = useRef();
31
+ const componentReady = useRef();
32
+
33
+ const optionsRef = options.map((item, i) => {
34
+ return { ...item, id: i, ref: useRef() };
35
+ });
36
+
37
+ // Determine when the component is "ready"
38
+ useEffect(() => {
39
+ componentReady.current = true;
40
+ }, []);
41
+
42
+ useEffect(()=>{
43
+ if( defaultIndex >= 0 && defaultIndex < options?.length){
44
+ setActiveIndex(defaultIndex);
45
+ }
46
+ },[defaultIndex])
47
+
48
+ useEffect(() => {
49
+ const activeSegmentRef = optionsRef[activeIndex].ref;
50
+ const { offsetWidth, offsetLeft } = activeSegmentRef.current;
51
+ const { style } = controlRef.current;
52
+
53
+ style.setProperty("--highlight-width", `${offsetWidth}px`);
54
+ style.setProperty("--highlight-x-pos", `${offsetLeft}px`);
55
+ }, [activeIndex, controlRef, optionsRef]);
56
+
57
+ const onInputChangeHandler = (value, index) => {
58
+ setActiveIndex(index);
59
+ onClick({index: index, value: value} );
60
+ };
61
+
62
+ return (
63
+ <ControlsContainer
64
+ fontSize={fontSize}
65
+ ref={controlRef}>
66
+ <Controls
67
+ backgroundColor={backgroundColor}
68
+ selectedSegmentColor={selectedSegmentColor}
69
+ segmentRadius={segmentRadius}
70
+ controlRadius={controlRadius}
71
+ segmentHeigth={segmentHeigth/4}
72
+ segmentWidth={segmentWidth}
73
+ className={`controls ${componentReady.current ? "ready" : "idle"}`}
74
+ >
75
+ {optionsRef?.map((item, i) => (
76
+ <Segment
77
+ key={item.id}
78
+ backgroundColor={backgroundColor}
79
+ selectedSegmentColor={selectedSegmentColor}
80
+ segmentRadius={segmentRadius}
81
+ controlRadius={controlRadius}
82
+ segmentHeigth={segmentHeigth/4}
83
+ segmentWidth={segmentWidth}
84
+ className={`${activeIndex === i ? "active" : "inactive"}`}
85
+ ref={item.ref}
86
+ >
87
+ <ControlsInput
88
+ type="radio"
89
+ value={item.value}
90
+ id={item.id}
91
+ name={name}
92
+ onChange={() => onInputChangeHandler(item.value, item.id)}
93
+ checked={i === activeIndex}
94
+ />
95
+ <SegmentLabel
96
+ selectedTextColor={selectedTextColor}
97
+ unselectedTextColor={unselectedTextColor}
98
+ segmentHeigth={segmentHeigth/4}
99
+ className={`${activeIndex === i ? "active" : "inactive"} `}
100
+ htmlFor={item.value}
101
+ >
102
+ {item.value}
103
+ </SegmentLabel>
104
+ </Segment>
105
+ ))}
106
+ </Controls>
107
+ </ControlsContainer>
108
+ );
109
+ };
110
+
111
+ export default SegmentedButton;
package/decs.d.ts DELETED
File without changes
package/src/index.d.ts DELETED
@@ -1,10 +0,0 @@
1
- export function Button({ text, style, size, disabled, onClick, ...props }: {
2
- [x: string]: any;
3
- text: any;
4
- style: any;
5
- size: any;
6
- disabled: any;
7
- onClick: any;
8
- }): any;
9
- export default Button;
10
-
package/tsconfig.json DELETED
File without changes