Skip to content
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
2d1686a
Add filter controls barebones
danielfdsilva Apr 13, 2023
6241313
Fix styles for drop menu icon button
danielfdsilva Apr 14, 2023
affaf1b
Add Text Highlight component
danielfdsilva Apr 14, 2023
838976d
Implement draft version of data catalog filters
danielfdsilva Apr 14, 2023
dae6794
Remove list view mode
danielfdsilva Apr 17, 2023
166837e
Reposition catalog browse controls
ricardoduplos Apr 18, 2023
23f715a
Refactor control markup and styling
ricardoduplos Apr 18, 2023
399fb81
Add collapsible search input
danielfdsilva Apr 18, 2023
368e455
Add scrollable filters on small screens
danielfdsilva Apr 18, 2023
d05e738
Add pills with topics
danielfdsilva Apr 18, 2023
19a0f3f
Add featured discoveries
danielfdsilva Apr 18, 2023
656e3a5
Tweak pill default appearance
ricardoduplos Apr 18, 2023
4eafe9e
Fix grid blowout on card list
danielfdsilva Apr 19, 2023
49fb271
Add topics to dataset cards
danielfdsilva Apr 19, 2023
8113847
Tweak browse controls inner spacing
ricardoduplos Apr 19, 2023
65d2d33
Tweak catalog inner spacing
ricardoduplos Apr 19, 2023
0160723
Resize featured card
ricardoduplos Apr 19, 2023
79fbb6b
Update search field clear button
ricardoduplos Apr 19, 2023
5882294
Add meta information to dataset cards
danielfdsilva Apr 19, 2023
45972dc
Cleanup temporary data
danielfdsilva Apr 21, 2023
cb2fe78
Include dataset menu on data catalog page
danielfdsilva Apr 21, 2023
7f1f5e3
Separate notebook connect modal from button
danielfdsilva Apr 21, 2023
53ad725
Add analyse data option to datasets menu
danielfdsilva Apr 21, 2023
1ea16e6
Dataset menu for catalog page (#516)
danielfdsilva Apr 26, 2023
28b4133
Allow for datasets without thematics
danielfdsilva Apr 26, 2023
008b18b
Make search case insensitive
danielfdsilva Apr 26, 2023
533e880
Add clear filter button
danielfdsilva Apr 26, 2023
2d8368c
Scroll to filters on card tag click
danielfdsilva Apr 26, 2023
c58531f
Fix pill styles
danielfdsilva Apr 26, 2023
806767a
Use constant for all option
danielfdsilva Apr 26, 2023
fbf1247
Memoize prepareDatasets
danielfdsilva Apr 26, 2023
a95991e
Import types directly for react and mapbox
danielfdsilva Apr 27, 2023
b2836e7
Import mapboxgl map with alias
danielfdsilva Apr 27, 2023
bdbe1b4
Fix dataset count line height
danielfdsilva Apr 27, 2023
4651cc8
Remove clear button when there's no search
danielfdsilva Apr 27, 2023
8624306
Show character count message
danielfdsilva Apr 27, 2023
7fababa
Remove type pill from dataset cards
danielfdsilva Apr 27, 2023
37beffd
Make topics searchable
danielfdsilva Apr 27, 2023
e88bd14
Import types directly for react and mapbox (#517)
danielfdsilva Apr 27, 2023
2d886d3
Only show featured datasets on featured section
danielfdsilva Apr 27, 2023
12f3184
Merge branch 'main' into feature/data-catalog-search
danielfdsilva Apr 27, 2023
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
73 changes: 69 additions & 4 deletions app/scripts/components/common/card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ export const CardList = styled.ol`
${listReset()}
grid-column: 1 / -1;
display: grid;
grid-template-columns: repeat(1, 1fr);
gap: ${variableGlsp()};
grid-template-columns: repeat(1, 1fr);

${media.mediumUp`
grid-template-columns: repeat(2, 1fr);
Expand All @@ -42,6 +42,10 @@ export const CardList = styled.ol`
${media.largeUp`
grid-template-columns: repeat(3, 1fr);
`}

> li {
min-width: 0;
}
`;

function renderCardType({ cardType }: CardSelfProps) {
Expand Down Expand Up @@ -69,6 +73,11 @@ function renderCardType({ cardType }: CardSelfProps) {
padding-top: ${variableGlsp()};
color: ${themeVal('color.surface')};
justify-content: flex-end;
min-height: 16rem;

${media.mediumUp`
min-height: 28rem;
`}

${CardFigure} {
position: absolute;
Expand Down Expand Up @@ -169,6 +178,26 @@ export const CardOverline = styled(Overline)`
}
`;

export const CardMeta = styled.div`
display: flex;
gap: ${glsp(0.25)};

> a {
color: inherit;
pointer-events: all;

&,
&:visited {
text-decoration: none;
color: inherit;
}

&:hover {
opacity: 0.64;
}
}
`;

const CardLabel = styled.span`
position: absolute;
z-index: 1;
Expand Down Expand Up @@ -202,6 +231,39 @@ export const CardBody = styled.div`
}
`;

export const CardFooter = styled.div`
display: flex;
flex-flow: row nowrap;
gap: ${variableGlsp(0.5)};
padding: ${variableGlsp()};

&:not(:first-child) {
padding-top: 0;
margin-top: ${variableGlsp(-0.5)};
}

button {
pointer-events: all;
}
`;

export const CardTopicsList = styled.dl`
display: flex;
gap: ${variableGlsp(0.25)};
max-width: 100%;
width: 100%;
overflow: hidden;
mask-image: linear-gradient(
to right,
black calc(100% - 3rem),
transparent 100%
);

> dt {
${visuallyHidden()}
}
`;

const CardFigure = styled(Figure)`
order: -1;

Expand All @@ -214,18 +276,19 @@ const CardFigure = styled(Figure)`
`;

interface CardComponentProps {
title: string;
title: React.ReactNode;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just out of curiosity: do we have a set practice on using React types directly, rather than importing them (import React, { ReactNode } from 'react';)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we do. Do you favor one?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually import everything at the top of a file, so for consistency's sake, I don't see why this should be different for React types (especially in this file where we have 4 occurrences). Very much nitpicking though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nerik Did this in a separate PR because there were a lot of changes. #517

linkLabel: string;
linkTo: string;
className?: string;
cardType?: CardType;
description?: string;
description?: React.ReactNode;
date?: Date;
overline?: React.ReactNode;
imgSrc?: string;
imgAlt?: string;
parentName?: string;
parentTo?: string;
footerContent?: React.ReactNode;
onCardClickCapture?: React.MouseEventHandler;
}

Expand All @@ -243,6 +306,7 @@ function CardComponent(props: CardComponentProps) {
imgAlt,
parentName,
parentTo,
footerContent,
onCardClickCapture
} = props;

Expand All @@ -261,7 +325,7 @@ function CardComponent(props: CardComponentProps) {
<CardHeader>
<CardHeadline>
<CardTitle>{title}</CardTitle>
<CardOverline>
<CardOverline as='div'>
{parentName && parentTo && (
<CardLabel as={Link} to={parentTo}>
{parentName}
Expand All @@ -285,6 +349,7 @@ function CardComponent(props: CardComponentProps) {
<p>{description}</p>
</CardBody>
)}
{footerContent && <CardFooter>{footerContent}</CardFooter>}
{imgSrc && (
<CardFigure>
<img src={imgSrc} alt={imgAlt} loading='lazy' />
Expand Down
3 changes: 2 additions & 1 deletion app/scripts/components/common/dropdown-scrollable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import styled from 'styled-components';
import { glsp } from '@devseed-ui/theme-provider';
import {
Dropdown,
DropdownProps,
DropdownRef,
DropMenu,
DropTitle
Expand Down Expand Up @@ -31,7 +32,7 @@ const shadowScrollbarProps = {
autoHeightMax: 320
};

interface DropdownScrollableProps {
interface DropdownScrollableProps extends DropdownProps {
children?: React.ReactNode;
}

Expand Down
13 changes: 9 additions & 4 deletions app/scripts/components/common/fold.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export const FoldGrid = styled(Hug)`
padding-top: ${variableGlsp(2)};
padding-bottom: ${variableGlsp(2)};

& + & {
& + &,
& + ${FoldBase} {
padding-top: 0;
}
`;
Expand All @@ -33,10 +34,14 @@ const FoldInner = styled(Constrainer)`
export const FoldHeader = styled.div`
grid-column: 1 / -1;
display: flex;
flex-flow: row nowrap;
flex-flow: column nowrap;
gap: ${variableGlsp()};
justify-content: space-between;
align-items: flex-end;

${media.largeUp`
flex-flow: row nowrap;
justify-content: space-between;
align-items: flex-end;
`}

> a {
flex-shrink: 0;
Expand Down
124 changes: 73 additions & 51 deletions app/scripts/components/common/notebook-connect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
CollecticonCog
} from '@devseed-ui/collecticons';
import { Modal } from '@devseed-ui/modal';
import { DatasetData, datasets, VedaDatum } from 'veda';
import { DatasetData, datasets } from 'veda';

import { HintedError } from '$utils/hinted-error';
import { variableGlsp } from '$styles/variable-utils';
Expand All @@ -17,7 +17,7 @@ interface NotebookConnectButtonProps {
compact?: boolean;
variation?: ButtonProps['variation'];
size?: ButtonProps['size'];
dataset?: VedaDatum<DatasetData>;
dataset?: DatasetData;
className?: string;
}

Expand Down Expand Up @@ -86,19 +86,14 @@ const IconByType: Record<DatasetUsageType, any> = {
unknown: <CollecticonCog />
};

function NotebookConnectButtonSelf(props: NotebookConnectButtonProps) {
const {
className,
compact = true,
variation = 'primary-fill',
size = 'medium',
dataset
} = props;
export function NotebookConnectModal(props: {
dataset?: DatasetData;
revealed: boolean;
onClose: () => void;
}) {
const { dataset, revealed, onClose } = props;

const [revealed, setRevealed] = useState(false);
const close = useCallback(() => setRevealed(false), []);

const datasetUsages = dataset?.data.usage;
const datasetUsages = dataset?.usage;

const datasetUsagesWithIcon = useMemo(() => {
return datasetUsages?.map((d) => {
Expand All @@ -116,11 +111,70 @@ function NotebookConnectButtonSelf(props: NotebookConnectButtonProps) {
return null;
}

const layerIdsSet = dataset.data.layers.reduce(
const layerIdsSet = dataset.layers.reduce(
(acc, layer) => acc.add(layer.stacCol),
new Set<string>()
);

return (
<Modal
id='modal'
size='medium'
title='How to use this dataset'
revealed={revealed}
onCloseClick={onClose}
onOverlayClick={onClose}
closeButton
content={
<>
<DatasetUsages>
{datasetUsagesWithIcon.map((datasetUsage) => (
<li key={datasetUsage.url}>
<DatasetUsageLink href={datasetUsage.url}>
{IconByType[datasetUsage.type]}
<DatasetUsageLabel>
<h4>{datasetUsage.title}</h4>
<p>{datasetUsage.label}</p>
</DatasetUsageLabel>
</DatasetUsageLink>
</li>
))}
</DatasetUsages>
<p>
For reference, the following STAC collection ID&apos;s are
associated with this dataset:
</p>
<ul>
{Array.from(layerIdsSet).map((id) => (
<li key={id}>
<code>{id}</code>
</li>
))}
</ul>
</>
}
/>
);
}

function NotebookConnectButtonSelf(props: NotebookConnectButtonProps) {
const {
className,
compact = true,
variation = 'primary-fill',
size = 'medium',
dataset
} = props;

const [revealed, setRevealed] = useState(false);
const close = useCallback(() => setRevealed(false), []);

const datasetUsages = dataset?.usage;

if (!datasetUsages) {
return null;
}

return (
<>
<Button
Expand All @@ -134,42 +188,10 @@ function NotebookConnectButtonSelf(props: NotebookConnectButtonProps) {
<CollecticonCode meaningful={compact} title='Open data usage options' />
{compact ? '' : 'Analyze data (Python)'}
</Button>
<Modal
id='modal'
size='medium'
title='How to use this dataset'
<NotebookConnectModal
dataset={dataset}
revealed={revealed}
onCloseClick={close}
onOverlayClick={close}
closeButton
content={
<>
<DatasetUsages>
{datasetUsagesWithIcon.map((datasetUsage) => (
<li key={datasetUsage.url}>
<DatasetUsageLink href={datasetUsage.url}>
{IconByType[datasetUsage.type]}
<DatasetUsageLabel>
<h4>{datasetUsage.title}</h4>
<p>{datasetUsage.label}</p>
</DatasetUsageLabel>
</DatasetUsageLink>
</li>
))}
</DatasetUsages>
<p>
For reference, the following STAC collection ID&apos;s are
associated with this dataset:
</p>
<ul>
{Array.from(layerIdsSet).map((id) => (
<li key={id}>
<code>{id}</code>
</li>
))}
</ul>
</>
}
onClose={close}
/>
</>
);
Expand Down Expand Up @@ -214,7 +236,7 @@ function NotebookConnectCalloutSelf(props: NotebookConnectCalloutProps) {
<NotebookConnectButton
// compact={false}
variation='base-outline'
dataset={dataset}
dataset={dataset.data}
/>
</div>
);
Expand Down
Loading