#Pushing state higher

3 messages · Page 1 of 1 (latest)

dire zodiacBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

worldly needle
#

type PreviewImageCardProps = {
  selectedImage: number
  index: 0 | 1 | 2
}

const PreviewImageCard = ({ selectedImage, index }: PreviewImageCardProps) => {
  const indexDistance = Math.abs(index - selectedImage)
  const sizeScale = 11 - indexDistance * 2
  const baseOffset = (-selectedImage + 1) * 33
  const additionalOffset = (index - selectedImage) * 25

  return (
    <Group
      className={clsx(classes.imageContainer, classes.animated)}
      wrap="nowrap"
      style={{
        left: `${baseOffset + additionalOffset}%`,
        top: indexDistance * 20,
        opacity: selectedImage === index ? 1 : indexDistance <= 1 ? 0.5 : 0,
        zIndex: indexDistance === 0 ? 3 : 1,
      }}
    >
      <Image
        src={images[index]!}
        alt={`Zdjęcie widoku '${periods[index]?.label}' w panelu hodowcy`}
        className={clsx(classes.animated, classes.image)}
        style={{ [classes.sizeScale]: sizeScale } as CSSProperties}
        height="0"
        width="0"
        sizes="100vw"
      />
    </Group>
  )
}

const images = [
  '/img/landing/webp/Pigeons.webp',
  '/img/landing/webp/Dashboard.webp',
  '/img/landing/webp/Pedigree.webp',
]

const periods = [
  { label: 'Moje gołębie', value: '0' },
  { label: 'Dashboard', value: '1' },
  { label: 'Generator rodowodu', value: '2' },
]
#

How can i make it SSR? I have no idea how i can separate "SegmentedControl" to handle this PreviewImageCards