Skip to content

Commit

Permalink
feature/page bg theme params (#34)
Browse files Browse the repository at this point in the history
* remove theme from sections and add it to page, add background color

* update sanity types

* remove theme from section container

* fix some text colors

* update preset

* remove bg options for sections, remove revalidate tokens console log

* enhance generators, make sure UI section is created when generating a storyblok component

* remove unused generators

* fix generators
  • Loading branch information
dogfrogfog authored Nov 6, 2024
1 parent 9e34b6c commit e7dffbf
Show file tree
Hide file tree
Showing 35 changed files with 637 additions and 291 deletions.
2 changes: 1 addition & 1 deletion apps/sanity/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default async function RootLayout({
lang="en"
// className={`${mono.variable} ${sans.variable} ${serif.variable}`}
>
<body className={"bg-white"}>{children}</body>
<body>{children}</body>
</html>
);
}
2 changes: 0 additions & 2 deletions apps/sanity/src/components/Footer/schema.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
CommonGroup,
commonGroups,
themeField,
} from "@/contentSections/commonFields";
import { defineField } from "sanity";

Expand Down Expand Up @@ -44,7 +43,6 @@ export default {
type: "string",
group: CommonGroup.Content,
}),
themeField,
],
preview: {
select: {
Expand Down
7 changes: 1 addition & 6 deletions apps/sanity/src/components/Header/schema.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
CommonGroup,
commonGroups,
themeField,
} from "@/contentSections/commonFields";
import { CommonGroup, commonGroups } from "@/contentSections/commonFields";
import { AlignVariant } from "@shared/ui/components/sections/header/types";
import { defineField } from "sanity";

Expand Down Expand Up @@ -49,7 +45,6 @@ export default {
validation: (Rule) => Rule.required(),
initialValue: AlignVariant.Right,
}),
themeField,
],
preview: {
select: {
Expand Down
6 changes: 3 additions & 3 deletions apps/sanity/src/components/Page/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SectionRenderer } from "@/contentSections";

import { CookieBanner } from "@shared/ui";
import { cn, CookieBanner } from "@shared/ui";

import Footer from "../Footer";
import Header from "../Header";
Expand All @@ -9,10 +9,10 @@ import type { IPageProps } from "./types";
export default function Page({ data }: IPageProps) {
if (!data) return null;

const { sectionsBody, showCookieBanner, header, footer } = data;
const { sectionsBody, showCookieBanner, header, footer, theme } = data;

return (
<div>
<div className={cn("bg-bgColor", theme)}>
<Header data={header} />
{sectionsBody?.map((section) => (
<SectionRenderer key={section._key} section={section} />
Expand Down
16 changes: 9 additions & 7 deletions apps/sanity/src/components/Page/schema.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { CommonGroup } from "@/contentSections/commonFields";
import {
CommonGroup,
commonGroups,
themeField,
} from "@/contentSections/commonFields";
// import { sectionsPresets } from "@/contentSections/presets";
import { definePathname } from "@tinloof/sanity-studio";
import { defineField, defineType } from "sanity";
import { defineField, defineType, type FieldGroupDefinition } from "sanity";

import sections from "@/lib/schemas/sections";

Expand All @@ -11,14 +15,12 @@ export default defineType({
type: "document",
name: "page",
groups: [
{
name: "content",
title: "Content",
default: true,
},
commonGroups[0] as FieldGroupDefinition,
{ name: "seo", title: "SEO" },
commonGroups[1] as FieldGroupDefinition,
],
fields: [
themeField,
defineField({
type: "string",
name: "title",
Expand Down
13 changes: 3 additions & 10 deletions apps/sanity/src/components/SectionContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,16 @@ export default function SectionContainer({
className,
sectionData,
}: ISectionContainerProps) {
const {
_key,
theme,
marginTop,
marginBottom,
paddingX,
paddingY,
noMaxWidth,
} = sectionData;
const { _key, marginTop, marginBottom, paddingX, paddingY, noMaxWidth } =
sectionData;

const cleanMarginTop = stegaClean(marginTop);
const cleanMarginBottom = stegaClean(marginBottom);

return (
<section
id={_key}
className={cn("bg-bgColor overflow-x-hidden", theme, className, {
className={cn("overflow-x-hidden", className, {
"mt-0": cleanMarginTop === "none",
"mb-0": cleanMarginBottom === "none",
"mt-sectionBase": cleanMarginTop === "base",
Expand Down
1 change: 0 additions & 1 deletion apps/sanity/src/components/SectionContainer/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
interface ISectionData {
_key: string;
theme?: "light" | "dark"; /// move to page
paddingX?: "none";
paddingY?: "none";
marginTop?: "none" | "base" | "lg";
Expand Down
2 changes: 0 additions & 2 deletions apps/sanity/src/contentSections/Blog/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
CommonGroup,
commonGroups,
sectionMarginFields,
themeField,
} from "../commonFields";

export const blogPost = defineType({
Expand Down Expand Up @@ -91,7 +90,6 @@ export default {
of: [{ type: blogPost.name }],
validation: (Rule) => Rule.required(),
}),
themeField,
...sectionMarginFields,
],
preview: {
Expand Down
2 changes: 0 additions & 2 deletions apps/sanity/src/contentSections/CardsGrid/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
CommonGroup,
commonGroups,
sectionMarginFields,
themeField,
} from "../commonFields";

const featurePointStyles = [
Expand Down Expand Up @@ -109,7 +108,6 @@ export default {
of: [{ type: "defaultCard" }],
validation: (Rule) => Rule.required().min(1),
}),
themeField,
...sectionMarginFields,
],
preview: {
Expand Down
2 changes: 0 additions & 2 deletions apps/sanity/src/contentSections/Copy/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
CommonGroup,
commonGroups,
sectionMarginFields,
themeField,
} from "../commonFields";

export default {
Expand All @@ -31,7 +30,6 @@ export default {
initialValue: false,
validation: (Rule) => Rule.required(),
}),
themeField,
...sectionMarginFields,
],
preview: {
Expand Down
1 change: 0 additions & 1 deletion apps/sanity/src/contentSections/Hero/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export default {
of: [{ type: customLink.name }],
validation: (Rule) => Rule.required(),
}),
// themeField,
...sectionMarginFields,
],
preview: {
Expand Down
2 changes: 0 additions & 2 deletions apps/sanity/src/contentSections/LinksList/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
CommonGroup,
commonGroups,
sectionMarginFields,
themeField,
} from "../commonFields";

export default {
Expand Down Expand Up @@ -39,7 +38,6 @@ export default {
validation: (Rule) => Rule.required(),
initialValue: AlignVariant.Left,
}),
themeField,
...sectionMarginFields,
],
preview: {
Expand Down
2 changes: 0 additions & 2 deletions apps/sanity/src/contentSections/Logos/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
CommonGroup,
commonGroups,
sectionMarginFields,
themeField,
} from "../commonFields";

export const logoItem = defineType({
Expand Down Expand Up @@ -79,7 +78,6 @@ export default {
validation: (Rule) => Rule.required(),
initialValue: AlignVariant.Left,
}),
themeField,
...sectionMarginFields,
],
preview: {
Expand Down
4 changes: 2 additions & 2 deletions apps/sanity/src/contentSections/commonFields.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { defineField } from "sanity";
import { defineField, type FieldGroupDefinition } from "sanity";

export enum CommonGroup {
Content = "content",
Style = "style",
}

export const commonGroups = [
export const commonGroups: FieldGroupDefinition[] = [
{
name: CommonGroup.Content,
title: "Content",
Expand Down
Loading

0 comments on commit e7dffbf

Please sign in to comment.