1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 12:56:41 +07:00

made transitional Anchor component for next/cra

This commit is contained in:
Fedor Katurov 2022-01-13 16:08:23 +07:00
parent 7658068caa
commit 14b93d5dbb
7 changed files with 44 additions and 18 deletions

View file

@ -12,6 +12,7 @@ import { useHistory } from 'react-router';
import classNames from 'classnames';
import { IFlowNode } from '~/types';
import { useWindowSize } from '~/hooks/dom/useWindowSize';
import { useNavigation } from '~/hooks/navigation/useNavigation';
SwiperCore.use([EffectFade, Lazy, Autoplay, Navigation]);
@ -21,13 +22,13 @@ interface Props {
export const FlowSwiperHero: FC<Props> = ({ heroes }) => {
const { innerWidth } = useWindowSize();
const { push } = useNavigation();
const [controlledSwiper, setControlledSwiper] = useState<SwiperClass | undefined>(undefined);
const [currentIndex, setCurrentIndex] = useState(heroes.length);
const preset = useMemo(() => (innerWidth <= 768 ? PRESETS.cover : PRESETS.small_hero), [
innerWidth,
]);
const history = useHistory();
const onNext = useCallback(() => {
controlledSwiper?.slideNext(1);
@ -63,9 +64,9 @@ export const FlowSwiperHero: FC<Props> = ({ heroes }) => {
const onClick = useCallback(
(sw: SwiperClass) => {
history.push(URLS.NODE_URL(heroes[sw.realIndex]?.id));
push(URLS.NODE_URL(heroes[sw.realIndex]?.id));
},
[history, heroes]
[push, heroes]
);
if (!heroes.length) {