Merge pull request #11 from bluewave-labs/feat/image-buttons
Added start and end icon props to buttons to allow for images, made p…
This commit is contained in:
2 files changed
+48
-7
No files matched your search
@@ -24,22 +24,35 @@ const levelConfig = {
|
|||||||
* @typedef {Object} Props
|
* @typedef {Object} Props
|
||||||
* @property {'primary' | 'secondary' | 'tertiary' | 'error'} level - The level of the button
|
* @property {'primary' | 'secondary' | 'tertiary' | 'error'} level - The level of the button
|
||||||
* @property {string} label - The label of the button
|
* @property {string} label - The label of the button
|
||||||
|
* @property {React.ReactNode} [startIcon] - Icon prepended to the label
|
||||||
|
* @property {React.ReactNode} [endIcon] - Icon appended to the button label
|
||||||
* @property {boolean} [disabled] - Whether the button is disabled
|
* @property {boolean} [disabled] - Whether the button is disabled
|
||||||
|
* @property {(event: React.MouseEvent<HTMLButtonElement>) => void} [onClick] - The click handler of the button
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const Button = ({ level, label, disabled }) => {
|
const Button = ({ level, label, disabled, startIcon, endIcon, onClick }) => {
|
||||||
const { variant, color } = levelConfig[level];
|
const { variant, color } = levelConfig[level];
|
||||||
return (
|
return (
|
||||||
<MuiButton variant={variant} color={color} disabled={disabled}>
|
<MuiButton
|
||||||
|
variant={variant}
|
||||||
|
color={color}
|
||||||
|
disabled={disabled}
|
||||||
|
startIcon={startIcon}
|
||||||
|
endIcon={endIcon}
|
||||||
|
onClick={onClick}
|
||||||
|
>
|
||||||
{label}
|
{label}
|
||||||
</MuiButton>
|
</MuiButton>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
Button.propTypes = {
|
Button.propTypes = {
|
||||||
level: PropTypes.string.isRequired,
|
level: PropTypes.oneOf(["primary", "secondary", "tertiary", "error"]),
|
||||||
label: PropTypes.string.isRequired,
|
label: PropTypes.string.isRequired,
|
||||||
|
startIcon: PropTypes.node,
|
||||||
|
endIcon: PropTypes.node,
|
||||||
disabled: PropTypes.bool,
|
disabled: PropTypes.bool,
|
||||||
|
onClick: PropTypes.func,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Button;
|
export default Button;
|
||||||
@@ -2,6 +2,7 @@ import React from "react";
|
|||||||
import DropdownTeamMember from "../../Components/DropdownTeamMember";
|
import DropdownTeamMember from "../../Components/DropdownTeamMember";
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
import Button from "../../Components/Button";
|
import Button from "../../Components/Button";
|
||||||
|
import SettingsIcon from "@mui/icons-material/Settings";
|
||||||
|
|
||||||
const Home = () => {
|
const Home = () => {
|
||||||
return (
|
return (
|
||||||
@@ -13,10 +14,24 @@ const Home = () => {
|
|||||||
>
|
>
|
||||||
<h4>Buttons</h4>
|
<h4>Buttons</h4>
|
||||||
<div>
|
<div>
|
||||||
<Button level="primary" label="Primary" />
|
<Button
|
||||||
<Button level="secondary" label="Secondary" />
|
level="primary"
|
||||||
<Button level="tertiary" label="Tertiary" />
|
label="Primary"
|
||||||
<Button level="error" label="Error" />
|
onClick={() => {
|
||||||
|
alert("Primary");
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
level="secondary"
|
||||||
|
label="Secondary"
|
||||||
|
onClick={() => alert("Secondary")}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
level="tertiary"
|
||||||
|
label="Tertiary"
|
||||||
|
onClick={() => alert("Tertiary")}
|
||||||
|
/>
|
||||||
|
<Button level="error" label="Error" onClick={() => alert("Error")} />
|
||||||
</div>
|
</div>
|
||||||
<h4>Disabled Buttons</h4>
|
<h4>Disabled Buttons</h4>
|
||||||
<div>
|
<div>
|
||||||
@@ -25,6 +40,19 @@ const Home = () => {
|
|||||||
<Button level="tertiary" label="Tertiary" disabled />
|
<Button level="tertiary" label="Tertiary" disabled />
|
||||||
<Button level="error" label="Error" disabled />
|
<Button level="error" label="Error" disabled />
|
||||||
</div>
|
</div>
|
||||||
|
<h4>Image Button</h4>
|
||||||
|
<div>
|
||||||
|
<Button
|
||||||
|
level="tertiary"
|
||||||
|
label="Configure"
|
||||||
|
startIcon={<SettingsIcon />}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
level="tertiary"
|
||||||
|
label="Configure"
|
||||||
|
endIcon={<SettingsIcon />}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in new issue
Block a user