Skip to content

Commit

Permalink
💄 Add violet background to Tag component
Browse files Browse the repository at this point in the history
  • Loading branch information
petterhh committed Dec 2, 2024
1 parent f40e6b7 commit 7025e19
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/components/sections/jobs/JobPostingList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ export default function JobPostingList({
active={!locationFilter}
type="button"
onClick={() => setLocationFilter(null)}
text={"Alle"}
text="Alle"
background="violet"
/>
{companyLocations.map((location: CompanyLocation) => (
<Tag
Expand All @@ -66,6 +67,7 @@ export default function JobPostingList({
onClick={() => setLocationFilter(location)}
text={location.companyLocationName}
key={location._id}
background="violet"
/>
))}
</div>
Expand Down
19 changes: 16 additions & 3 deletions src/components/tag/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,22 @@ type TagInner =
href: string;
} & JSX.IntrinsicElements["link"]);

function getBackgroundClass(backgroundColor: string) {
switch (backgroundColor) {
case "light":
return "";
case "dark":
return styles["tag--bgDark"];
case "violet":
return styles["tag--bgViolet"];
default:
return "";
}
}

type TagProps = {
active?: boolean;
background?: "light" | "dark";
background?: "light" | "dark" | "violet";
text: string;
} & TagInner;

Expand All @@ -27,8 +40,8 @@ export const Tag = ({
...props
}: TagProps) => {
const activeClass = active ? styles["tag--active"] : "";
const bgDarkClass = background === "dark" ? styles["tag--bgDark"] : "";
const className = `${styles.tag} ${activeClass} ${bgDarkClass}`;
const bgClass = getBackgroundClass(background);
const className = `${styles.tag} ${activeClass} ${bgClass}`;
if (props.type === "button") {
return (
<button className={className} onClick={props.onClick}>
Expand Down
17 changes: 17 additions & 0 deletions src/components/tag/tag.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@
--_tag-background: transparent;
}

.tag--bgViolet {
--_tag-borderColor: var(--text-primary-light);
--_tag-color: var(--text-primary-light);
}
.tag--bgViolet:active {
--_tag-background: var(--text-primary-light);
--_tag-color: var(--text-primary);
}
.tag--bgViolet:hover {
--_tag-color: var(--text-primary-light);
--_tag-background: transparent;
}

.tag--active {
--_tag-background: var(--background-bg-dark);
--_tag-color: var(--text-primary-light);
Expand All @@ -49,3 +62,7 @@
--_tag-background: var(--background-bg-light-primary);
--_tag-color: var(--text-primary);
}
.tag--active.tag--bgViolet {
--_tag-background: var(--text-primary-light);
--_tag-color: var(--text-primary);
}

0 comments on commit 7025e19

Please sign in to comment.