Skip to content

Commit

Permalink
✨ Add openness section
Browse files Browse the repository at this point in the history
  • Loading branch information
petterhh committed Dec 11, 2024
1 parent 3ebbbf9 commit a8c1dd7
Show file tree
Hide file tree
Showing 10 changed files with 170 additions and 2 deletions.
6 changes: 6 additions & 0 deletions public/_assets/happy-smiley-face.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions src/components/sections/openness/Openness.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { SanityImage } from "src/components/image/SanityImage";
import SmileyBox from "src/components/smileyBox/SmileyBox";
import Text from "src/components/text/Text";
import { OpennessSection } from "studio/lib/interfaces/pages";

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

export interface OpennessProps {
section: OpennessSection;
}

export default function Openness({ section }: OpennessProps) {
return (
<div className={styles.wrapper}>
<div className={styles.title}>
<Text type={"h2"}>{section.basicTitle}</Text>
</div>
<div className={styles.content}>
<div className={styles.image}>
<SanityImage image={section.image} />
</div>
<SmileyBox description={section.description} />
</div>
</div>
);
}
32 changes: 32 additions & 0 deletions src/components/sections/openness/openness.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.wrapper {
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
max-width: var(--max-content-width-large);
padding: 0 2rem;
margin: 5rem auto;
gap: 2rem;
color: var(--text-primary);
}

.image {
height: 30rem;

& img {
border-radius: 0.375rem 6rem 0.375rem 0.375rem;
}
}

.title {
width: 40rem;
color: var(--text-primary);
}

.content {
display: flex;
flex-direction: row;
align-items: flex-start;
padding: 0.25rem;
gap: 1rem;
}
19 changes: 19 additions & 0 deletions src/components/smileyBox/SmileyBox.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Text from "src/components/text/Text";

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

type SmileyBoxProps = {
background?: "dark" | "light";
description: string;
};

export default function SmileyBox({ description }: SmileyBoxProps) {
return (
description && (
<div className={styles.wrapper}>
<div className={styles.smiley} />
<Text type={"h3"}>{description}</Text>
</div>
)
);
}
25 changes: 25 additions & 0 deletions src/components/smileyBox/smileyBox.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.wrapper {
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: flex-start;
height: 30rem;
min-width: var(19.75rem);
padding: 2.25rem;
border-radius: 6rem 6rem 0.375rem 0.375rem;
background-color: #dafbdc;
}

.smiley {
&::before {
content: "";
display: block;
width: 4.86119rem;
height: 4.86119rem;
-webkit-mask: url("/_assets/happy-smiley-face.svg") no-repeat center;
-webkit-mask-size: cover;
mask: url("/_assets/happy-smiley-face.svg") no-repeat center;
mask-size: cover;
background-color: var(--text-primary);
}
}
3 changes: 3 additions & 0 deletions src/utils/renderSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import ImageSectionComponentPreview from "src/components/sections/imageSection/I
import Jobs from "src/components/sections/jobs/Jobs";
import { LogoSalad } from "src/components/sections/logoSalad/LogoSalad";
import LogoSaladPreview from "src/components/sections/logoSalad/LogoSaladPreview";
import Openness from "src/components/sections/openness/Openness";
import { Testimonials } from "src/components/sections/testimonials/Testimonials";
import TestimonialsPreview from "src/components/sections/testimonials/TestimonialsPreview";
import { Locale } from "src/i18n/routing";
Expand Down Expand Up @@ -289,6 +290,8 @@ const SectionRenderer = ({
return <Jobs language={language} section={section} />;
case "employeeHighlight":
return <EmployeeHighlight section={section} />;
case "opennessSection":
return <Openness section={section} />;
default:
return null;
}
Expand Down
13 changes: 11 additions & 2 deletions studio/lib/interfaces/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export interface ContactBoxSection {
_key: string;
basicTitle: string;
optionalSubtitle?: string;
background: "light" | "dark";
background: "light" | "dark" | "transparent";
contactPoints: {
_key: string;
_type: string;
Expand Down Expand Up @@ -158,6 +158,14 @@ export interface EmployeeHighlightSection {
employeePhoto: IImage;
}

export interface OpennessSection {
_type: "opennessSection";
_key: string;
basicTitle: string;
image: IImage;
description: string;
}

export type Section =
| HeroSection
| LogoSaladSection
Expand All @@ -174,7 +182,8 @@ export type Section =
| EmployeesSection
| EmployeeHighlightSection
| CompensationCalculatorSection
| JobsSection;
| JobsSection
| OpennessSection;

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 @@ -85,6 +85,10 @@ const SECTIONS_FRAGMENT = groq`
_type == "employeeHighlight" => {
"basicTitle": ${translatedFieldFragment("basicTitle")},
"description": ${translatedFieldFragment("description")},
},
_type == "opennessSection" => {
"basicTitle": ${translatedFieldFragment("basicTitle")},
"description": ${translatedFieldFragment("description")},
}
}
`;
Expand Down
2 changes: 2 additions & 0 deletions studio/schemas/documents/pageBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import imageSection from "studio/schemas/objects/sections/image";
import imageSplitSection from "studio/schemas/objects/sections/imagesplit";
import { jobs } from "studio/schemas/objects/sections/jobs";
import logoSalad from "studio/schemas/objects/sections/logoSalad";
import { opennessSection } from "studio/schemas/objects/sections/openness";
import testimonals from "studio/schemas/objects/sections/testimonials";
import seo from "studio/schemas/objects/seo";
import { titleSlug } from "studio/schemas/schemaTypes/slug";
Expand Down Expand Up @@ -61,6 +62,7 @@ const pageBuilder = defineType({
jobs,
employeeHighlightSection,
compensationCalculator,
opennessSection,
],
}),
],
Expand Down
42 changes: 42 additions & 0 deletions studio/schemas/objects/sections/openness.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { defineField } from "sanity";

import { titleID } from "studio/schemas/fields/text";
export const opennessID = "opennessSection";

export const opennessSection = defineField({
name: opennessID,
title: "Openness",
type: "object",
fields: [
{
name: titleID.basic,
title: "Title",
description:
"Enter the primary title that will be displayed at the top of the section.",
type: "internationalizedArrayString",
},
{
name: "image",
type: "image",
title: "Image",
description: "An image of the openness",
options: {
hotspot: true,
},
},
{
name: "description",
title: "Description",
description:
"Enter the description that will be displayed in the smiley block.",
type: "internationalizedArrayString",
},
],
preview: {
prepare() {
return {
title: "Openness Section",
};
},
},
});

0 comments on commit a8c1dd7

Please sign in to comment.