feat: generate landing stub types outside (#33)
This commit is contained in:
@@ -9,7 +9,7 @@ import { BenefitsSectionProps } from './types';
|
||||
import { iconsMap } from './helper';
|
||||
|
||||
export const BenefitsSection: FC<BenefitsSectionProps> = ({
|
||||
data: { heading, description, list },
|
||||
data: { heading, description, list } = {},
|
||||
}) => {
|
||||
const { t } = useTranslation('~', { keyPrefix: 'dry-wash.landing' });
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import { CtaButton, SiteLogo, PageSection } from '../';
|
||||
import { HeroSectionProps } from './types';
|
||||
|
||||
export const HeroSection: FC<HeroSectionProps> = ({
|
||||
data: { headline, description, video },
|
||||
data: { headline, description, video } = {},
|
||||
flexShrink,
|
||||
}) => {
|
||||
const { t } = useTranslation('~', { keyPrefix: 'dry-wash.landing' });
|
||||
|
||||
@@ -8,7 +8,7 @@ import { ReviewsSlider } from './ReviewsSlider';
|
||||
import { SocialProofSectionProps } from './types';
|
||||
|
||||
export const SocialProofSection: FC<SocialProofSectionProps> = ({
|
||||
data: { heading },
|
||||
data: { heading } = {},
|
||||
}) => {
|
||||
const { t } = useTranslation('~', { keyPrefix: 'dry-wash.landing' });
|
||||
|
||||
|
||||
1
src/models/landing/index.ts
Normal file
1
src/models/landing/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './stubs';
|
||||
1
src/models/landing/stubs/index.ts
Normal file
1
src/models/landing/stubs/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default as LandingSuccessStub } from './success';
|
||||
27
src/models/landing/stubs/success.ts
Normal file
27
src/models/landing/stubs/success.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
// Generated by json-literal-typer
|
||||
// <-- BEGIN
|
||||
interface HeroXsection {
|
||||
description: "hero-section.description";
|
||||
headline: "hero-section.headline";
|
||||
video: "demo.mp4";
|
||||
}
|
||||
|
||||
interface Sections {
|
||||
description?: "benefits-section.description";
|
||||
heading: "benefits-section.heading" | "social-proof-section.heading";
|
||||
list?: ("benefits-section.list.0" | "benefits-section.list.1" | "benefits-section.list.2" | "benefits-section.list.3")[];
|
||||
type: "benefits-section" | "social-proof-section";
|
||||
}
|
||||
|
||||
interface Body {
|
||||
"hero-section": HeroXsection;
|
||||
sections: Sections[];
|
||||
}
|
||||
|
||||
interface Root {
|
||||
body: Body;
|
||||
success: true;
|
||||
}
|
||||
// END -->
|
||||
|
||||
export default Root;
|
||||
@@ -1,9 +1,17 @@
|
||||
import React, { FC } from 'react';
|
||||
import { Container, VStack } from '@chakra-ui/react';
|
||||
|
||||
import LandingSuccess from '../../../stubs/json/landing/landing-success.json';
|
||||
import { BenefitsSection, Footer, HeroSection, SocialProofSection } from '../../components/landing';
|
||||
import {
|
||||
BenefitsSection,
|
||||
Footer,
|
||||
HeroSection,
|
||||
SocialProofSection,
|
||||
} from '../../components/landing';
|
||||
import { LandingThemeProvider } from '../../containers';
|
||||
import { LandingSuccessStub } from '../../models/landing';
|
||||
const landingSuccessStub = import(
|
||||
'../../../stubs/json/landing/success.json'
|
||||
) as unknown as LandingSuccessStub;
|
||||
|
||||
import { isBenefitsSectionData, isSocialProofSectionData } from './types';
|
||||
|
||||
@@ -20,11 +28,11 @@ const Page: FC = () => {
|
||||
>
|
||||
<VStack w='full' h='full' alignItems='stretch' flexGrow={1}>
|
||||
<HeroSection
|
||||
data={LandingSuccess.body['hero-section']}
|
||||
data={landingSuccessStub['body']['hero-section']}
|
||||
flexShrink={0}
|
||||
/>
|
||||
<VStack as='main' flexGrow={1}>
|
||||
{LandingSuccess.body.sections.map(({ type, ...data }, i) => {
|
||||
{landingSuccessStub.body.sections.map(({ type, ...data }, i) => {
|
||||
if (isBenefitsSectionData(type, data)) {
|
||||
return <BenefitsSection key={i} data={data} />;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import LandingSuccess from "../../../stubs/json/landing/landing-success.json";
|
||||
import LandingSuccess from "../../../stubs/json/landing/success.json";
|
||||
import { BenefitsSectionProps, SocialProofSectionProps } from "../../components/landing";
|
||||
import { ArrElement } from "../../lib";
|
||||
|
||||
type SectionsItemData = ArrElement<LandingSuccess['body']['sections']>;
|
||||
type SectionsItemData = ArrElement<typeof LandingSuccess['body']['sections']>;
|
||||
type SectionType = SectionsItemData['type'];
|
||||
type SectionData = Omit<SectionsItemData, 'type'>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user