Skip to content

Commit

Permalink
Merge pull request #23 from Vizzuality/client/feature/story-layers
Browse files Browse the repository at this point in the history
Fix outro fly
  • Loading branch information
barbara-chaves authored Nov 30, 2023
2 parents cd1ca44 + 54d7c62 commit 071972d
Show file tree
Hide file tree
Showing 6 changed files with 222 additions and 319 deletions.
10 changes: 7 additions & 3 deletions client/src/containers/map/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
layersInteractiveIdsAtom,
// popupAtom,
tmpBboxAtom,
isFlyingBackAtom,
} from '@/store';

// import { useGetLayers } from '@/types/generated/layer';
Expand Down Expand Up @@ -78,16 +79,19 @@ export default function MapContainer() {

const bbox = useRecoilValue(bboxAtom);
const tmpBbox = useRecoilValue(tmpBboxAtom);
// const layersInteractive = useRecoilValue(layersInteractiveAtom);
const isFlyingBack = useRecoilValue(isFlyingBackAtom);

const layersInteractiveIds = useRecoilValue(layersInteractiveIdsAtom);

const setBbox = useSetRecoilState(bboxAtom);
const setTmpBbox = useSetRecoilState(tmpBboxAtom);
// const setPopup = useSetRecoilState(popupAtom);

const pathname = usePathname();

const isHomePage = useMemo(() => !pathname.includes('stories'), [pathname]);
const isHomePage = useMemo(
() => !pathname.includes('stories') && !isFlyingBack,
[pathname, isFlyingBack]
);

// const { data: layersInteractiveData } = useGetLayers(
// {
Expand Down
11 changes: 7 additions & 4 deletions client/src/containers/story/steps/layouts/outro-step.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { useCallback, useEffect, useRef, useState } from 'react';
import { useRouter } from 'next/navigation';

import { useScroll, motion, useTransform } from 'framer-motion';
import { useResetRecoilState } from 'recoil';
import { useSetRecoilState } from 'recoil';

import env from '@/env.mjs';

import { tmpBboxAtom } from '@/store';
import { isFlyingBackAtom } from '@/store';

import { StepLayoutItem, StepLayoutOutroStepComponent } from '@/types/generated/strapi.schemas';

Expand All @@ -24,7 +24,7 @@ type MediaStepLayoutProps = {
const OutroStepLayout = ({ step, showContent }: MediaStepLayoutProps) => {
const { push } = useRouter();

const resetBbox = useResetRecoilState(tmpBboxAtom);
const setIsFlyingBack = useSetRecoilState(isFlyingBackAtom);

const { content, title } = step as StepLayoutOutroStepComponent;
const containerRef = useRef<HTMLDivElement>(null);
Expand All @@ -49,7 +49,10 @@ const OutroStepLayout = ({ step, showContent }: MediaStepLayoutProps) => {

useTransform(scrollYProgress, (v) => {
if (v > 0.6) {
resetBbox();
setIsFlyingBack(true);
setTimeout(() => {
setIsFlyingBack(false);
}, 3000);
push('/');
}
});
Expand Down
5 changes: 5 additions & 0 deletions client/src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ export const markerAtom = atom<MapboxGeoJSONFeature | null>({
default: null,
});

export const isFlyingBackAtom = atom<boolean>({
key: 'is-flying-back',
default: false,
});

export const DEFAULT_SETTINGS = {
expand: true,
};
Expand Down
2 changes: 1 addition & 1 deletion cms/config/middlewares.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default [
name: 'strapi::cors',
config: {
enabled: true,
origin: ['http://localhost:3000', 'http://localhost:1337']
origin: ['http://localhost:3000', 'http://localhost:1337', 'http://localhost:8000']
}
},
'strapi::poweredBy',
Expand Down
1 change: 1 addition & 0 deletions cms/src/plugins/map-field/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@strapi/typescript-utils": "4.11.2",
"@types/react": "^17.0.53",
"@types/react-dom": "^18.0.28",
"@types/react-router": "^5.1.20",
"@types/react-router-dom": "^5.3.3",
"@types/styled-components": "^5.1.26",
"react-dom": "^18.2.0",
Expand Down
Loading

0 comments on commit 071972d

Please sign in to comment.