Главная / Каталог редких и коллекционных кроссовок

Каталог редких и коллекционных кроссовок

5 месяцев

Stauch Sneakers

Текущая версия сайта

stauchsneakers

В основном активно участвовал в начальном и завершающем этапах разработки.
В начале занимался общей архитектурой, бизнес-логикой и прототипированием комплексных frontend-компонентов.

В течение цикла проекта консультировал основных разработчиков по технической части, под конец активно фиксил баги, занимался технической и логической оптимизацией.

Фичсет

Моя работа

Команда

Frontend:    3
Backend:     2
Design:      1
Management:  2

Стак

Frontend:  Next-js, TypeScript, Radix UI, Zustand, Tailwind CSS, Motion (Framer), htmr, react-hook-form
Backend:   Java (Spring)
Design:    Figma
Toolchain: GitLab, Docker

Первый прототип showcase-компонента

В начале были определённые сложности с обновлением границ при зуме.

Решением оказалось пропорциональное изменение scale и width × height компонента одновременно.

import React from "react";
import clsx from "clsx";
import { motion } from "motion/react";

const totalItems = 2500;
const zooms = [
  [0.3, 335],
  [0.5, 200],
  [1, 100],
];

const data = Array.from({ length: totalItems }).map((_, i) => ({
  value: i,
  scale: [0.4, 0.6, 0.8][Math.floor(Math.random() * 3)],
  color: ["bg-green-400", "bg-blue-400", "bg-yellow-400"][
    Math.floor(Math.random() * 3)
  ],
}));

export default function App() {
  const [constraints, setConstraints] = React.useState([0, 0]);
  const [scale, setScale] = React.useState(zooms[1]);

  const containerRef = React.useRef<HTMLDivElement>(null);
  const dragRef = React.useRef<HTMLDivElement>(null);

  const updateConstraints = React.useCallback(() => {
    if (!containerRef.current || !dragRef.current) return;

    const containerWidth = containerRef.current.offsetWidth;
    const containerHeight = containerRef.current.offsetHeight;
    const dragWidth = dragRef.current.offsetWidth;
    const dragHeight = dragRef.current.offsetHeight;

    const x = Math.max(0, (dragWidth - containerWidth) / 2);
    const y = Math.max(0, (dragHeight - containerHeight) / 2);

    setConstraints([x, y]);
  }, []);

  React.useEffect(() => {
    updateConstraints();
  }, [containerRef.current, dragRef.current]);

  return (
    <div className="relative h-screen overflow-clip">
      <motion.div
        onAnimationComplete={updateConstraints}
        animate={{
          scale: scale[0],
          width: scale[1] + "vw",
          height: scale[1] + "vh",
        }}
        ref={containerRef}
        className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 overflow-hidden"
      >
        <motion.div
          drag={true}
          ref={dragRef}
          dragConstraints={{
            top: -constraints[1],
            bottom: constraints[1],
            left: -constraints[0],
            right: constraints[0],
          }}
          dragElastic={0.3}
          dragMomentum={true}
          className="grid grid-rows-50 grid-flow-col absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-fit h-fit"
        >
          {data.map((entry) => (
            <motion.div
              initial={{ opacity: 0, scale: 0.3 }}
              animate={{
                scale: entry.scale,
                opacity: 1,
              }}
            >
              <motion.div
                className={clsx(
                  "size-96 flex items-center justify-center rounded-full text-7xl font-bold",
                  entry.color,
                )}
                key={entry.value}
                children={entry.value}
              />
            </motion.div>
          ))}
        </motion.div>
      </motion.div>
    </div>
  );
}