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

Add Employee Highlight section #943

Merged
merged 6 commits into from
Dec 5, 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
32 changes: 32 additions & 0 deletions src/components/sections/employeeHighlight/EmployeeHighlight.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { SanityImage } from "src/components/image/SanityImage";
import Text from "src/components/text/Text";
import { EmployeeHighlightSection } from "studio/lib/interfaces/pages";

import styles from "./employeeHighlight.module.css";

export interface EmployeeHighlightProps {
section: EmployeeHighlightSection;
}

export default function EmployeeHighLight({ section }: EmployeeHighlightProps) {
return (
<div className={styles.wrapper}>
<div className={styles.image}>
<SanityImage image={section.employeePhoto} />
</div>
<div className={styles.textContainer}>
<div className={styles.titleContainer}>
<Text type={"h5"} className={styles.title}>
{section.basicTitle}
</Text>
<div className={styles.nameContainer}>
<Text type={"h2"} className={styles.name}>
{section.name}
</Text>
</div>
</div>
<Text type={"bodyNormal"}>{section.description}</Text>
</div>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
.wrapper {
display: flex;
flex-direction: row;
justify-content: center;
padding: 0 2rem;
max-width: 64rem;
petterhh marked this conversation as resolved.
Show resolved Hide resolved
margin: 5rem auto;
gap: 1.5rem;
color: var(--text-primary);

@media (max-width: 834px) {
flex-direction: column;
margin-left: 2rem;
margin-right: 2rem;
}
}

.image {
min-width: 20rem;
width: 100%;
height: auto;
object-fit: cover;

& img {
border-radius: 0.375rem;
}

@media (max-width: 834px) {
max-width: 60%;
}
}

.textContainer {
display: flex;
flex-direction: column;
gap: 0.625rem;
}

.titleContainer {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 0;
}

.title {
padding: 0.25rem 1rem;
border-radius: 0.25rem 0.25rem 0rem 0rem;
background-color: var(--Violet-700);
color: var(--text-primary-light);
}

.nameContainer {
display: flex;
flex-direction: column;
align-items: flex-start;
padding: 0.25rem;
gap: 0.5rem;
border-radius: 0rem 0.25rem 0.25rem 0.25rem;
background: var(--Purple-700, #7022d6);
}

.name {
display: flex;
flex-direction: column;
padding: 0.25rem 0.75rem 0.125rem 0.75rem;
border-radius: 1.5rem;
background-color: var(--text-primary-light);
}
3 changes: 3 additions & 0 deletions src/utils/renderSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import CalloutPreview from "src/components/sections/callout/CalloutPreview";
import CallToAction from "src/components/sections/callToAction/CallToAction";
import CallToActionPreview from "src/components/sections/callToAction/CallToActionPreview";
import ContactBox from "src/components/sections/contact-box/ContactBox";
import EmployeeHighlight from "src/components/sections/employeeHighlight/EmployeeHighlight";
import Employees from "src/components/sections/employees/Employees";
import Grid from "src/components/sections/grid/Grid";
import GridPreview from "src/components/sections/grid/GridPreview";
Expand Down Expand Up @@ -258,6 +259,8 @@ const SectionRenderer = ({
return <Employees language={language} section={section} />;
case "jobs":
return <Jobs language={language} section={section} />;
case "employeeHighlight":
return <EmployeeHighlight section={section} />;
default:
return null;
}
Expand Down
12 changes: 11 additions & 1 deletion studio/lib/interfaces/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,15 @@ export interface JobsSection {
subtitle: string;
}

export interface EmployeeHighlightSection {
_type: "employeeHighlight";
_key: string;
basicTitle: string;
name: string;
description: string;
employeePhoto: IImage;
}

export type Section =
| HeroSection
| LogoSaladSection
Expand All @@ -128,7 +137,8 @@ export type Section =
| GridSection
| ContactBoxSection
| EmployeesSection
| JobsSection;
| JobsSection
| EmployeeHighlightSection;

export interface PageBuilder {
_createdAt: string;
Expand Down
4 changes: 4 additions & 0 deletions studio/lib/queries/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ const SECTIONS_FRAGMENT = groq`
_type == "jobs" => {
"basicTitle": ${translatedFieldFragment("basicTitle")},
"subtitle": ${translatedFieldFragment("subtitle")}
},
_type == "employeeHighlight" => {
"basicTitle": ${translatedFieldFragment("basicTitle")},
"description": ${translatedFieldFragment("description")},
}
}
`;
Expand Down
2 changes: 2 additions & 0 deletions studio/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import benefitsByLocation from "./schemas/objects/compensations/benefitsByLocati
import { footerSection } from "./schemas/objects/footerSection";
import jobPosting from "./schemas/objects/jobPosting";
import { link } from "./schemas/objects/link";
import { employeeHighlightSection } from "./schemas/objects/sections/employeeHighlight";
import seo from "./schemas/objects/seo";
import { socialMedia } from "./schemas/objects/socialMedia";

Expand Down Expand Up @@ -47,5 +48,6 @@ export const schema: { types: SchemaTypeDefinition[] } = {
announcement,
jobPosting,
jobPostings,
employeeHighlightSection,
],
};
2 changes: 2 additions & 0 deletions studio/schemas/documents/pageBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import article from "studio/schemas/objects/sections/article";
import callout from "studio/schemas/objects/sections/callout";
import callToAction from "studio/schemas/objects/sections/callToAction";
import contactBox from "studio/schemas/objects/sections/contact-box";
import { employeeHighlightSection } from "studio/schemas/objects/sections/employeeHighlight";
import { employees } from "studio/schemas/objects/sections/employees";
import grid from "studio/schemas/objects/sections/grid";
import hero from "studio/schemas/objects/sections/hero";
Expand Down Expand Up @@ -55,6 +56,7 @@ const pageBuilder = defineType({
employees,
contactBox,
jobs,
employeeHighlightSection,
],
}),
],
Expand Down
59 changes: 59 additions & 0 deletions studio/schemas/objects/sections/employeeHighlight.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { defineField } from "sanity";

import { isInternationalizedString } from "studio/lib/interfaces/global";
import { titleID } from "studio/schemas/fields/text";
import { firstTranslation } from "studio/utils/i18n";

export const employeeHighlightID = "employeeHighlight";

export const employeeHighlightSection = defineField({
name: employeeHighlightID,
title: "Employee Highlight",
type: "object",
fields: [
{
name: titleID.basic,
type: "internationalizedArrayString",
title: "Title",
description: "The title/prefix that will appear above the name block.",
},
{
name: "name",
type: "string",
title: "Name",
description: "The name of the employee.",
},
{
name: "description",
type: "internationalizedArrayText",
title: "Description",
description: "The body text in the section.",
},
{
name: "employeePhoto",
type: "image",
title: "Employee photo",
description: "A photo of the employee,",
options: {
hotspot: true,
},
},
],
preview: {
select: {
title: "basicTitle",
name: "name",
},
prepare({ title, name }) {
if (!isInternationalizedString(title)) {
throw new TypeError(
`Expected 'title' to be InternationalizedString, was ${typeof title}`,
);
}
return {
title: `${firstTranslation(title) ?? ""} ${name}`,
subtitle: "Employee highlight",
};
},
},
});
Loading