Skip to content

Commit

Permalink
FIx types
Browse files Browse the repository at this point in the history
  • Loading branch information
barbara-chaves committed Dec 19, 2023
1 parent b6a55ee commit dc5226c
Show file tree
Hide file tree
Showing 14 changed files with 1,485 additions and 3,489 deletions.
8 changes: 3 additions & 5 deletions client/src/containers/map/markers/story-markers/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { stepAtom } from '@/store/stories';
import { useGetStoriesId } from '@/types/generated/story';

import StoryMarkerMedia from './marker';
import { StoryStepMap } from '@/types/story';
// import Carousel from './carousel';
// import { Dialog, DialogContent } from '@/components/ui/dialog';

Expand All @@ -33,12 +34,9 @@ const StoryMarkers = () => {
populate: 'deep',
});
// const [currentMedia, setCurrentMedia] = useState<number>();

const markers: StoryMarker[] = useMemo(() => {
return (
storyData?.data?.attributes?.steps?.data?.[step]?.attributes?.layout[0].map?.markers || []
);
}, [step, storyData?.data?.attributes?.steps?.data]);
return (storyData?.data?.attributes?.steps?.[step]?.map as StoryStepMap)?.markers || [];
}, [step, storyData?.data?.attributes?.steps]);

// const medias = useMemo(() => {
// return markers?.map((marker) => ({
Expand Down
18 changes: 4 additions & 14 deletions client/src/containers/story/steps/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,17 @@ import { cn } from '@/lib/classnames';
import { stepAtom } from '@/store/stories';

import {
StepLayoutMediaStepComponentMedia,
StepLayoutOutroStepComponentMedia,
StoryCategory,
StoryStepsItem,
} from '@/types/generated/strapi.schemas';

import MapStepLayout from './layouts/map-step';
import MediaStepLayout from './layouts/media-step';
import OutroStepLayout from './layouts/outro-step';
import { getStepType } from './utils';

type StepProps = PropsWithChildren<{
media?: StepLayoutMediaStepComponentMedia | StepLayoutOutroStepComponentMedia;
media?: StepLayoutOutroStepComponentMedia;
step: StoryStepsItem;
category?: StoryCategory;
index: number;
Expand All @@ -31,7 +29,7 @@ const Step = ({ step, category, index }: StepProps) => {
const type = getStepType(step);

const STEP_COMPONENT = useMemo(() => {
const stepLayout = step?.attributes?.layout?.[0];
const stepLayout = step;
if (!type || !stepLayout) return null;

switch (type) {
Expand All @@ -45,8 +43,7 @@ const Step = ({ step, category, index }: StepProps) => {
/>
);
}
case 'media-step':
return <MediaStepLayout step={step} />;

case 'outro-step':
return (
<OutroStepLayout
Expand All @@ -58,14 +55,7 @@ const Step = ({ step, category, index }: StepProps) => {
default:
return null;
}
}, [
step?.attributes?.layout,
type,
currentStep,
index,
category?.data?.id,
category?.data?.attributes,
]);
}, [step, type, currentStep, index, category?.data?.id, category?.data?.attributes]);

return (
<div className="pointer-events-none h-screen w-full ">
Expand Down
52 changes: 28 additions & 24 deletions client/src/containers/story/steps/layouts/map-step.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useScrollToItem } from '@/lib/scroll';

import {
StepLayoutMapStepComponent,
StepLayoutItem,
StoryStepsItem,
StoryCategoryDataAttributes,
} from '@/types/generated/strapi.schemas';

Expand All @@ -21,7 +21,7 @@ const Legend = dynamic(() => import('@/containers/map/legend'), {
});

type MapStepLayoutProps = {
step: StepLayoutItem;
step: StoryStepsItem;
category: StoryCategoryDataAttributes | undefined;
stepIndex: number;
showContent?: boolean;
Expand Down Expand Up @@ -78,30 +78,34 @@ const MapStepLayout = ({ step, category, showContent, stepIndex }: MapStepLayout
</div>
<div className="">
<div className="flex h-fit min-h-full flex-col items-end justify-center space-y-6 pb-6">
{card?.map((item) => (
<div
key={item?.id}
onClick={handleClickCard}
className={cn(
'pointer-events-auto cursor-pointer overflow-hidden rounded border border-gray-800 bg-[#335e6f] bg-opacity-50 p-8 backdrop-blur transition-all duration-300 ease-in-out',
showContent ? 'opacity-100' : 'opacity-0'
)}
>
<div className="w-[400px] space-y-1">
{item?.title && <h2 className="font-notes text-2xl font-bold">{item?.title}</h2>}
{!!item?.content && (
<div className="font-open-sans space-y-4">
{item.content.split('\n').map((p, i) => (
<p key={i} className="text-sm">
{p}
</p>
))}
</div>
{card?.map((item) => {
return (
<div
key={item?.id}
onClick={handleClickCard}
className={cn(
'pointer-events-auto cursor-pointer overflow-hidden rounded border border-gray-800 bg-[#335e6f] bg-opacity-50 p-8 backdrop-blur transition-all duration-300 ease-in-out',
showContent ? 'opacity-100' : 'opacity-0'
)}
{!!item?.widget && <Chart options={item?.widget} />}
>
<div className="w-[400px] space-y-1">
{item?.title && (
<h2 className="font-notes text-2xl font-bold">{item?.title}</h2>
)}
{!!item?.content && (
<div className="font-open-sans space-y-4">
{item.content.split('\n').map((p, i) => (
<p key={i} className="text-sm">
{p}
</p>
))}
</div>
)}
{!!item?.widget && <Chart options={item?.widget} />}
</div>
</div>
</div>
))}
);
})}
</div>
</div>
</div>
Expand Down
20 changes: 0 additions & 20 deletions client/src/containers/story/steps/layouts/media-step.tsx

This file was deleted.

16 changes: 8 additions & 8 deletions client/src/containers/story/steps/layouts/outro-step.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import { useCallback, useEffect, useRef, useState } from 'react';
import { useEffect, useRef, useState } from 'react';

import Image from 'next/image';
import { useRouter } from 'next/navigation';
Expand Down Expand Up @@ -80,13 +80,13 @@ const OutroStepLayout = ({ step, showContent }: MediaStepLayoutProps) => {

const isVideo = mediaType.includes('video');

const handlePlayVideo = useCallback(
(e: React.MouseEvent<HTMLVideoElement, MouseEvent>, action: 'play' | 'pause') => {
if (action === 'play') e.currentTarget.play();
else e.currentTarget.pause();
},
[]
);
// const handlePlayVideo = useCallback(
// (e: React.MouseEvent<HTMLVideoElement, MouseEvent>, action: 'play' | 'pause') => {
// if (action === 'play') e.currentTarget.play();
// else e.currentTarget.pause();
// },
// []
// );

const scale = useTransform(scrollYProgress, [0.5, 0.7], ['1', '2']);
const scaleContent = useTransform(scrollYProgress, [0.5, 0.7], ['1', '0.75']);
Expand Down
Loading

0 comments on commit dc5226c

Please sign in to comment.