Skip to content

Commit

Permalink
Refactor project components and styles for improved theming and badge…
Browse files Browse the repository at this point in the history
… display.
  • Loading branch information
izzet committed Nov 13, 2024
1 parent 20ad35e commit 8499166
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 10 deletions.
11 changes: 9 additions & 2 deletions src/components/home/HomepageProjects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,22 @@ import styles from "./HomepageProjects.module.css";

export default function HomepageProjects({
className,
}: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>): JSX.Element {
}: React.DetailedHTMLProps<
React.HTMLAttributes<HTMLElement>,
HTMLElement
>): JSX.Element {
const featuredProjects = projects.filter((project) => project.isFeatured);
return (
<section className={clsx(styles.projects, className)}>
<SectionHeader>Featured projects</SectionHeader>
<div className="container">
<div className="row">
{featuredProjects.map((project) => (
<ProjectItem key={project.id} project={project} />
<ProjectItem
isThemeLight={true}
key={project.id}
project={project}
/>
))}
</div>
</div>
Expand Down
4 changes: 4 additions & 0 deletions src/components/projects/ProjectBadges.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.badgeDarker {
background-color: var(--ifm-color-secondary-darker);
border-color: var(--ifm-color-secondary-darker);
}
37 changes: 31 additions & 6 deletions src/components/projects/ProjectBadges.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,44 @@ type ProjectBadgesProps = {
projectId: ProjectId;
};

export default function ProjectBadges({ addMargin = true, projectId }: ProjectBadgesProps) {
const { isOpenSource = false, isOurs = false, type } = getProjectById(projectId);
import styles from "./ProjectBadges.module.css";

export default function ProjectBadges({
addMargin = true,
projectId,
}: ProjectBadgesProps) {
const {
isOpenSource = false,
isOurs = false,
type,
} = getProjectById(projectId);
const isFunded = type === "funded";
// Check if all false
if (!isFunded && !isOpenSource && !isOurs) {
return null;
}
return (
<div className={clsx(addMargin && "margin-bottom--md")} style={{ lineHeight: 1 }}>
{isOurs && <span className="badge badge--primary margin-horiz--xs">GRC-LED</span>}
<div
className={clsx(addMargin && "margin-bottom--md")}
style={{ lineHeight: 1 }}
>
{isOurs && (
<span className="badge badge--primary margin-horiz--xs">GRC-LED</span>
)}
{/* {isFeatured && <span className="badge badge--info margin-horiz--xs">FEATURED</span>} */}
{isFunded && <span className="badge badge--success margin-horiz--xs">FUNDED</span>}
{isOpenSource && <span className="badge badge--secondary margin-horiz--xs">OPEN SOURCE</span>}
{isFunded && (
<span className="badge badge--success margin-horiz--xs">FUNDED</span>
)}
{isOpenSource && (
<span
className={clsx(
"badge badge--secondary margin-horiz--xs",
styles.badgeDarker
)}
>
OPEN SOURCE
</span>
)}
</div>
);
}
8 changes: 8 additions & 0 deletions src/components/projects/ProjectItem.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.card {
/* border-radius: var(--ifm-global-radius); */
box-shadow: none;
}

.cardDarker {
background-color: var(--ifm-color-emphasis-200);
}
17 changes: 15 additions & 2 deletions src/components/projects/ProjectItem.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
import Link from "@docusaurus/Link";
import React from "react";
import clsx from "clsx";
import { Project } from "@site/src/types";

import ProjectBadges from "./ProjectBadges";

type ProjectItemProps = {
project: Project;
isThemeLight?: boolean;
};

export default function ProjectItem({ project }: ProjectItemProps) {
import styles from "./ProjectItem.module.css";

export default function ProjectItem({
project,
isThemeLight = false,
}: ProjectItemProps) {
const { id, link, name, title, shortDescription } = project;
return (
<div className="col col--4 margin-bottom--lg">
<div className="card text--center">
<div
className={clsx(
"card text--center",
styles.card,
!isThemeLight && styles.cardDarker
)}
>
<div className="card__header">
<h3>{title}</h3>
<ProjectBadges addMargin={false} projectId={id} />
Expand Down

0 comments on commit 8499166

Please sign in to comment.