Skip to content

Commit

Permalink
Allow additional classes to be specified on the clean up button (#1737)
Browse files Browse the repository at this point in the history
* Allow additional classes to be specified on the clean up button

* Add 'fit' size to button

* Add size property to CleanUpButton
  • Loading branch information
rtorrero authored Aug 24, 2023
1 parent d31a8f3 commit 5a74ca7
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 3 deletions.
2 changes: 2 additions & 0 deletions assets/js/components/Button/Button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ const getSizeClasses = (size) => {
switch (size) {
case 'small':
return 'py-1 px-2 text-sm';
case 'fit':
return 'text-sm';
default:
return 'py-2 px-4 text-base';
}
Expand Down
15 changes: 15 additions & 0 deletions assets/js/components/Button/Button.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ import Button from '.';
export default {
title: 'Button',
component: Button,
argTypes: {
size: {
control: { type: 'radio' },
options: ['small', 'fit'],
description: 'Button size',
table: {
type: { summary: 'string' },
defaultValue: { summary: 'small' },
},
},
},
};

export function Default() {
Expand All @@ -27,6 +38,10 @@ export function Small() {
return <Button size="small">Hello world!</Button>;
}

export function Fit() {
return <Button size="fit">Hello world!</Button>;
}

export function SmallSecondary() {
return (
<Button size="small" type="secondary">
Expand Down
12 changes: 9 additions & 3 deletions assets/js/components/CleanUpButton/CleanUpButton.jsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
import React from 'react';

import { EOS_CLEANING_SERVICES } from 'eos-icons-react';
import classNames from 'classnames';

import Button from '@components/Button';
import Spinner from '@components/Spinner';

function CleanUpButton({ cleaning, onClick }) {
function CleanUpButton({ className, size = 'small', cleaning, onClick }) {
const buttonClasses = classNames(
'inline-block mx-0.5 border-green-500 border w-fit',
className
);

return (
<Button
type="primary-white"
className="inline-block mx-0.5 border-green-500 border w-fit"
size="small"
className={buttonClasses}
size={size}
disabled={cleaning}
onClick={() => onClick()}
>
Expand Down
24 changes: 24 additions & 0 deletions assets/js/components/CleanUpButton/CleanUpButton.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,22 @@ export default {
},
},
onClick: { action: 'Click button' },
className: {
control: 'text',
description: 'CSS classes',
table: {
type: { summary: 'string' },
},
},
size: {
control: { type: 'radio' },
options: ['small', 'fit'],
description: 'Button size',
table: {
type: { summary: 'string' },
defaultValue: { summary: 'small' },
},
},
},
};

Expand All @@ -26,3 +42,11 @@ export const Cleaning = {
cleaning: true,
},
};

export const NoOutline = {
args: {
...Default.args,
className: 'border-none shadow-none',
size: 'fit',
},
};
2 changes: 2 additions & 0 deletions assets/js/components/HostsList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ function HostsList() {
content && (
<CleanUpButton
cleaning={item.deregistering}
size="fit"
className="border-none shadow-none"
onClick={() => {
openDeregistrationModal(item);
}}
Expand Down

0 comments on commit 5a74ca7

Please sign in to comment.