Skip to content

Commit df07623

Browse files
committed
feat: add technology button
1 parent 5a2bf62 commit df07623

File tree

3 files changed

+78
-24
lines changed

3 files changed

+78
-24
lines changed

apps/app/public/icons/add-icon.svg

Lines changed: 6 additions & 0 deletions
Loading
Lines changed: 52 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,61 @@
11
import { ReactElement } from "react";
2+
import { twMerge } from "tailwind-merge";
23
import { ActiveLink } from "../../ActiveLink";
34

45
type TechnologyProps = Readonly<{
6+
technology: string;
7+
technologyTitle: string;
8+
icon: ReactElement;
9+
}>;
10+
11+
export const Technology = ({ technology, technologyTitle, icon }: TechnologyProps) => (
12+
<TechnologyLink
13+
label={technologyTitle}
14+
title={`Wyświetl pytania z kategorii ${technologyTitle}`}
15+
href={`/questions/${technology}/1`}
16+
activeHref={`/questions/${technology}`}
17+
icon={icon}
18+
/>
19+
);
20+
21+
type TechnologyLinkProps = Readonly<{
522
href: string;
623
title: string;
24+
label: string;
725
icon: ReactElement;
26+
transparent?: boolean;
27+
activeHref?: string;
28+
target?: string;
829
}>;
930

10-
export const Technology = ({ href, title, icon }: TechnologyProps) => (
11-
<ActiveLink
12-
className="flex min-h-[85px] min-w-[85px] cursor-pointer flex-col items-center justify-center rounded-lg bg-white shadow-[0px_1px_4px] shadow-neutral-400 transition-colors hover:bg-violet-50 dark:bg-white-dark dark:shadow-neutral-900 hover:dark:bg-violet-900 small-filters:h-14 small-filters:min-h-[unset] small-filters:w-14 small-filters:min-w-[unset] small-filters:[&>svg]:h-7 small-filters:[&>svg]:w-7"
13-
activeClassName="border border-primary bg-violet-50 dark:bg-violet-900"
14-
title={`Wyświetl pytania z kategorii ${title}`}
15-
href={`/questions/${href}/1`}
16-
activeHref={`/questions/${href}`}
17-
mergeQuery
18-
>
19-
<span className="text-sm text-neutral-600 dark:text-neutral-200 small-filters:text-xs">
20-
{title}
21-
</span>
22-
{icon}
23-
</ActiveLink>
24-
);
31+
export const TechnologyLink = ({
32+
href,
33+
title,
34+
label,
35+
transparent,
36+
activeHref,
37+
icon,
38+
target,
39+
}: TechnologyLinkProps) => {
40+
return (
41+
<ActiveLink
42+
className={twMerge(
43+
`flex min-h-[85px] min-w-[85px] cursor-pointer flex-col items-center justify-center rounded-lg transition hover:bg-violet-50 hover:dark:bg-violet-900 small-filters:h-14 small-filters:min-h-[unset] small-filters:w-14 small-filters:min-w-[unset] small-filters:[&>svg]:h-7 small-filters:[&>svg]:w-7`,
44+
transparent
45+
? `hover:shadow-[0px_1px_4px] hover:shadow-neutral-400 hover:dark:bg-white-dark hover:dark:shadow-neutral-900`
46+
: `bg-white shadow-[0px_1px_4px] shadow-neutral-400 dark:bg-white-dark dark:shadow-neutral-900`,
47+
)}
48+
activeClassName="border border-primary bg-violet-50 dark:bg-violet-900"
49+
title={title}
50+
href={href}
51+
activeHref={activeHref}
52+
target={target}
53+
mergeQuery
54+
>
55+
<span className="text-sm text-neutral-600 dark:text-neutral-200 small-filters:text-xs">
56+
{label}
57+
</span>
58+
{icon}
59+
</ActiveLink>
60+
);
61+
};

apps/app/src/components/QuestionsSidebar/TechnologyFilter/TechnologyFilter.tsx

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,39 @@ import AngularLogo from "../../../../public/icons/angularjs-logo.svg";
77
import ReactLogo from "../../../../public/icons/reactjs-logo.svg";
88
import GitLogo from "../../../../public/icons/git-logo.svg";
99
import OtherLogo from "../../../../public/icons/other-logo.svg";
10+
import AddIcon from "../../../../public/icons/add-icon.svg";
1011

11-
import { Technology } from "./Technology";
12+
import { Technology, TechnologyLink } from "./Technology";
1213

1314
const technologyFilters = [
14-
{ href: "html", title: "HTML", icon: <HTMLLogo /> },
15-
{ href: "css", title: "CSS", icon: <CSSLogo /> },
16-
{ href: "js", title: "JS", icon: <JavaScriptLogo /> },
17-
{ href: "angular", title: "Angular", icon: <AngularLogo /> },
18-
{ href: "react", title: "React", icon: <ReactLogo /> },
19-
{ href: "git", title: "Git", icon: <GitLogo /> },
20-
{ href: "other", title: "Inne", icon: <OtherLogo /> },
15+
{ technology: "html", technologyTitle: "HTML", icon: <HTMLLogo /> },
16+
{ technology: "css", technologyTitle: "CSS", icon: <CSSLogo /> },
17+
{ technology: "js", technologyTitle: "JS", icon: <JavaScriptLogo /> },
18+
{ technology: "angular", technologyTitle: "Angular", icon: <AngularLogo /> },
19+
{ technology: "react", technologyTitle: "React", icon: <ReactLogo /> },
20+
{ technology: "git", technologyTitle: "Git", icon: <GitLogo /> },
21+
{ technology: "other", technologyTitle: "Inne", icon: <OtherLogo /> },
2122
] as const;
2223

2324
export const TechnologyFilter = () => {
2425
return (
2526
<QuestionsSidebarSection title="Wybierz technologię">
2627
<ul className="flex justify-between gap-x-4 overflow-x-auto px-4 pb-4 sm:flex-wrap sm:gap-x-0 sm:gap-y-5 sm:overflow-x-visible sm:p-0 small-filters:gap-y-2">
2728
{technologyFilters.map((tech) => (
28-
<li key={tech.href} className="pt-1">
29+
<li key={tech.technology} className="pt-1">
2930
<Technology {...tech} />
3031
</li>
3132
))}
33+
<li className="pt-1">
34+
<TechnologyLink
35+
href="https://github.com/typeofweb/devfaq/issues/new"
36+
icon={<AddIcon className="text-green-700" />}
37+
title="Czegoś brakuje? Zasugeruj dodanie nowej technologii"
38+
label="Dodaj"
39+
target="_blank"
40+
transparent={true}
41+
/>
42+
</li>
3243
</ul>
3344
</QuestionsSidebarSection>
3445
);

0 commit comments

Comments
 (0)