Skip to content

Commit

Permalink
fix: architecture issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelbr committed Dec 13, 2024
1 parent 6cc6c9c commit bf1d75e
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 42 deletions.
10 changes: 5 additions & 5 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module.exports = {
{
mode: "full",
type: "schema",
pattern: ["studioShared/schema/**/*", "studio/schema/**/*"],
pattern: ["studioShared/schemas/**/*", "studio/schemas/**/*"],
},
{
mode: "full",
Expand All @@ -53,12 +53,12 @@ module.exports = {
{
mode: "full",
type: "studioComponents",
pattern: ["studio/components/**/*", "sharedStudio/components/**/*"],
pattern: ["studio/components/**/*", "studioShared/components/**/*"],
},
{
mode: "full",
type: "studioLib",
pattern: ["studio/lib/**/*", "sharedStudio/lib/**/*"],
pattern: ["studio/lib/**/*", "studioShared/lib/**/*"],
},
],
},
Expand All @@ -79,7 +79,7 @@ module.exports = {
rules: [
{
from: ["schema"],
allow: ["schema", "studioComponents"],
allow: ["schema", "studioComponents", "studioLib"],
},
{
from: ["studioComponents"],
Expand All @@ -88,7 +88,7 @@ module.exports = {
{
from: ["studioLib"],
allow: ["studioLib"],
disallow: ["schema", "studioComponents"],
disallow: ["schema", "studioComponents", "app"],
},
{
from: ["app"],
Expand Down
2 changes: 1 addition & 1 deletion src/app/(main)/[locale]/[...path]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import { getDraftModeInfo } from "src/utils/draftmode";
import { fetchPageDataFromParams } from "src/utils/pageData";
import SectionRenderer from "src/utils/renderSection";
import {
SeoData,
generateMetadataFromSeo,
seoDataFromChewbaccaEmployee,
seoDataFromCustomerCase,
} from "src/utils/seo";
import { SeoData } from "studio/lib/interfaces/seo";

export const dynamic = "force-dynamic";

Expand Down
4 changes: 2 additions & 2 deletions src/components/navigation/mockData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import {
SectionType,
} from "studio/lib/interfaces/navigation";
import { SocialMediaProfiles } from "studio/lib/interfaces/socialMedia";
import { callToActionFieldID } from "studio/schemas/fields/callToActionFields";
import { linkID } from "studio/schemas/objects/link";

const callToActionFieldID = "callToActionField";
const linkID = "link";
// Mock Navigation Data
export const mockNavigation: Navigation = {
_id: "main-navigation",
Expand Down
2 changes: 1 addition & 1 deletion src/components/sections/article/mockData.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { PortableTextBlock } from "sanity";

import placeholder from "src/stories/assets/image-placeholder.png";
import { ImageAlignment } from "studio/lib/interfaces/media";
import { LinkType } from "studio/lib/interfaces/navigation";
import { ArticleSection } from "studio/lib/interfaces/pages";
import { ImageAlignment } from "studio/schemas/fields/media";

const commonRichText: PortableTextBlock[] = [
{
Expand Down
2 changes: 1 addition & 1 deletion src/components/sections/image-split/ImageSplit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { SanityImage } from "src/components/image/SanityImage";
import LinkButton from "src/components/linkButton/LinkButton";
import Text, { TextType } from "src/components/text/Text";
import { cnIf } from "src/utils/css";
import { ImageAlignment } from "studio/lib/interfaces/media";
import { ImageSplitSection } from "studio/lib/interfaces/pages";
import { ImageAlignment } from "studio/schemas/fields/media";

import styles from "./image-split.module.css";

Expand Down
3 changes: 2 additions & 1 deletion studio/components/ClearLinkFieldsButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { Button } from "@sanity/ui";
import { useFormValue } from "sanity";

import { client } from "studio/lib/client";
import { linkID } from "studio/schemas/objects/link";

const linkID = "link";

interface ClearLinkFieldsButtonProps {
path: Array<string | { _key: string }>;
Expand Down
10 changes: 9 additions & 1 deletion studio/lib/interfaces/media.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import { SanityImageSource } from "@sanity/image-url/lib/types/types";

import { ImageAlignment } from "studio/schemas/fields/media";
export enum ImageAlignment {
Left = "left",
Right = "right",
}

export enum ImageSize {
Large = "large",
Small = "small",
}

interface IHotspot {
x: number;
Expand Down
4 changes: 1 addition & 3 deletions studio/lib/interfaces/socialMedia.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { soMeLinksID } from "studio/schemas/documents/siteSettings/socialMediaProfiles";

// Define the SocialMediaLink interface based on the expected structure
export interface SocialMediaLink {
_type: string;
Expand All @@ -11,6 +9,6 @@ export interface SocialMediaLink {
// Define the SocialMediaProfiles interface based on the document schema
export interface SocialMediaProfiles {
_id: string;
_type: typeof soMeLinksID;
_type: "soMeLinksID";
soMeLinkArray?: SocialMediaLink[];
}
11 changes: 1 addition & 10 deletions studio/schemas/fields/media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,9 @@ import { StringInputProps, defineField } from "sanity";

import { StringInputWithCharacterCount } from "studio/components/stringInputWithCharacterCount/StringInputWithCharacterCount";
import { isInternationalizedString } from "studio/lib/interfaces/global";
import { ImageAlignment } from "studio/lib/interfaces/media";
import { firstTranslation } from "studio/utils/i18n";

export enum ImageAlignment {
Left = "left",
Right = "right",
}

export enum ImageSize {
Large = "large",
Small = "small",
}

const alignmentOptions = [
{ title: "Left", value: ImageAlignment.Left },
{ title: "Right", value: ImageAlignment.Right },
Expand Down
16 changes: 0 additions & 16 deletions studioShared/lib/interfaces/splitSection.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { isSanityKeyTypeObject } from "studio/lib/interfaces/global";
import { splitSectionSections } from "studioShared/schemas/objects/splitSection";

import { ImageBlock } from "./imageBlock";
import { TextBlock } from "./textBlock";

Expand All @@ -16,16 +13,3 @@ export interface SplitSection {
_type: "splitSection";
sections: SplitSectionSection[];
}

export function isSplitSectionSections(
value: unknown,
): value is SplitSectionSection[] {
return (
Array.isArray(value) &&
value.every(
(item) =>
isSanityKeyTypeObject(item) &&
splitSectionSections.some((s) => s.name === item._type),
)
);
}
16 changes: 15 additions & 1 deletion studioShared/schemas/objects/splitSection.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { InlineIcon } from "@sanity/icons";
import { defineField } from "sanity";

import { isSanityKeyTypeObject } from "studio/lib/interfaces/global";
import { humanizeCamelCase } from "studio/utils/stringUtils";
import { isSplitSectionSections } from "studioShared/lib/interfaces/splitSection";
import { SplitSectionSection } from "studioShared/lib/interfaces/splitSection";

import emptySection from "./emptySection";
import imageBlock from "./imageBlock";
Expand Down Expand Up @@ -44,4 +45,17 @@ const splitSection = defineField({
},
});

function isSplitSectionSections(
value: unknown,
): value is SplitSectionSection[] {
return (
Array.isArray(value) &&
value.every(
(item) =>
isSanityKeyTypeObject(item) &&
splitSectionSections.some((s) => s.name === item._type),
)
);
}

export default splitSection;

0 comments on commit bf1d75e

Please sign in to comment.