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

Data Catalog enhancement with floating filter sidebar #918

Merged
merged 27 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7a50528
Create new filters file
sandrahoang686 Apr 9, 2024
976c28e
Start building out form component
sandrahoang686 Apr 10, 2024
572d88e
Progress on filters
sandrahoang686 Apr 12, 2024
abaabb8
Add tags and more polish on filters
sandrahoang686 Apr 12, 2024
4b4d7d8
Update search and tags logic and add optimization hooks
sandrahoang686 Apr 16, 2024
bb77a5d
Organize cards logic to start modularizing...
sandrahoang686 Apr 16, 2024
e61da95
partially update some routing logic...
sandrahoang686 Apr 17, 2024
ac8d097
Update cards naming and add new card type
sandrahoang686 Apr 18, 2024
ca927cb
Fix more cards types... and add taxonomy tags to cards
sandrahoang686 Apr 18, 2024
d3f47fb
Moved tags and got to a place where globally selected tags are workin…
sandrahoang686 Apr 18, 2024
b60058b
successfully moved tags up
sandrahoang686 Apr 18, 2024
80a1f6f
Add pills, change default behavior of filters
sandrahoang686 Apr 18, 2024
1afb407
global filters working again
sandrahoang686 Apr 21, 2024
56ca482
AND, OR operators work for multiple taxonomy selections
sandrahoang686 Apr 21, 2024
652c95b
fix useCallback sideEffects, issue with clearing route fixed?
sandrahoang686 Apr 24, 2024
88c2b37
Move prepareDatasets to useEffect to update datasets to display on ch…
sandrahoang686 Apr 24, 2024
64a1b6d
Fix issue where some options were not displaying with space in taxono…
sandrahoang686 Apr 24, 2024
dd6735c
Tidy up Actions.TAXONOMY and include multiselect action
sandrahoang686 Apr 24, 2024
c013ca2
Make new view the main index file
sandrahoang686 Apr 24, 2024
44bc781
Fix conflicts
sandrahoang686 Apr 24, 2024
3ab4444
Fix issue of routing from dataset info page and organize cards better
sandrahoang686 Apr 24, 2024
f4c3e87
Remove some comments and update some styles
sandrahoang686 Apr 24, 2024
97d324f
More cleaning and add more memoization
sandrahoang686 Apr 24, 2024
4fade61
Bring card styles back to card file to support instances
sandrahoang686 Apr 25, 2024
c3e08d3
Give proper spacing
hanbyul-here Apr 25, 2024
19f56f7
Revert the cardlist style back
hanbyul-here Apr 25, 2024
278125c
Separate alldatasets from allexploredataset
hanbyul-here Apr 25, 2024
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
12 changes: 4 additions & 8 deletions app/scripts/components/analysis/results/chart-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,9 @@ import AnalysisMetricsDropdown, {
} from './analysis-metrics-dropdown';

import {
CardSelf,
CardHeader,
CardHeadline,
CardTitle,
CardActions,
CardBody
CardItem
} from '$components/common/card';
import { CardHeader, CardHeadline, CardActions, CardTitle, CardBody } from '$components/common/card/styles';
import Chart, { AnalysisChartRef } from '$components/common/chart/analysis';
import { ChartLoading } from '$components/common/loading-skeleton';
import { dateFormatter } from '$components/common/chart/utils';
Expand Down Expand Up @@ -189,7 +185,7 @@ export default function ChartCard(props: ChartCardProps) {
);

return (
<CardSelf>
<CardItem>
<CardHeader>
<CardHeadline>
<CardTitle>{title}</CardTitle>
Expand Down Expand Up @@ -298,6 +294,6 @@ export default function ChartCard(props: ChartCardProps) {
)
) : null}
</CardBody>
</CardSelf>
</CardItem>
);
}
4 changes: 2 additions & 2 deletions app/scripts/components/analysis/results/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
import ChartCard from './chart-card';
import AnalysisHead from './analysis-head';
import { LayoutProps } from '$components/common/layout-root';
import { CardList } from '$components/common/card';
import { CardListGrid } from '$components/common/card/styles';
import {
Fold,
FoldHeader,
Expand All @@ -36,7 +36,7 @@ import { pluralize } from '$utils/pluralize';
import { calcFeatCollArea } from '$components/common/aoi/utils';
import { ANALYSIS_PATH, ANALYSIS_RESULTS_PATH } from '$utils/routes';

const ChartCardList = styled(CardList)`
const ChartCardList = styled(CardListGrid)`
> li {
min-width: 0;
}
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/components/common/browse-controls/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function BrowseControls(props: BrowseControlsProps) {
key={name}
prefix={name}
items={[optionAll].concat(values)}
currentId={taxonomies?.[name] ?? 'all'}
currentId={(taxonomies?.[name] as string) || 'all'}
onChange={(v) => {
onAction(Actions.TAXONOMY, { key: name, value: v });
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export enum Actions {
SEARCH = 'search',
SORT_FIELD = 'sfield',
SORT_DIR = 'sdir',
TAXONOMY = 'taxonomy'
TAXONOMY = 'taxonomy',
TAXONOMY_MULTISELECT = 'taxonomy_multiselect',
}

export type BrowserControlsAction = (what: Actions, value?: any) => void;
Expand Down Expand Up @@ -79,12 +80,12 @@ export function useBrowserControls({ sortOptions }: BrowseControlsHookParams) {
[]
);

const [taxonomies, setTaxonomies] = useQsState.memo<Record<string, string>>(
const [taxonomies, setTaxonomies] = useQsState.memo<Record<string, string | string[]>>(
{
key: Actions.TAXONOMY,
default: {},
dehydrator: (v) => JSON.stringify(v),
hydrator: (v) => (v ? JSON.parse(v) : {})
dehydrator: (v) => JSON.stringify(v), // dehydrator defines how a value is stored in the url
hydrator: (v) => (v ? JSON.parse(v) : {}) // hydrator defines how a value is read from the url
},
[]
);
Expand Down Expand Up @@ -115,7 +116,26 @@ export function useBrowserControls({ sortOptions }: BrowseControlsHookParams) {
}
}
break;
case Actions.TAXONOMY_MULTISELECT:
{
const { key, value: val } = value;
if (taxonomies && (key in taxonomies)) { // If taxonomy group currently present
const taxonomyGroupValues = taxonomies[key] instanceof Array ? (taxonomies[key] as string[]) : [taxonomies[key]];

if (taxonomyGroupValues.includes(val)) { // If val exists, then remove
const updatedValues = taxonomyGroupValues.filter((x) => x !== val);
updatedValues.length ? setTaxonomies(set({ ...taxonomies }, key, updatedValues)) : setTaxonomies(omit(taxonomies, key));
} else { // else add
taxonomyGroupValues.push(val);
setTaxonomies(taxonomies);
}
} else { // Taxonomy group currently not present
setTaxonomies(set({ ...taxonomies }, key, [val]));
}
}
break;
}

},
[setSortField, setSortDir, taxonomies, setTaxonomies, setSearch]
);
Expand Down
104 changes: 104 additions & 0 deletions app/scripts/components/common/card/horizontal-info-card.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import React from 'react';
import styled, { css } from 'styled-components';
import {
glsp,
themeVal,
} from '@devseed-ui/theme-provider';
import { CardTitle } from './styles';
import { variableBaseType } from '$styles/variable-utils';
import { Pill } from '$styles/pill';

const HorizontalCard = styled.div`
display: flex;
height: inherit;
`;

const CardImage = styled.div`
min-width: 10rem;
width: 10rem;
height: 100%;
img {
width: 100%;
height: 100%;
object-fit: cover;
}
`;

const CardContent = styled.div`
display: flex;
flex-direction: column;
padding: 1.5rem 1rem;
`;

export const HorizontalCardStyles = css`
height: 10rem;
color: ${themeVal('color.base-800')};

${CardTitle} {
font-size: ${variableBaseType('0.7rem')};
}

#description {
font-size: ${variableBaseType('0.6rem')};
height: 3rem;
margin: 0.5rem 0;
overflow: hidden;
text-overflow: ellipsis;

/* stylelint-disable-next-line value-no-vendor-prefix */
display: -webkit-box;
-webkit-line-clamp: 2; /* number of lines to show */
line-clamp: 2;

/* stylelint-disable-next-line property-no-vendor-prefix */
-webkit-box-orient: vertical;
}

#tags {
display: flex;
gap: ${glsp(0.5)};
}
`;

interface Props {
title: JSX.Element | string;
description?: JSX.Element | string;
imgSrc?: string;
imgAlt?: string;
tagLabels?: string[];
}

export default function HorizontalInfoCard(props: Props) {
const {
title,
description,
imgSrc,
imgAlt,
tagLabels,
} = props;

return (
<HorizontalCard>
<CardImage>
<img src={imgSrc} alt={imgAlt} loading='lazy' />
</CardImage>
<CardContent>
<CardTitle>{title}</CardTitle>
<div id='description'>
<p>{description}</p>
</div>
<div id='tags'>
{
tagLabels && (
tagLabels.map((label) => (
<Pill variation='primary' key={label}>
{label}
</Pill>
))
)
}
</div>
</CardContent>
</HorizontalCard>
);
}
Loading
Loading