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

Move the see all data sources chip into the link chip group #4803

Merged
merged 2 commits into from
Dec 17, 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
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ export function StatVarQueries({ queries }: StatVarQueriesProps): ReactElement {
id: query.url,
title: query.title,
url: query.url,
variant: "flat",
}));

if (queries.length === 0) {
return null;
}
return (
<LinkChips
variant="flat"
header={
"Explore statistical variables around the world in the Timeline explorer tool"
}
Expand Down
1 change: 1 addition & 0 deletions static/js/apps/homepage/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export function App({
id: topic.id,
title: topic.title,
url: topic.browseUrl,
variant: "elevated",
}));

return (
Expand Down
22 changes: 8 additions & 14 deletions static/js/apps/homepage/components/home_hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ interface HomeHeroProps {

export const HomeHero = ({ linkChips }: HomeHeroProps): ReactElement => {
const theme = useTheme();

linkChips.push({
id: "data-sources",
title: "See all available data sources",
url: "https://docs.datacommons.org/datasets/",
variant: "flat",
});

return (
<HeroColumns>
<HeroColumns.Left>
Expand All @@ -53,20 +61,6 @@ export const HomeHero = ({ linkChips }: HomeHeroProps): ReactElement => {
section="topic"
linkChips={linkChips}
/>
<div
css={css`
margin-top: ${theme.spacing.xxl}px;
`}
>
<LinkChip
variant="flat"
linkChip={{
id: "data-sources",
title: "See all available data sources",
url: "https://docs.datacommons.org/datasets/",
}}
/>
</div>
</HeroColumns.Right>
</HeroColumns>
);
Expand Down
15 changes: 9 additions & 6 deletions static/js/components/content/link_chips.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ export const LinkChips = ({
linkChips,
}: LinkChipsProps): ReactElement => {
const theme = useTheme();

linkChips.map((lc) => {
if (!lc.variant) {
lc.variant = variant;
}
return lc;
});

return (
<>
{header && (
Expand Down Expand Up @@ -88,12 +96,7 @@ export const LinkChips = ({
`}
>
{linkChips.map((linkChip) => (
<LinkChip
key={linkChip.id}
variant={variant}
section={section}
linkChip={linkChip}
/>
<LinkChip key={linkChip.id} section={section} linkChip={linkChip} />
))}
</div>
</>
Expand Down
17 changes: 9 additions & 8 deletions static/js/components/elements/link_chip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,31 +40,32 @@ export interface Link {
title: string;
//the url of the chip link
url: string;
//the variant of the link chip
variant?: "elevated" | "flat";
}

interface LinkChipProps {
//the variant of the link chip to display: elevated is a raised grey chip and flat is a flat blue chip
variant?: "elevated" | "flat";
//the link chip to be displayed
linkChip: Link;
//the section gives location of the chip component in order to give context for the GA event
section?: string;
}

export const LinkChip = ({
variant = "elevated",
linkChip,
section = "",
}: LinkChipProps): ReactElement => {
const theme = useTheme();

const chipStyles = css`
${variant === "elevated" ? theme.box.primary : theme.box.secondary};
${variant === "elevated" ? theme.elevation.primary : ""};
${linkChip.variant === "elevated"
? theme.box.primary
: theme.box.secondary};
${linkChip.variant === "elevated" ? theme.elevation.primary : ""};
${theme.typography.family.text};
${theme.typography.text.md};
${theme.radius.primary};
color: ${variant === "elevated"
color: ${linkChip.variant === "elevated"
? theme.colors.link.primary.base
: theme.colors.text.primary.base};
line-height: 1rem;
Expand All @@ -77,7 +78,7 @@ export const LinkChip = ({

&:hover {
text-decoration: none;
color: ${variant === "elevated"
color: ${linkChip.variant === "elevated"
? theme.colors.link.primary.base
: theme.colors.text.primary.base};
.icon {
Expand All @@ -88,7 +89,7 @@ export const LinkChip = ({
.icon {
transition: transform 0.1s ease-in-out;
svg {
fill: ${variant === "elevated"
fill: ${linkChip.variant === "elevated"
? theme.colors.link.primary.base
: theme.colors.text.primary.base};
}
Expand Down
Loading