Skip to content

Commit

Permalink
EDD-6: Tweaking more info button on autenticating state
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorlang authored and macrouch committed Jul 3, 2023
1 parent faa08f9 commit 65f89bd
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 48 deletions.
101 changes: 56 additions & 45 deletions src/app/components/DownloadItem/DownloadItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import PropTypes from 'prop-types'
import classNames from 'classnames'
import {
FaCheckCircle,
FaInfoCircle,
FaLock,
FaSpinner
} from 'react-icons/fa'
Expand Down Expand Up @@ -87,8 +88,9 @@ const DownloadItem = ({
if (state === downloadStates.waitingForAuth) {
primaryActions.push(
<Tooltip
content="Log In with Earthdata Login"
key="LogIn"
content="Log In with Earthdata Login"
delayDuration={300}
>
<Button
className={styles.action}
Expand All @@ -113,7 +115,11 @@ const DownloadItem = ({
actionGroup.forEach((action) => {
primaryActions.push(
(action.isActive && action.isPrimary) && (
<Tooltip content={action.label} key={action.label}>
<Tooltip
key={action.label}
content={action.label}
delayDuration={300}
>
<Button
className={styles.action}
size="sm"
Expand Down Expand Up @@ -233,59 +239,64 @@ const DownloadItem = ({
className={styles.statusDescription}
data-testid="download-item-status-description"
>
{
shouldShowProgress && (
<>
{commafy(finishedFiles)}
{
!loadingMoreFiles && (
<p className={styles.statusInformation}>
{
shouldShowProgress && (
<>
{commafy(finishedFiles)}
{
!loadingMoreFiles && (
<>
{' '}
of
{' '}
{commafy(totalFiles)}
</>
)
}
{' '}
files
</>
)
}
{
(
shouldShowTime && (
<>
{' '}
of
done in
{' '}
{commafy(totalFiles)}
{humanizeDuration(totalTime * 1000)}
</>
)
}
{' '}
files
</>
)
}
{
(
shouldShowTime && (
)
}
{
loadingMoreFiles && (
<>
{' '}
done in
(determining file count)
</>
)
}
{
state === downloadStates.waitingForAuth && (
<>
{' '}
{humanizeDuration(totalTime * 1000)}
Waiting for log in with Earthdata Login
{' '}
<Tooltip
content="This download requires authentication with Earthdata Login. If your browser did not automatically open, click Log In"
>
<span className={styles.statusInformationTooltip}>
<FaInfoCircle className={styles.statusInformationIcon} />
<span>More Info</span>
</span>
</Tooltip>
</>
)
)
}
{
loadingMoreFiles && (
<>
{' '}
(determining file count)
</>
)
}
{
state === downloadStates.waitingForAuth && (
<>
{' '}
Waiting for log in with Earthdata Login
{' '}
<Tooltip
content="This download requires authentication with Earthdata Login. If your browser did not automatically open, click Log In"
>
<span>(More Info)</span>
</Tooltip>
</>
)
}
}
</p>
</div>
)
}
Expand Down
24 changes: 24 additions & 0 deletions src/app/components/DownloadItem/DownloadItem.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,30 @@
}
}

.statusInformation {
display: flex;
align-items: center;
margin: 0;
}

.statusInformationTooltip {
display: inline-flex;
align-items: center;
justify-content: center;
margin-left: var(--size__150);
color: var(--color__black--600);
cursor: default;
text-decoration: underline;

&:hover {
color: var(--color__black--700);
}
}

.statusInformationIcon {
margin-right: var(--size__050);
}

.metaSecondary {
position: fixed;
display: flex;
Expand Down
5 changes: 4 additions & 1 deletion src/app/components/Dropdown/Dropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ const Dropdown = ({

return (
<RadixDropdown.Root modal="false">
<Tooltip content="More Actions">
<Tooltip
content="More Actions"
delayDuration={300}
>
<RadixDropdown.Trigger asChild className={styles.trigger}>
<Button
data-testid="dropdown-trigger"
Expand Down
9 changes: 7 additions & 2 deletions src/app/components/Tooltip/Tooltip.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import * as styles from './Tooltip.module.scss'

/**
* @typedef {Object} TooltipProps
* @property {React.ReactNode} [additionalContent] A React node to be used as the additional content for the tooltip.
* @property {React.ReactNode} children A React node to be wrapped in the tooltip trigger.
* @property {React.ReactNode} content A React node to be used as the content for the tooltip.
* @property {React.ReactNode} [additionalContent] A React node to be used as the additional content for the tooltip.
* @property {Number} delayDuration A number representing the tooltip delay in milliseconds.
* @property {Boolean} open A boolean representing the "open" state of the tooltip.
*/

/**
Expand All @@ -30,14 +32,15 @@ const Tooltip = ({
additionalContent,
children,
content,
delayDuration,
open
}) => {
const conditionalRootProps = {}

if (open) conditionalRootProps.open = true

return (
<RadixTooltip.Provider delayDuration={300}>
<RadixTooltip.Provider delayDuration={delayDuration}>
<RadixTooltip.Root {...conditionalRootProps}>
<RadixTooltip.Trigger asChild>
{children}
Expand Down Expand Up @@ -65,11 +68,13 @@ const Tooltip = ({

Tooltip.defaultProps = {
additionalContent: null,
delayDuration: 0,
open: undefined
}

Tooltip.propTypes = {
additionalContent: PropTypes.node,
delayDuration: PropTypes.number,
children: PropTypes.node.isRequired,
content: PropTypes.node.isRequired,
open: PropTypes.bool
Expand Down
5 changes: 5 additions & 0 deletions src/app/components/Tooltip/Tooltip.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
white-space: normal;
}

.triggerWrapper {
display: inline-flex;
cursor: pointer;
}

[data-radix-popper-content-wrapper] {
pointer-events: none;
user-select: none;
Expand Down
1 change: 1 addition & 0 deletions src/app/dialogs/InitializeDownload/InitializeDownload.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ const InitializeDownload = ({
<span className={styles.downloadLocationLabel}>Download files to</span>
<Tooltip
content="Change the selected download location"
delayDuration={300}
>
<button
className={styles.downloadLocationButton}
Expand Down

0 comments on commit 65f89bd

Please sign in to comment.