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

Preview page metadata highlighting #291

Merged
merged 19 commits into from
Oct 25, 2021
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
2 changes: 1 addition & 1 deletion frontend/src/components/AppBar/AppBarPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import {
} from '@/components/common/icons';
import { Link } from '@/components/common/Link';
import { Media } from '@/components/common/media';
import { MetadataStatus } from '@/components/MetadataStatus';

import styles from './AppBarPreview.module.scss';
import { useMetadataSections } from './metadataPreview.hooks';
import { MetadataStatus } from './MetadataStatus';
import { PreviewMetadataPanel } from './PreviewMetadataPanel';

const HUB_WIKI_LINK =
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/AppBar/PreviewMetadataPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import clsx from 'clsx';

import { Media } from '@/components/common/media';
import { MetadataStatus } from '@/components/MetadataStatus';

import {
MetadataSectionField,
useMetadataSections,
} from './metadataPreview.hooks';
import { MetadataStatus } from './MetadataStatus';

/**
* Creates a new array of metadata fields that have the missing metadata ordered
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function MetadataStatus({
className={clsx(
'flex items-center justify-center',
hasValue ? 'bg-napari-primary' : 'bg-napari-preview-orange',
variant === 'small' && 'w-2 h-2',
variant === 'small' ? 'w-2 h-2' : 'w-[0.9375rem] h-[0.9375rem]',
)}
>
{hasValue ? <Check /> : <PriorityHigh color="#fff" />}
Expand Down
32 changes: 30 additions & 2 deletions frontend/src/components/PluginDetails/MetadataList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import clsx from 'clsx';
import { ReactNode } from 'react';

import { Link } from '@/components/common/Link';
import { MetadataStatus } from '@/components/MetadataStatus';
import { usePluginState } from '@/context/plugin';
import { usePlausible } from '@/hooks';

Expand Down Expand Up @@ -46,6 +47,9 @@ function MetadataListItem({ inline, title, values }: MetadataListItemProps) {

// Font
'font-bold whitespace-nowrap',

// Preview orange overlay
isEmpty && 'bg-napari-preview-orange-overlay',
)}
>
{title}:
Expand All @@ -54,12 +58,18 @@ function MetadataListItem({ inline, title, values }: MetadataListItemProps) {
<ul className={clsx('list-none space-y-5', inline ? 'inline' : 'block')}>
{isEmpty && (
<li
// Preview orange overlay if isValueEmpty is true
className={clsx(
'text-napari-gray font-normal',
inline ? 'inline' : 'block',
'text-napari-gray font-normal bg-napari-preview-orange-overlay flex justify-between items-center',
inline ? 'inline' : 'block leading-8',
)}
>
information not submitted
<Tooltip placement="right" title="MetadataStatus Text Placeholder">
<div>
<MetadataStatus hasValue={false} />
</div>
</Tooltip>
</li>
)}

Expand All @@ -68,13 +78,17 @@ function MetadataListItem({ inline, title, values }: MetadataListItemProps) {
let node: ReactNode;
let key: string;

let isValueEmpty = false;

if (typeof value === 'string') {
key = value;
node = value;
isValueEmpty = !value;
} else {
// If metadata value is link, render icon and anchor tag.
key = `${value.text}-${value.href}`;
const hasLink = !!value.href;
isValueEmpty = !hasLink;

const icon = (!hasLink && value.missingIcon) || value.icon;
const iconNode = icon && <span className="min-w-4">{icon}</span>;
Expand Down Expand Up @@ -136,10 +150,24 @@ function MetadataListItem({ inline, title, values }: MetadataListItemProps) {
// Render as comma list if inline
// https://markheath.net/post/css-comma-separated-list
inline && ['inline', styles.commaList],

// Preview orange overlay if isValueEmpty is true
isValueEmpty &&
'bg-napari-preview-orange-overlay flex justify-between items-center',
)}
key={key}
>
{node}
{isValueEmpty && (
<Tooltip
placement="right"
title="MetadataStatus Text Placeholder"
>
<div>
<MetadataStatus hasValue={false} />
</div>
</Tooltip>
)}
</li>
);
})}
Expand Down