Iurii RoguliaIurii Rogulia
AboutAI EngineeringServicesProjectsAI SkillsStackTestimonialsPhrasesBlog
Contact
Iuriiย ships.

Iurii Rogulia, Senior Agentic AI & Full-Stack Software Engineer. Professionally building software since 2001.

ChecklistsPrivacy PolicyCookie Policy
Just for fun:Think of a numberThink of a birthday

Business

TMI Iurii Rogulia
VAT ID: FI29845875
DUNS: 368664211
Lappeenranta, Finland ๐Ÿ‡ซ๐Ÿ‡ฎ

  1. /
  2. Projects
  3. /
  4. pikkuna.fi โ€“ Real-time SVG Product Configurator

Iuriiย Configures: pikkuna.fi โ€“ Real-time SVG Product Configurator

March 10, 2025

Client-side SVG configurator with live preview for designing vinyl curtains and roofing panels. Supports trapezoid shapes, zipper doors, 5 mounting types, and automatic price calculation.

Live Demo

Stack

Next.jsReactTypeScriptNode.jsTailwind CSS

Topics

CTOProduct ConfiguratorReal-timeSVG

Key Results

  • Lets customers see exactly what they order before they buy, cutting mistakes and returns
  • Handles fully custom dimensions, including sloped trapezoid shapes, in real time
  • 12+ options โ€“ sizes, film, colours, mountings, doors โ€“ in one live preview
  • Stays smooth (60fps) even on mid-range phones
pikkuna.fi โ€“ Real-time SVG Product Configurator

The Business Problem

Pikkuna vinyl curtains are custom-order products with unique dimensions for each customer. Buyers didnโ€™t understand how the finished product would look, especially when choosing a trapezoid shape (different left/right heights) or adding a zipper door. This led to order errors and returns.

The Solution

I built an interactive SVG configurator where every parameter change is instantly reflected in the visual preview. Trapezoid shape renders mathematically precise via SVG <path>. Zipper door visualizes with real proportions and position. I used useDeferredValue from React 18 to keep the UI responsive during fast input. A single PikkunaSVGPreview component, reused in 4 contexts: calculator, cart, floating price bar, and server-side PNG generation for email confirmations.

Pikkuna โ€” Real-time SVG Product Configurator

Results

MetricValue
Products2 (Pikkuna, Pikkuroof)
Parameters12+ configurable
INP<200ms (useDeferredValue)
Adaptivity100% (32px to fullscreen)
Component reuse4 contexts
Main component622 lines
Calculator1622 lines (Pikkuna), 962 lines (Pikkuroof)

Order errors dropped significantly โ€“ customers see exactly what theyโ€™re ordering. The real-time preview maintains 60fps even on mid-range devices thanks to useMemo optimization and efficient SVG path calculations.

Component Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    PikkunaSVGPreview.tsx                        โ”‚
โ”‚                      (622 lines, Client Component)              โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Props:                                                         โ”‚
โ”‚  โ”œโ”€ productType: 'pikkuna' | 'pikkuroof'                       โ”‚
โ”‚  โ”œโ”€ width, leftHeight, rightHeight                             โ”‚
โ”‚  โ”œโ”€ film: 'clear' | 'tinted' | 'mosquito' | 'clearRoof'...     โ”‚
โ”‚  โ”œโ”€ border: 'white' | 'black' | 'gray' | 'brown' | 'beige'     โ”‚
โ”‚  โ””โ”€ zipDoor, doorWidth, doorOffset                             โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Used in:                                                       โ”‚
โ”‚  โ”œโ”€ pikkunaCalculator (live edit)                              โ”‚
โ”‚  โ”œโ”€ FloatingPriceBar (mini 32-64px)                            โ”‚
โ”‚  โ”œโ”€ cart/ProductCard (cart preview)                            โ”‚
โ”‚  โ””โ”€ generateProductSvg.ts (server-side SVGโ†’PNG for email)      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Under the Hood

For the technically curious, here is how the core pieces are built.

Trapezoid Mathematical Model

The SVG renders as a <path> with 4 points, where the top corners shift along the Y axis when the sides have different heights:

// src/components/PikkunaSVGPreview.tsx
const trapezoidDimensions = useMemo(() => {
  const baseWidth = width;
  const baseHeight = Math.max(leftHeight, rightHeight);
 
  // Scale to fit container (fit-contain)
  const scaleX = (containerSize.width - FRAME_STROKE_WIDTH * 2) / baseWidth;
  const scaleY = (containerSize.height - FRAME_STROKE_WIDTH * 2) / baseHeight;
  const scale = Math.min(scaleX, scaleY);
 
  const scaledWidth = baseWidth * scale;
  const scaledLeftHeight = leftHeight * scale;
  const scaledRightHeight = rightHeight * scale;
 
  // Center in container
  const offsetX = (containerSize.width - scaledWidth) / 2;
  const offsetY = (containerSize.height - Math.max(scaledLeftHeight, scaledRightHeight)) / 2;
 
  // 4 trapezoid points (top can be sloped)
  const topLeftY = offsetY + (Math.max(scaledLeftHeight, scaledRightHeight) - scaledLeftHeight);
  const topRightY = offsetY + (Math.max(scaledLeftHeight, scaledRightHeight) - scaledRightHeight);
  const bottomY = offsetY + Math.max(scaledLeftHeight, scaledRightHeight);
 
  return {
    topLeftX: offsetX, topLeftY,
    topRightX: offsetX + scaledWidth, topRightY,
    bottomLeftX: offsetX, bottomLeftY: bottomY,
    bottomRightX: offsetX + scaledWidth, bottomRightY: bottomY,
    scale,
  };
}, [width, leftHeight, rightHeight, containerSize]);
 
// SVG path: trapezoid or rectangle
<path
  d={`M ${topLeftX},${topLeftY}
      L ${topRightX},${topRightY}
      L ${bottomRightX},${bottomRightY}
      L ${bottomLeftX},${bottomLeftY} Z`}
  fill={filmFill}
  stroke={borderColor}
  strokeWidth={FRAME_STROKE_WIDTH}
/>

Zipper Door Visualization

The zipper renders as 3 parallel lines with dashes to simulate teeth:

// src/components/PikkunaSVGPreview.tsx
const renderZipperDoor = () => {
  if (!zipDoor || doorWidth <= 0) return null;
 
  const { scale } = trapezoidDimensions;
  const scaledDoorWidth = doorWidth * scale;
  const scaledDoorOffset = doorOffset * scale;
 
  // Door position from left edge
  const doorLeftX = bottomLeftX + scaledDoorOffset;
  const doorRightX = doorLeftX + scaledDoorWidth;
 
  // Y interpolation for door top (accounting for trapezoid)
  const doorTopLeftY = interpolateY(doorLeftX);
  const doorTopRightY = interpolateY(doorRightX);
 
  return (
    <g className="zipper-door">
      {/* Left zipper rail */}
      <line x1={doorLeftX} y1={doorTopLeftY} x2={doorLeftX} y2={bottomY}
            stroke={borderColor} strokeWidth={ZIP_FRAME_WIDTH} />
      <line x1={doorLeftX} y1={doorTopLeftY} x2={doorLeftX} y2={bottomY}
            stroke="#333" strokeWidth={2} strokeDasharray="10 5 3 5" />
 
      {/* Right zipper rail */}
      <line x1={doorRightX} y1={doorTopRightY} x2={doorRightX} y2={bottomY}
            stroke={borderColor} strokeWidth={ZIP_FRAME_WIDTH} />
      <line x1={doorRightX} y1={doorTopRightY} x2={doorRightX} y2={bottomY}
            stroke="#333" strokeWidth={2} strokeDasharray="10 5 3 5" />
 
      {/* Bottom crossbar */}
      <line x1={doorLeftX} y1={bottomY - ZIP_FRAME_WIDTH/2}
            x2={doorRightX} y2={bottomY - ZIP_FRAME_WIDTH/2}
            stroke={borderColor} strokeWidth={ZIP_FRAME_WIDTH} />
    </g>
  );
};

Optimization with useDeferredValue

React 18 concurrent features for maintaining responsiveness during fast input:

// src/app/[locale]/pikkuna/pikkunaCalculator.tsx
const [width, setWidth] = useState(200);
const [leftHeight, setLeftHeight] = useState(150);
const [rightHeight, setRightHeight] = useState(150);
const [doorWidth, setDoorWidth] = useState(0);
const [doorOffset, setDoorOffset] = useState(0);
 
// Deferred values โ€” SVG updates with delay, UI stays responsive
const deferredWidth = useDeferredValue(width);
const deferredLeftHeight = useDeferredValue(leftHeight);
const deferredRightHeight = useDeferredValue(rightHeight);
const deferredDoorWidth = useDeferredValue(doorWidth);
const deferredDoorOffset = useDeferredValue(doorOffset);
 
// "Stale" state indicator
const isStale = width !== deferredWidth ||
                leftHeight !== deferredLeftHeight ||
                rightHeight !== deferredRightHeight;
 
return (
  <div className={isStale ? 'opacity-80' : 'opacity-100'}>
    <PikkunaSVGPreview
      width={deferredWidth}
      leftHeight={deferredLeftHeight}
      rightHeight={deferredRightHeight}
      doorWidth={deferredDoorWidth}
      doorOffset={deferredDoorOffset}
    />
  </div>
);

Adaptive Scaling and Mobile Simplification

Single component works from 32px mini-preview to fullscreen:

// src/components/PikkunaSVGPreview.tsx
 
// Adaptive stroke constants
const FRAME_STROKE_WIDTH = containerSize.width <= 768
  ? 3   // Mobile
  : 10; // Desktop
 
const ZIP_FRAME_WIDTH = containerSize.width <= 768
  ? 3
  : 5;
 
// Simplified rendering for very small sizes (cart, floating bar)
const isSmallSize = containerSize.width < 120 || containerSize.height < 120;
 
const renderZipperDoor = () => {
  if (isSmallSize) {
    // Only 2 simple lines instead of full detail
    return (
      <>
        <line x1={doorLeftX} y1={topY} x2={doorLeftX} y2={bottomY}
              stroke={borderColor} strokeWidth={2} />
        <line x1={doorRightX} y1={topY} x2={doorRightX} y2={bottomY}
              stroke={borderColor} strokeWidth={2} />
      </>
    );
  }
  // Full detail for larger sizes
  return (/* ... 6 lines with patterns ... */);
};
 
// viewBox auto-adjusts to content
<svg
  viewBox={`${bounds.minX} ${bounds.minY} ${bounds.width} ${bounds.height}`}
  preserveAspectRatio="xMidYMid meet"
  className="w-full h-full"
/>
Iurii RoguliaAvailable

Need something similar?

I build custom solutions โ€“ from APIs to full products. Letโ€™s talk about your project.

View all projects

Related projects

tsstboxes.com โ€“ Fitment-First Online Store for ATV and UTV Cargo Boxes
tsstboxes.com โ€“ Fitment-First Online Store for ATV and UTV Cargo Boxes
November 10, 2026
tsstboxes.com โ€“ Fitment-First Online Store for ATV and UTV Cargo Boxes

Online store for ATV and UTV cargo boxes, each made for one model. Pick your machine, see only what fits, and pay in USD with shipping included.

Stack

Next.jsReactTypeScriptPythonNode.jsTailwind CSSDocker

Databases

PostgreSQL
kri.rocks โ€“ Booking Website and Online Scheduling SaaS for Beauty Businesses
kri.rocks โ€“ Booking Website and Online Scheduling SaaS for Beauty Businesses
September 28, 2026

Vertical SaaS that gives a salon, barbershop or solo beauty specialist their own booking website in minutes.

Stack

Next.jsReactHonoTypeScriptNode.jsTailwind CSSTurborepoDocker

Databases

PostgreSQLRedis

Related posts

Recoloring a Product Photo with an SVG Filter โ€“ and Where It Breaks
November 4, 2026ยท 9 min
Recoloring a Product Photo with an SVG Filter โ€“ and Where It Breaks

An SVG product color preview from one transparent photo works, but the result depends on the photoโ€™s tonal range. Measured, with what replaced it.

Stack

Next.jsReactTypeScript
Building a React Product Configurator with Zustand and Motion
April 21, 2026ยท 12 min
Building a React Product Configurator with Zustand and Motion

Build a React product configurator with Zustand, DaisyUI, Motion animations and a live SVG preview โ€“ architecture, pricing logic, and performance patterns.

Stack

Next.jsReactTypeScript