sprint-asia-custom-component 0.1.1 → 0.1.2
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/index.js +34 -6
- package/package.json +1 -1
- package/src/components/Button/index.js +45 -8
package/dist/index.js
CHANGED
|
@@ -8,12 +8,40 @@
|
|
|
8
8
|
|
|
9
9
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
10
10
|
|
|
11
|
-
const Button = (
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
const Button = ({
|
|
12
|
+
title = "Button",
|
|
13
|
+
type = "wrap",
|
|
14
|
+
isActive = true,
|
|
15
|
+
size = "large",
|
|
16
|
+
onClick = () => {}
|
|
17
|
+
}) => {
|
|
18
|
+
const [isPressed, setIsPressed] = React.useState(false);
|
|
19
|
+
const handleButtonPress = () => {
|
|
20
|
+
setIsPressed(true);
|
|
21
|
+
};
|
|
22
|
+
const handleButtonRelease = () => {
|
|
23
|
+
setIsPressed(false);
|
|
24
|
+
};
|
|
25
|
+
const handleClick = () => {
|
|
26
|
+
onClick();
|
|
27
|
+
};
|
|
28
|
+
return /*#__PURE__*/React__default["default"].createElement("button", {
|
|
29
|
+
className: `
|
|
30
|
+
${isPressed && isActive ? 'bg-primary700 text-white' : isActive ? 'bg-primary500 hover:bg-primary600 text-white cursor-pointer' : 'bg-neutral30 text-neutral80 cursor-default'}
|
|
31
|
+
${type === "full" && "w-full"}
|
|
32
|
+
${size === "small" && "text-sm h-7"}
|
|
33
|
+
${size === "medium" && "text-md h-8"}
|
|
34
|
+
${size === "large" && "text-lg h-10"}
|
|
35
|
+
${size === "very large" && "text-xl h-12"}
|
|
36
|
+
${size === "extra very large" && "text-2xl h-14"}
|
|
37
|
+
rounded-lg drop-shadow-md text-center py-1.5 px-4 flex justify-center items-center`,
|
|
38
|
+
disabled: !isActive,
|
|
39
|
+
onClick: handleClick,
|
|
40
|
+
onMouseDown: handleButtonPress,
|
|
41
|
+
onMouseUp: handleButtonRelease,
|
|
42
|
+
onTouchStart: handleButtonPress,
|
|
43
|
+
onTouchEnd: handleButtonRelease
|
|
44
|
+
}, title);
|
|
17
45
|
};
|
|
18
46
|
|
|
19
47
|
exports.Button = Button;
|
package/package.json
CHANGED
|
@@ -1,11 +1,48 @@
|
|
|
1
|
-
import React from 'react'
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
|
|
3
|
+
const Button = ({
|
|
4
|
+
title = "Button",
|
|
5
|
+
type = "wrap",
|
|
6
|
+
isActive = true,
|
|
7
|
+
size = "large",
|
|
8
|
+
onClick = () => {}
|
|
9
|
+
}) => {
|
|
10
|
+
const [isPressed, setIsPressed] = useState(false);
|
|
11
|
+
|
|
12
|
+
const handleButtonPress = () => {
|
|
13
|
+
setIsPressed(true);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const handleButtonRelease = () => {
|
|
17
|
+
setIsPressed(false);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const handleClick = () => {
|
|
21
|
+
onClick();
|
|
22
|
+
};
|
|
2
23
|
|
|
3
|
-
const Button = () => {
|
|
4
24
|
return (
|
|
5
|
-
<
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
25
|
+
<button
|
|
26
|
+
className={`
|
|
27
|
+
${(isPressed && isActive) ? 'bg-primary700 text-white' : (isActive ? 'bg-primary500 hover:bg-primary600 text-white cursor-pointer' : 'bg-neutral30 text-neutral80 cursor-default')}
|
|
28
|
+
${type === "full" && "w-full"}
|
|
29
|
+
${size === "small" && "text-sm h-7"}
|
|
30
|
+
${size === "medium" && "text-md h-8"}
|
|
31
|
+
${size === "large" && "text-lg h-10"}
|
|
32
|
+
${size === "very large" && "text-xl h-12"}
|
|
33
|
+
${size === "extra very large" && "text-2xl h-14"}
|
|
34
|
+
rounded-lg drop-shadow-md text-center py-1.5 px-4 flex justify-center items-center`
|
|
35
|
+
}
|
|
36
|
+
disabled={!isActive}
|
|
37
|
+
onClick={handleClick}
|
|
38
|
+
onMouseDown={handleButtonPress}
|
|
39
|
+
onMouseUp={handleButtonRelease}
|
|
40
|
+
onTouchStart={handleButtonPress}
|
|
41
|
+
onTouchEnd={handleButtonRelease}
|
|
42
|
+
>
|
|
43
|
+
{title}
|
|
44
|
+
</button>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
10
47
|
|
|
11
|
-
export default Button
|
|
48
|
+
export default Button;
|