# Wavy Background

Lapisan gelombang lembut berwarna token yang bergeser pelan di belakang konten, berupa ombak terisi, garis sutra tipis, atau pita bertumpuk.

- Kategori: Latar
- Status: stable
- Registry: https://markas.jenderalcorp.com/r/wavy-background.json
- CLI: `npx markasui@latest add wavy-background`

## Kapan dipakai

Latar bergerak yang tenang untuk hero, kartu newsletter, halaman masuk, atau halaman 404.

- Tambahkan padding bawah lewat class supaya teks tidak menumpuk di gelombang paling rapat
- Pakai silk di belakang form dan teks padat, ocean atau layered di belakang judul pendek
- Atur warna latar, padding, dan radius lewat class pada komponen

## Kode

### Blade

Simpan di `resources/views/components/markas/wavy-background.blade.php`. Tanpa dependensi tambahan.

```blade
@props([
    'variant' => 'ocean',
    'color' => 'primary',
    'speed' => 'normal',
    'waves' => 4,
])

@php
    $base = 'relative isolate overflow-hidden';
    $layer = 'pointer-events-none absolute inset-0';
    $wave = 'absolute left-0 w-[200%] animate-[markas-wave_20s_linear_infinite] motion-reduce:animate-none';
    $content = 'relative';
    $colors = [
        'muted' => 'text-muted',
        'ink' => 'text-ink',
        'primary' => 'text-primary',
        'success' => 'text-success',
        'warning' => 'text-warning',
        'danger' => 'text-danger',
    ];
    $variants = [
        'ocean' => ['layer' => 'blur-[2px]', 'wave' => '-bottom-1 h-1/2'],
        'silk' => ['layer' => 'blur-[0.5px]', 'wave' => 'top-1/4 h-1/2'],
        'layered' => ['layer' => 'blur-[1px]', 'wave' => '-bottom-1 h-3/4'],
    ];
    $speeds = ['slow' => 30, 'normal' => 18, 'fast' => 10];
    $keyframes = '@keyframes markas-wave{to{transform:translateX(-50%)}}';

    // Gelombang dari kurva kuadrat berulang: satu periode 600 unit, jadi geser -50% (1200 unit) menyambung mulus.
    $period = 600;
    $viewHeight = 120;
    $phaseStep = 110;
    $minWaves = 3;
    $maxWaves = 5;

    $key = array_key_exists($variant, $variants) ? $variant : 'ocean';
    $config = $variants[$key];
    $speedBase = $speeds[$speed] ?? $speeds['normal'];

    // Garis dasar, tinggi puncak, dan opasitas (persen) gelombang ke-i untuk tiap varian.
    $shapes = [
        'ocean' => fn ($i) => ['baseline' => 40 + $i * 12, 'amplitude' => 16 - $i * 2, 'opacity' => 6 + $i * 4],
        'silk' => fn ($i) => ['baseline' => 30 + $i * 15, 'amplitude' => 10 + $i * 3, 'opacity' => 30 + $i * 8],
        'layered' => fn ($i) => ['baseline' => 20 + $i * 20, 'amplitude' => 8 + ($i % 2) * 4, 'opacity' => 5 + $i * 3],
    ];
    $wavePath = function ($baseline, $amplitude, $phase, $filled) use ($period, $viewHeight) {
        $start = -$phase;
        $quarter = $period / 4;
        $d = 'M'.$start.' '.$baseline.' Q'.($start + $quarter).' '.($baseline - 2 * $amplitude).' '.($start + 2 * $quarter).' '.$baseline;
        for ($x = $start + 4 * $quarter; $x <= 2 * $period + 2 * $quarter; $x += 2 * $quarter) {
            $d .= ' T'.$x.' '.$baseline;
        }

        return $filled ? $d.' V'.$viewHeight.' H'.$start.' Z' : $d;
    };

    $total = max($minWaves, min((int) $waves, $maxWaves));
    $items = [];
    for ($i = 0; $i < $total; $i++) {
        $shape = $shapes[$key]($i);
        $filled = $key !== 'silk';
        $items[] = [
            'd' => $wavePath($shape['baseline'], $shape['amplitude'], ($i * $phaseStep) % $period, $filled),
            'filled' => $filled,
            'style' => 'opacity: '.($shape['opacity'] / 100).'; animation-duration: '.($speedBase + ($total - 1 - $i) * 4).'s; animation-direction: '.($i % 2 === 1 ? 'reverse' : 'normal'),
        ];
    }
@endphp

<div {{ $attributes->class([$base]) }}>
    <style>{!! $keyframes !!}</style>
    <div aria-hidden="true" @class([$layer, $config['layer'], $colors[$color] ?? $colors['primary']])>
        @foreach ($items as $item)
            <svg class="{{ $wave }} {{ $config['wave'] }}" style="{{ $item['style'] }}" viewBox="0 0 1200 {{ $viewHeight }}" preserveAspectRatio="none">
                @if ($item['filled'])
                    <path d="{{ $item['d'] }}" fill="currentColor" />
                @else
                    <path d="{{ $item['d'] }}" fill="none" stroke="currentColor" stroke-width="1.5" vector-effect="non-scaling-stroke" />
                @endif
            </svg>
        @endforeach
    </div>
    <div class="{{ $content }}">{{ $slot }}</div>
</div>
```

```blade
<x-markas.wavy-background variant="ocean" color="primary" class="rounded-xl border border-line bg-surface px-6 pt-12 pb-32">
    <h2 class="text-2xl font-semibold text-ink">Rilis tenang setiap Jumat</h2>
    <x-markas.button>Coba gratis</x-markas.button>
</x-markas.wavy-background>
```

Tidak butuh JavaScript atau Alpine.js.

### React

Simpan di `src/components/markas/WavyBackground.tsx`. Tanpa dependensi tambahan.

```tsx
import type { ComponentProps } from "react";

const base = "relative isolate overflow-hidden";
const layer = "pointer-events-none absolute inset-0";
const wave =
  "absolute left-0 w-[200%] animate-[markas-wave_20s_linear_infinite] motion-reduce:animate-none";
const content = "relative";
const colors = {
  muted: "text-muted",
  ink: "text-ink",
  primary: "text-primary",
  success: "text-success",
  warning: "text-warning",
  danger: "text-danger",
};
const variants = {
  ocean: { layer: "blur-[2px]", wave: "-bottom-1 h-1/2" },
  silk: { layer: "blur-[0.5px]", wave: "top-1/4 h-1/2" },
  layered: { layer: "blur-[1px]", wave: "-bottom-1 h-3/4" },
};
const speeds = { slow: 30, normal: 18, fast: 10 };
const keyframes = "@keyframes markas-wave{to{transform:translateX(-50%)}}";
const cx = (...c: (string | false | null | undefined)[]) =>
  c.filter(Boolean).join(" ");

/** Gelombang dari kurva kuadrat berulang: satu periode 600 unit, jadi geser -50% (1200 unit) menyambung mulus. */
const PERIOD = 600;
const VIEW_HEIGHT = 120;
const PHASE_STEP = 110;
const MIN_WAVES = 3;
const MAX_WAVES = 5;

type Variant = keyof typeof variants;

function wavePath(
  baseline: number,
  amplitude: number,
  phase: number,
  filled: boolean,
) {
  const start = -phase;
  const quarter = PERIOD / 4;
  let d = `M${start} ${baseline} Q${start + quarter} ${baseline - 2 * amplitude} ${start + 2 * quarter} ${baseline}`;
  for (
    let x = start + 4 * quarter;
    x <= 2 * PERIOD + 2 * quarter;
    x += 2 * quarter
  )
    d += ` T${x} ${baseline}`;
  return filled ? `${d} V${VIEW_HEIGHT} H${start} Z` : d;
}

/** Garis dasar, tinggi puncak, dan opasitas (persen) gelombang ke-i untuk tiap varian. */
const shapes = {
  ocean: (i: number) => ({
    baseline: 40 + i * 12,
    amplitude: 16 - i * 2,
    opacity: 6 + i * 4,
  }),
  silk: (i: number) => ({
    baseline: 30 + i * 15,
    amplitude: 10 + i * 3,
    opacity: 30 + i * 8,
  }),
  layered: (i: number) => ({
    baseline: 20 + i * 20,
    amplitude: 8 + (i % 2) * 4,
    opacity: 5 + i * 3,
  }),
};

function makeWaves(
  variant: Variant,
  waves: number,
  speed: keyof typeof speeds,
) {
  const total = Math.max(MIN_WAVES, Math.min(Math.trunc(waves), MAX_WAVES));
  return Array.from({ length: total }, (_, i) => {
    const shape = shapes[variant](i);
    const filled = variant !== "silk";
    return {
      d: wavePath(
        shape.baseline,
        shape.amplitude,
        (i * PHASE_STEP) % PERIOD,
        filled,
      ),
      filled,
      style: {
        opacity: shape.opacity / 100,
        animationDuration: `${(speeds[speed] ?? speeds.normal) + (total - 1 - i) * 4}s`,
        animationDirection: i % 2 === 1 ? "reverse" : "normal",
      },
    };
  });
}

export type WavyBackgroundProps = ComponentProps<"div"> & {
  variant?: Variant;
  color?: keyof typeof colors;
  speed?: keyof typeof speeds;
  waves?: number;
};

export function WavyBackground({
  variant = "ocean",
  color = "primary",
  speed = "normal",
  waves = 4,
  className,
  children,
  ...props
}: WavyBackgroundProps) {
  const key: Variant = variant in variants ? variant : "ocean";
  const config = variants[key];
  return (
    <div {...props} className={cx(base, className)}>
      <style>{keyframes}</style>
      <div
        aria-hidden="true"
        className={cx(layer, config.layer, colors[color] ?? colors.primary)}
      >
        {makeWaves(key, waves, speed).map((item, index) => (
          <svg
            key={index}
            className={cx(wave, config.wave)}
            style={item.style}
            viewBox={`0 0 1200 ${VIEW_HEIGHT}`}
            preserveAspectRatio="none"
          >
            {item.filled ? (
              <path d={item.d} fill="currentColor" />
            ) : (
              <path
                d={item.d}
                fill="none"
                stroke="currentColor"
                strokeWidth="1.5"
                vectorEffect="non-scaling-stroke"
              />
            )}
          </svg>
        ))}
      </div>
      <div className={content}>{children}</div>
    </div>
  );
}
```

```tsx
import { Button } from "@/components/markas/Button";
import { WavyBackground } from "@/components/markas/WavyBackground";

<WavyBackground
  variant="ocean"
  color="primary"
  className="rounded-xl border border-line bg-surface px-6 pt-12 pb-32"
>
  <h2 className="text-2xl font-semibold text-ink">Rilis tenang setiap Jumat</h2>
  <Button>Coba gratis</Button>
</WavyBackground>;
```

### Vue

Simpan di `src/components/markas/WavyBackground.vue`. Tanpa dependensi tambahan.

```vue
<script setup lang="ts">
import { computed } from "vue";

const base = "relative isolate overflow-hidden";
const layer = "pointer-events-none absolute inset-0";
const wave =
  "absolute left-0 w-[200%] animate-[markas-wave_20s_linear_infinite] motion-reduce:animate-none";
const content = "relative";
const colors = {
  muted: "text-muted",
  ink: "text-ink",
  primary: "text-primary",
  success: "text-success",
  warning: "text-warning",
  danger: "text-danger",
};
const variants = {
  ocean: { layer: "blur-[2px]", wave: "-bottom-1 h-1/2" },
  silk: { layer: "blur-[0.5px]", wave: "top-1/4 h-1/2" },
  layered: { layer: "blur-[1px]", wave: "-bottom-1 h-3/4" },
};
const speeds = { slow: 30, normal: 18, fast: 10 };
const keyframes = "@keyframes markas-wave{to{transform:translateX(-50%)}}";

/** Gelombang dari kurva kuadrat berulang: satu periode 600 unit, jadi geser -50% (1200 unit) menyambung mulus. */
const PERIOD = 600;
const VIEW_HEIGHT = 120;
const PHASE_STEP = 110;
const MIN_WAVES = 3;
const MAX_WAVES = 5;

type Variant = keyof typeof variants;

function wavePath(
  baseline: number,
  amplitude: number,
  phase: number,
  filled: boolean,
) {
  const start = -phase;
  const quarter = PERIOD / 4;
  let d = `M${start} ${baseline} Q${start + quarter} ${baseline - 2 * amplitude} ${start + 2 * quarter} ${baseline}`;
  for (
    let x = start + 4 * quarter;
    x <= 2 * PERIOD + 2 * quarter;
    x += 2 * quarter
  )
    d += ` T${x} ${baseline}`;
  return filled ? `${d} V${VIEW_HEIGHT} H${start} Z` : d;
}

/** Garis dasar, tinggi puncak, dan opasitas (persen) gelombang ke-i untuk tiap varian. */
const shapes = {
  ocean: (i: number) => ({
    baseline: 40 + i * 12,
    amplitude: 16 - i * 2,
    opacity: 6 + i * 4,
  }),
  silk: (i: number) => ({
    baseline: 30 + i * 15,
    amplitude: 10 + i * 3,
    opacity: 30 + i * 8,
  }),
  layered: (i: number) => ({
    baseline: 20 + i * 20,
    amplitude: 8 + (i % 2) * 4,
    opacity: 5 + i * 3,
  }),
};

function makeWaves(
  variant: Variant,
  waves: number,
  speed: keyof typeof speeds,
) {
  const total = Math.max(MIN_WAVES, Math.min(Math.trunc(waves), MAX_WAVES));
  return Array.from({ length: total }, (_, i) => {
    const shape = shapes[variant](i);
    const filled = variant !== "silk";
    return {
      d: wavePath(
        shape.baseline,
        shape.amplitude,
        (i * PHASE_STEP) % PERIOD,
        filled,
      ),
      filled,
      style: {
        opacity: shape.opacity / 100,
        animationDuration: `${(speeds[speed] ?? speeds.normal) + (total - 1 - i) * 4}s`,
        animationDirection: i % 2 === 1 ? "reverse" : "normal",
      },
    };
  });
}

const props = withDefaults(
  defineProps<{
    variant?: Variant;
    color?: keyof typeof colors;
    speed?: keyof typeof speeds;
    waves?: number;
  }>(),
  { variant: "ocean", color: "primary", speed: "normal", waves: 4 },
);

const key = computed<Variant>(() =>
  props.variant in variants ? props.variant : "ocean",
);
const items = computed(() => makeWaves(key.value, props.waves, props.speed));
</script>

<template>
  <div :class="base">
    <component :is="'style'">{{ keyframes }}</component>
    <div
      aria-hidden="true"
      :class="[
        layer,
        variants[key].layer,
        colors[props.color] ?? colors.primary,
      ]"
    >
      <svg
        v-for="(item, index) in items"
        :key="index"
        :class="[wave, variants[key].wave]"
        :style="item.style"
        :viewBox="`0 0 1200 ${VIEW_HEIGHT}`"
        preserveAspectRatio="none"
      >
        <path v-if="item.filled" :d="item.d" fill="currentColor" />
        <path
          v-else
          :d="item.d"
          fill="none"
          stroke="currentColor"
          stroke-width="1.5"
          vector-effect="non-scaling-stroke"
        />
      </svg>
    </div>
    <div :class="content"><slot /></div>
  </div>
</template>
```

```vue
<template>
  <WavyBackground
    variant="ocean"
    color="primary"
    class="rounded-xl border border-line bg-surface px-6 pt-12 pb-32"
  >
    <h2 class="text-2xl font-semibold text-ink">Rilis tenang setiap Jumat</h2>
    <Button>Coba gratis</Button>
  </WavyBackground>
</template>
```

### Svelte

Simpan di `src/lib/components/markas/WavyBackground.svelte`. Tanpa dependensi tambahan.

```svelte
<script lang="ts">
  import type { Snippet } from "svelte";
  import type { HTMLAttributes } from "svelte/elements";

  const base = "relative isolate overflow-hidden";
  const layer = "pointer-events-none absolute inset-0";
  const wave =
    "absolute left-0 w-[200%] animate-[markas-wave_20s_linear_infinite] motion-reduce:animate-none";
  const content = "relative";
  const colors = {
    muted: "text-muted",
    ink: "text-ink",
    primary: "text-primary",
    success: "text-success",
    warning: "text-warning",
    danger: "text-danger",
  };
  const variants = {
    ocean: { layer: "blur-[2px]", wave: "-bottom-1 h-1/2" },
    silk: { layer: "blur-[0.5px]", wave: "top-1/4 h-1/2" },
    layered: { layer: "blur-[1px]", wave: "-bottom-1 h-3/4" },
  };
  const speeds = { slow: 30, normal: 18, fast: 10 };
  const keyframes = "@keyframes markas-wave{to{transform:translateX(-50%)}}";

  /** Repeated quadratic curves: one period is 600 units, so shifting by -50% (1200 units) loops seamlessly. */
  const PERIOD = 600;
  const VIEW_HEIGHT = 120;
  const PHASE_STEP = 110;
  const MIN_WAVES = 3;
  const MAX_WAVES = 5;

  type Variant = keyof typeof variants;

  function wavePath(
    baseline: number,
    amplitude: number,
    phase: number,
    filled: boolean,
  ) {
    const start = -phase;
    const quarter = PERIOD / 4;
    let d = `M${start} ${baseline} Q${start + quarter} ${baseline - 2 * amplitude} ${start + 2 * quarter} ${baseline}`;
    for (
      let x = start + 4 * quarter;
      x <= 2 * PERIOD + 2 * quarter;
      x += 2 * quarter
    )
      d += ` T${x} ${baseline}`;
    return filled ? `${d} V${VIEW_HEIGHT} H${start} Z` : d;
  }

  /** Baseline, peak height, and opacity (percent) of wave i for each variant. */
  const shapes = {
    ocean: (i: number) => ({
      baseline: 40 + i * 12,
      amplitude: 16 - i * 2,
      opacity: 6 + i * 4,
    }),
    silk: (i: number) => ({
      baseline: 30 + i * 15,
      amplitude: 10 + i * 3,
      opacity: 30 + i * 8,
    }),
    layered: (i: number) => ({
      baseline: 20 + i * 20,
      amplitude: 8 + (i % 2) * 4,
      opacity: 5 + i * 3,
    }),
  };

  function makeWaves(
    variant: Variant,
    waves: number,
    speed: keyof typeof speeds,
  ) {
    const total = Math.max(MIN_WAVES, Math.min(Math.trunc(waves), MAX_WAVES));
    return Array.from({ length: total }, (_, i) => {
      const shape = shapes[variant](i);
      const filled = variant !== "silk";
      const seconds = (speeds[speed] ?? speeds.normal) + (total - 1 - i) * 4;
      const direction = i % 2 === 1 ? "reverse" : "normal";
      return {
        d: wavePath(
          shape.baseline,
          shape.amplitude,
          (i * PHASE_STEP) % PERIOD,
          filled,
        ),
        filled,
        style: `opacity: ${shape.opacity / 100}; animation-duration: ${seconds}s; animation-direction: ${direction}`,
      };
    });
  }

  type Props = HTMLAttributes<HTMLDivElement> & {
    variant?: Variant;
    color?: keyof typeof colors;
    speed?: keyof typeof speeds;
    waves?: number;
    children?: Snippet;
  };

  let {
    variant = "ocean",
    color = "primary",
    speed = "normal",
    waves = 4,
    class: className,
    children,
    ...rest
  }: Props = $props();

  const key = $derived<Variant>(variant in variants ? variant : "ocean");
  const config = $derived(variants[key]);
  const items = $derived(makeWaves(key, waves, speed));
</script>

<div {...rest} class={[base, className]}>
  {@html `<style>${keyframes}</style>`}
  <div
    aria-hidden="true"
    class={[layer, config.layer, colors[color] ?? colors.primary]}
  >
    {#each items as item, index (index)}
      <svg
        class={[wave, config.wave]}
        style={item.style}
        viewBox="0 0 1200 {VIEW_HEIGHT}"
        preserveAspectRatio="none"
      >
        {#if item.filled}
          <path d={item.d} fill="currentColor" />
        {:else}
          <path
            d={item.d}
            fill="none"
            stroke="currentColor"
            stroke-width="1.5"
            vector-effect="non-scaling-stroke"
          />
        {/if}
      </svg>
    {/each}
  </div>
  <div class={content}>{@render children?.()}</div>
</div>
```

```svelte
<script lang="ts">
  import Button from "$lib/components/markas/Button.svelte";
  import WavyBackground from "$lib/components/markas/WavyBackground.svelte";
</script>

<WavyBackground
  variant="ocean"
  color="primary"
  class="rounded-xl border border-line bg-surface px-6 pt-12 pb-32"
>
  <h2 class="text-2xl font-semibold text-ink">Calm releases, every Friday</h2>
  <Button>Start free trial</Button>
</WavyBackground>
```

### Astro

Simpan di `src/components/markas/WavyBackground.astro`. Tanpa dependensi tambahan.

```astro
---
import type { HTMLAttributes } from "astro/types";

const base = "relative isolate overflow-hidden";
const layer = "pointer-events-none absolute inset-0";
const wave =
  "absolute left-0 w-[200%] animate-[markas-wave_20s_linear_infinite] motion-reduce:animate-none";
const content = "relative";
const colors = {
  muted: "text-muted",
  ink: "text-ink",
  primary: "text-primary",
  success: "text-success",
  warning: "text-warning",
  danger: "text-danger",
};
const variants = {
  ocean: { layer: "blur-[2px]", wave: "-bottom-1 h-1/2" },
  silk: { layer: "blur-[0.5px]", wave: "top-1/4 h-1/2" },
  layered: { layer: "blur-[1px]", wave: "-bottom-1 h-3/4" },
};
const speeds = { slow: 30, normal: 18, fast: 10 };
const keyframes = "@keyframes markas-wave{to{transform:translateX(-50%)}}";

/** Repeated quadratic curves: one period is 600 units, so shifting by -50% (1200 units) loops seamlessly. */
const PERIOD = 600;
const VIEW_HEIGHT = 120;
const PHASE_STEP = 110;
const MIN_WAVES = 3;
const MAX_WAVES = 5;

type Variant = keyof typeof variants;

function wavePath(
  baseline: number,
  amplitude: number,
  phase: number,
  filled: boolean,
) {
  const start = -phase;
  const quarter = PERIOD / 4;
  let d = `M${start} ${baseline} Q${start + quarter} ${baseline - 2 * amplitude} ${start + 2 * quarter} ${baseline}`;
  for (
    let x = start + 4 * quarter;
    x <= 2 * PERIOD + 2 * quarter;
    x += 2 * quarter
  )
    d += ` T${x} ${baseline}`;
  return filled ? `${d} V${VIEW_HEIGHT} H${start} Z` : d;
}

/** Baseline, peak height, and opacity (percent) of wave i for each variant. */
const shapes = {
  ocean: (i: number) => ({
    baseline: 40 + i * 12,
    amplitude: 16 - i * 2,
    opacity: 6 + i * 4,
  }),
  silk: (i: number) => ({
    baseline: 30 + i * 15,
    amplitude: 10 + i * 3,
    opacity: 30 + i * 8,
  }),
  layered: (i: number) => ({
    baseline: 20 + i * 20,
    amplitude: 8 + (i % 2) * 4,
    opacity: 5 + i * 3,
  }),
};

function makeWaves(
  variant: Variant,
  waves: number,
  speed: keyof typeof speeds,
) {
  const total = Math.max(MIN_WAVES, Math.min(Math.trunc(waves), MAX_WAVES));
  return Array.from({ length: total }, (_, i) => {
    const shape = shapes[variant](i);
    const filled = variant !== "silk";
    return {
      d: wavePath(
        shape.baseline,
        shape.amplitude,
        (i * PHASE_STEP) % PERIOD,
        filled,
      ),
      filled,
      style: {
        opacity: shape.opacity / 100,
        animationDuration: `${(speeds[speed] ?? speeds.normal) + (total - 1 - i) * 4}s`,
        animationDirection: i % 2 === 1 ? "reverse" : "normal",
      },
    };
  });
}

type Props = HTMLAttributes<"div"> & {
  variant?: Variant;
  color?: keyof typeof colors;
  speed?: keyof typeof speeds;
  waves?: number;
};

const {
  variant = "ocean",
  color = "primary",
  speed = "normal",
  waves = 4,
  class: className,
  ...rest
} = Astro.props;
const key: Variant = variant in variants ? variant : "ocean";
const config = variants[key];
---

<div {...rest} class:list={[base, className]}>
  <style is:inline set:html={keyframes} />
  <div
    aria-hidden="true"
    class:list={[layer, config.layer, colors[color] ?? colors.primary]}
  >
    {
      makeWaves(key, waves, speed).map((item) => (
        <svg
          class:list={[wave, config.wave]}
          style={item.style}
          viewBox={`0 0 1200 ${VIEW_HEIGHT}`}
          preserveAspectRatio="none"
        >
          {item.filled ? (
            <path d={item.d} fill="currentColor" />
          ) : (
            <path
              d={item.d}
              fill="none"
              stroke="currentColor"
              stroke-width="1.5"
              vector-effect="non-scaling-stroke"
            />
          )}
        </svg>
      ))
    }
  </div>
  <div class={content}><slot /></div>
</div>
```

```astro
---
import Button from "@/components/markas/Button.astro";
import WavyBackground from "@/components/markas/WavyBackground.astro";
---

<WavyBackground
  variant="ocean"
  color="primary"
  class="rounded-xl border border-line bg-surface px-6 pt-12 pb-32"
>
  <h2 class="text-2xl font-semibold text-ink">
    Calm releases, every Friday
  </h2>
  <Button>Start free trial</Button>
</WavyBackground>
```

### Angular

Simpan di `src/app/markas/wavy-background.component.ts`. Tanpa dependensi tambahan.

```ts
import {
  ChangeDetectionStrategy,
  Component,
  computed,
  input,
  numberAttribute,
  ViewEncapsulation,
} from "@angular/core";

const base = "relative isolate overflow-hidden";
const layer = "pointer-events-none absolute inset-0";
const wave =
  "absolute left-0 w-[200%] animate-[markas-wave_20s_linear_infinite] motion-reduce:animate-none";
const content = "relative";
const colors = {
  muted: "text-muted",
  ink: "text-ink",
  primary: "text-primary",
  success: "text-success",
  warning: "text-warning",
  danger: "text-danger",
};
const variants = {
  ocean: { layer: "blur-[2px]", wave: "-bottom-1 h-1/2" },
  silk: { layer: "blur-[0.5px]", wave: "top-1/4 h-1/2" },
  layered: { layer: "blur-[1px]", wave: "-bottom-1 h-3/4" },
};
const speeds = { slow: 30, normal: 18, fast: 10 };
const keyframes = "@keyframes markas-wave{to{transform:translateX(-50%)}}";

/** Repeated quadratic curves: one period is 600 units, so shifting by -50% (1200 units) loops seamlessly. */
const PERIOD = 600;
const VIEW_HEIGHT = 120;
const PHASE_STEP = 110;
const MIN_WAVES = 3;
const MAX_WAVES = 5;

export type WavyBackgroundVariant = keyof typeof variants;
export type WavyBackgroundColor = keyof typeof colors;
export type WavyBackgroundSpeed = keyof typeof speeds;

function wavePath(
  baseline: number,
  amplitude: number,
  phase: number,
  filled: boolean,
) {
  const start = -phase;
  const quarter = PERIOD / 4;
  let d = `M${start} ${baseline} Q${start + quarter} ${baseline - 2 * amplitude} ${start + 2 * quarter} ${baseline}`;
  for (
    let x = start + 4 * quarter;
    x <= 2 * PERIOD + 2 * quarter;
    x += 2 * quarter
  )
    d += ` T${x} ${baseline}`;
  return filled ? `${d} V${VIEW_HEIGHT} H${start} Z` : d;
}

/** Baseline, peak height, and opacity (percent) of wave i for each variant. */
const shapes = {
  ocean: (i: number) => ({
    baseline: 40 + i * 12,
    amplitude: 16 - i * 2,
    opacity: 6 + i * 4,
  }),
  silk: (i: number) => ({
    baseline: 30 + i * 15,
    amplitude: 10 + i * 3,
    opacity: 30 + i * 8,
  }),
  layered: (i: number) => ({
    baseline: 20 + i * 20,
    amplitude: 8 + (i % 2) * 4,
    opacity: 5 + i * 3,
  }),
};

function makeWaves(
  variant: WavyBackgroundVariant,
  waves: number,
  speed: WavyBackgroundSpeed,
) {
  const total = Math.max(MIN_WAVES, Math.min(Math.trunc(waves), MAX_WAVES));
  return Array.from({ length: total }, (_, i) => {
    const shape = shapes[variant](i);
    const filled = variant !== "silk";
    const seconds = (speeds[speed] ?? speeds.normal) + (total - 1 - i) * 4;
    const direction = i % 2 === 1 ? "reverse" : "normal";
    return {
      d: wavePath(
        shape.baseline,
        shape.amplitude,
        (i * PHASE_STEP) % PERIOD,
        filled,
      ),
      filled,
      style: `opacity: ${shape.opacity / 100}; animation-duration: ${seconds}s; animation-direction: ${direction}`,
    };
  });
}

/**
 * Attribute selector on the native root div: the user's class and attributes stay on it.
 * The keyframes are a global style, so encapsulation is off.
 */
@Component({
  selector: "div[markas-wavy-background]",
  changeDetection: ChangeDetectionStrategy.OnPush,
  encapsulation: ViewEncapsulation.None,
  styles: [keyframes],
  host: { "[class]": "base" },
  template: `
    <div aria-hidden="true" [class]="layerClasses()">
      @for (item of items(); track $index) {
        <svg
          [attr.class]="waveClasses()"
          [style]="item.style"
          [attr.viewBox]="viewBox"
          preserveAspectRatio="none"
        >
          @if (item.filled) {
            <path [attr.d]="item.d" fill="currentColor" />
          } @else {
            <path
              [attr.d]="item.d"
              fill="none"
              stroke="currentColor"
              stroke-width="1.5"
              vector-effect="non-scaling-stroke"
            />
          }
        </svg>
      }
    </div>
    <div [class]="content"><ng-content /></div>
  `,
})
export class WavyBackground {
  readonly variant = input<WavyBackgroundVariant>("ocean");
  readonly color = input<WavyBackgroundColor>("primary");
  readonly speed = input<WavyBackgroundSpeed>("normal");
  readonly waves = input(4, { transform: numberAttribute });

  protected readonly base = base;
  protected readonly content = content;
  protected readonly viewBox = `0 0 1200 ${VIEW_HEIGHT}`;
  private readonly key = computed<WavyBackgroundVariant>(() =>
    this.variant() in variants ? this.variant() : "ocean",
  );
  protected readonly layerClasses = computed(
    () =>
      `${layer} ${variants[this.key()].layer} ${colors[this.color()] ?? colors.primary}`,
  );
  protected readonly waveClasses = computed(
    () => `${wave} ${variants[this.key()].wave}`,
  );
  protected readonly items = computed(() =>
    makeWaves(this.key(), this.waves(), this.speed()),
  );
}
```

```ts
import { Component } from "@angular/core";
import { Button } from "./markas/button.component";
import { WavyBackground } from "./markas/wavy-background.component";

@Component({
  selector: "app-release",
  imports: [Button, WavyBackground],
  template: `
    <div
      markas-wavy-background
      variant="ocean"
      color="primary"
      class="rounded-xl border border-line bg-surface px-6 pt-12 pb-32"
    >
      <h2 class="text-2xl font-semibold text-ink">
        Calm releases, every Friday
      </h2>
      <button markas-button>Start free trial</button>
    </div>
  `,
})
export class Release {}
```

Angular memakai attribute selector pada div native, jadi `class`, `aria-*`, dan atribut lain tetap di elemen akar.

## Props

| Nama | Tipe | Default | Keterangan |
| --- | --- | --- | --- |
| `variant` | `ocean \| silk \| layered` | ocean | ocean: ombak terisi yang diburamkan di bagian bawah. silk: garis tipis mengalir di tengah. layered: pita bertumpuk seperti bukit. |
| `color` | `muted \| ink \| primary \| success \| warning \| danger` | primary | Warna token gelombang. Setiap lapis memakai opasitasnya sendiri. |
| `speed` | `slow \| normal \| fast` | normal | Kecepatan gelombang bergeser. Lapis belakang selalu sedikit lebih lambat dari lapis depan. |
| `waves` | `number` | 4 | Jumlah lapis gelombang, dari 3 sampai 5. |
| `children / slot` | `slot / ReactNode` | - | Konten yang tampil di atas gelombang. |

## Aksesibilitas

- Lapisan gelombang memakai aria-hidden dan mengabaikan pointer.
- Dengan reduced motion, gelombang berhenti dan diam di tempat.

## Catatan

- Gelombang adalah path SVG biasa yang bergeser ke samping dengan satu keyframe CSS. Tanpa JavaScript, canvas, atau backdrop-filter.
- Blur ringan berupa filter CSS hanya pada lapisan gelombang, jadi konten di atasnya tetap tajam.
- Dengan reduced motion gelombang berhenti di posisi yang sama di semua framework.
- Komponen ini tidak punya teks bawaan, jadi tidak ada prop label yang perlu diterjemahkan.
