@bolttech/atoms-button 0.15.0 → 0.16.0
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/README.md +68 -4
- package/index.cjs +15 -13
- package/package.json +2 -2
- package/src/lib/atoms-button.d.ts +3 -1
package/README.md
CHANGED
|
@@ -1,8 +1,72 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Button Component
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A customizable React button component.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Installation
|
|
6
6
|
|
|
7
|
+
Use the package manager [npm](https://www.npmjs.com/) or [yarn](https://yarnpkg.com/) to install the component.
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
```bash
|
|
10
|
+
npm install @edirect/frontend-foundations @bolttech/atoms-button
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
or
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
yarn add @edirect/frontend-foundations @bolttech/atoms-button
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Props
|
|
20
|
+
|
|
21
|
+
The `Button` component accepts the following properties:
|
|
22
|
+
|
|
23
|
+
| Prop | Type | Description |
|
|
24
|
+
|---------------|--------------|-----------------------------------------------------------------------------------------------------------------|
|
|
25
|
+
| dataTestId | `string` | The `data-testid` attribute for testing. |
|
|
26
|
+
| disabled | `boolean` | Disables the button when set to `true`. |
|
|
27
|
+
| title | `string` | The text content of the button. |
|
|
28
|
+
| variant | `string` | The variant style of the button (e.g., `'primary'`, `'secondary'`, `'alternative'`). |
|
|
29
|
+
| size | `string` | The size of the button (e.g., `'sm'`, `'md'`, `'lg'`). |
|
|
30
|
+
| iconRight | `string` | The name of the icon to be displayed on the right side of the button. |
|
|
31
|
+
| iconLeft | `string` | The name of the icon to be displayed on the left side of the button. |
|
|
32
|
+
| fullWidth | `boolean` | Sets the button width to 100% if `true`. |
|
|
33
|
+
| type | `string` | The type of the button (e.g., `'button'`, `'submit'`, `'reset'`). |
|
|
34
|
+
| onClick | `function` | Callback function to handle the button click event. |
|
|
35
|
+
|
|
36
|
+
## Usage
|
|
37
|
+
|
|
38
|
+
```jsx
|
|
39
|
+
import React from 'react';
|
|
40
|
+
import {Button} from '@bolttech/atoms-button';
|
|
41
|
+
import {bolttechTheme, BolttechThemeProvider} from "@edirect/frontend-foundations";
|
|
42
|
+
|
|
43
|
+
const ExampleComponent = () => {
|
|
44
|
+
const handleButtonClick = () => {
|
|
45
|
+
// Logic to handle the button click event
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<BolttechThemeProvider theme={bolttechTheme}>
|
|
50
|
+
<Button
|
|
51
|
+
dataTestId="custom-button"
|
|
52
|
+
disabled={false}
|
|
53
|
+
title="Click Me"
|
|
54
|
+
variant="primary"
|
|
55
|
+
size="md"
|
|
56
|
+
iconRight="arrow_forward"
|
|
57
|
+
fullWidth={false}
|
|
58
|
+
type="button"
|
|
59
|
+
onClick={handleButtonClick}
|
|
60
|
+
/>
|
|
61
|
+
</BolttechThemeProvider>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export default ExampleComponent;
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Contributing
|
|
69
|
+
|
|
70
|
+
Contributions are welcome! For any bug fixes, improvements, or new features, please open an [issue](link-to-issues) or submit a pull request.
|
|
71
|
+
|
|
72
|
+
Please make sure to follow the code standards and test your changes before submitting.
|
package/index.cjs
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var react = require('react');
|
|
7
8
|
var atomsIcon = require('@bolttech/atoms-icon');
|
|
8
9
|
var styled = require('styled-components');
|
|
9
10
|
|
|
@@ -131,28 +132,29 @@ const ButtonTitle = /*#__PURE__*/styled__default["default"].label.withConfig({
|
|
|
131
132
|
sizeVariant
|
|
132
133
|
}) => theme.components.button[size][sizeVariant].textLabel.textCase);
|
|
133
134
|
|
|
134
|
-
|
|
135
|
+
const Button = /*#__PURE__*/react.forwardRef(({
|
|
135
136
|
dataTestId,
|
|
136
|
-
disabled = false,
|
|
137
|
-
title = '',
|
|
137
|
+
disabled: _disabled = false,
|
|
138
|
+
title: _title = '',
|
|
138
139
|
variant,
|
|
139
140
|
size,
|
|
140
141
|
iconRight,
|
|
141
142
|
iconLeft,
|
|
142
|
-
fullWidth = false,
|
|
143
|
-
type = 'button',
|
|
143
|
+
fullWidth: _fullWidth = false,
|
|
144
|
+
type: _type = 'button',
|
|
144
145
|
onClick
|
|
145
|
-
}) {
|
|
146
|
+
}, ref) => {
|
|
146
147
|
return jsxRuntime.jsx(Button$1, {
|
|
147
148
|
"data-testid": dataTestId,
|
|
148
149
|
variant: variant,
|
|
149
150
|
size: size,
|
|
150
151
|
sizeVariant: SizeVariant[variant],
|
|
151
152
|
inverseColors: variant === 'alternative',
|
|
152
|
-
disabled:
|
|
153
|
-
type:
|
|
154
|
-
fullWidth:
|
|
155
|
-
onClick: () => !
|
|
153
|
+
disabled: _disabled,
|
|
154
|
+
type: _type,
|
|
155
|
+
fullWidth: _fullWidth,
|
|
156
|
+
onClick: () => !_disabled && onClick && onClick(),
|
|
157
|
+
ref: ref,
|
|
156
158
|
children: jsxRuntime.jsxs(Container, {
|
|
157
159
|
size: size,
|
|
158
160
|
children: [iconLeft && jsxRuntime.jsx("div", {
|
|
@@ -162,10 +164,10 @@ function Button({
|
|
|
162
164
|
dataTestId: `buttonIcon-${iconLeft}`,
|
|
163
165
|
icon: iconLeft
|
|
164
166
|
})
|
|
165
|
-
}),
|
|
167
|
+
}), _title && jsxRuntime.jsx(ButtonTitle, {
|
|
166
168
|
size: size,
|
|
167
169
|
sizeVariant: SizeVariant[variant],
|
|
168
|
-
children:
|
|
170
|
+
children: _title
|
|
169
171
|
}), iconRight && jsxRuntime.jsx("div", {
|
|
170
172
|
className: "right-img-btn",
|
|
171
173
|
"data-testid": `left-img-btn-${iconRight}`,
|
|
@@ -176,6 +178,6 @@ function Button({
|
|
|
176
178
|
})]
|
|
177
179
|
})
|
|
178
180
|
});
|
|
179
|
-
}
|
|
181
|
+
});
|
|
180
182
|
|
|
181
183
|
exports.Button = Button;
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bolttech/atoms-button",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@bolttech/atoms-icon": "^0.1.14",
|
|
6
|
-
"@edirect/frontend-foundations": "0.0.
|
|
6
|
+
"@edirect/frontend-foundations": "0.0.67",
|
|
7
7
|
"react": "18.2.0",
|
|
8
8
|
"styled-components": "5.3.6"
|
|
9
9
|
},
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { ButtonProps } from './atoms-button.type';
|
|
2
|
-
export declare
|
|
3
|
+
export declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
4
|
+
export default Button;
|