Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: download button colour and loader behaviour #1126

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions src/buttons/DownloadButton/DownloadButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ import {

import { MouseEventHandler } from 'react';

import { DEFAULT_LOADER_SIZE } from '@/constants.js';
import {
ActionButton,
ActionButtonVariant,
ColorVariants,
ColorVariantsType,
TooltipPlacement,
} from '@/types.js';

import { useButtonColor } from '../hooks.js';

export const DEFAULT_LOADER_SIZE = 24;

export type DownloadButtonProps = {
ariaLabel: string;
/**
Expand All @@ -36,7 +36,7 @@ export type DownloadButtonProps = {
/**
* CircularProgress's size
*/
loaderSize: number;
loaderSize?: number;
/**
* Tooltip's title
*/
Expand All @@ -52,7 +52,7 @@ const DownloadButton = ({
ariaLabel = 'download',
handleDownload,
isLoading = false,
color = ColorVariants.Primary,
color,
loaderSize = DEFAULT_LOADER_SIZE,
title = 'Download',
placement = 'bottom',
Expand All @@ -74,18 +74,20 @@ const DownloadButton = ({
);
case ActionButton.ICON_BUTTON:
default:
if (isLoading) {
return <CircularProgress color={color} size={loaderSize} />;
}
return (
<Tooltip title={title} placement={placement}>
<span>
<IconButton
disabled={isLoading}
color={color}
onClick={handleDownload}
aria-label={ariaLabel}
>
{icon}
{isLoading ? (
<CircularProgress color={color} size={loaderSize} />
) : (
icon
)}
</IconButton>
</span>
</Tooltip>
Expand Down
1 change: 0 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export const DRAWER_HEADER_HEIGHT = 55;

export const DEFAULT_THUMBNAIL_SIZE = ThumbnailSize.Small;
export const DEFAULT_LINK_SHOW_BUTTON = true;
export const DEFAULT_LOADER_SIZE = 20;

export const UNEXPECTED_ERROR_MESSAGE = 'An unexpected error occurred';
export const SMALL_AVATAR_SIZE = 40;
Expand Down