{"id":50551221,"url":"https://github.com/serafimcloud/flag-wave-bookmark","last_synced_at":"2026-06-04T03:30:28.741Z","repository":{"id":362186112,"uuid":"1257787557","full_name":"serafimcloud/flag-wave-bookmark","owner":"serafimcloud","description":"A React bookmark icon that ripples like a flag in the wind - procedural SVG sine-wave, eased on hover, zero runtime deps.","archived":false,"fork":false,"pushed_at":"2026-06-03T02:33:24.000Z","size":1491,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-03T04:20:21.971Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://flag-wave-bookmark.vercel.app","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/serafimcloud.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-03T02:25:12.000Z","updated_at":"2026-06-03T02:33:57.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/serafimcloud/flag-wave-bookmark","commit_stats":null,"previous_names":["serafimcloud/flag-wave-bookmark"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/serafimcloud/flag-wave-bookmark","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serafimcloud%2Fflag-wave-bookmark","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serafimcloud%2Fflag-wave-bookmark/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serafimcloud%2Fflag-wave-bookmark/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serafimcloud%2Fflag-wave-bookmark/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/serafimcloud","download_url":"https://codeload.github.com/serafimcloud/flag-wave-bookmark/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serafimcloud%2Fflag-wave-bookmark/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33888302,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-04T02:00:06.755Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-04T03:30:27.897Z","updated_at":"2026-06-04T03:30:28.733Z","avatar_url":"https://github.com/serafimcloud.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# flag-wave-bookmark\n\nA React bookmark icon that ripples like a **flag in the wind**. The top edge stays pinned; the cloth below snakes on a traveling sine wave - eased into the wind on hover, settling back to rest on leave.\n\nBuilt on the [lucide](https://lucide.dev) bookmark outline, animated procedurally - no CSS keyframes, no animation library, no runtime dependencies.\n\n![flag-wave-bookmark demo](public/demo.gif)\n\n**Live demo:** \u003c!-- LIVE_DEMO --\u003e[flag-wave-bookmark.vercel.app](https://flag-wave-bookmark.vercel.app)\u003c!-- /LIVE_DEMO --\u003e\n\n## Why it looks good\n\n- **The shape ripples, it doesn't lean.** Each point is displaced sideways by an amount that grows from 0 at the pinned top to its peak at the free bottom edge - so the outline itself snakes, like real cloth, instead of just tilting.\n- **Traveling wave.** The ripple advances down the flag over time; it's not a single static bend.\n- **Eased, never snapped.** The amplitude lerps toward its target, so the flag picks up the wind on hover and settles back on leave instead of cutting on and off.\n- **Three drive modes.** Hover (default), always-on (`active`), or imperative (`ref.startAnimation()` / `ref.stopAnimation()`).\n- **Accessible.** Honors `prefers-reduced-motion` - reduced motion just renders the bookmark at rest, with no loop running.\n- **Zero runtime dependencies.** Just React, in a single self-contained file. No CSS file, no config: it's pure SVG path math on a `requestAnimationFrame` loop.\n\n## Install\n\nCopy the single file - [`src/components/bookmark.tsx`](src/components/bookmark.tsx) - into your project. No CSS, no config. (React 18+.)\n\n## Usage\n\n```tsx\nimport { BookmarkIcon } from \"@/components/bookmark\";\n\n// waves on hover, settles on leave\n\u003cBookmarkIcon /\u003e\n\n// waves continuously (e.g. a \"saved\" button)\n\u003cBookmarkIcon active size={20} /\u003e\n\n// tune the wind\n\u003cBookmarkIcon active amp={0.7} freq={0.5} period={900} /\u003e\n```\n\nImperative control via a ref - wave the icon from its parent's hover (or any other trigger):\n\n```tsx\nimport { useRef } from \"react\";\nimport { BookmarkIcon, type BookmarkIconHandle } from \"@/components/bookmark\";\n\nfunction SaveButton() {\n  const ref = useRef\u003cBookmarkIconHandle\u003e(null);\n  return (\n    \u003cbutton\n      onMouseEnter={() =\u003e ref.current?.startAnimation()}\n      onMouseLeave={() =\u003e ref.current?.stopAnimation()}\n    \u003e\n      \u003cBookmarkIcon ref={ref} /\u003e Save\n    \u003c/button\u003e\n  );\n}\n```\n\n\u003e Passing a `ref` hands you manual control and turns off the icon's built-in hover, so the wave follows your button's hover (or whatever you wire it to) instead of the icon's own.\n\n## Props\n\n| Prop        | Type      | Default | Description                                                                  |\n| ----------- | --------- | ------- | ---------------------------------------------------------------------------- |\n| `size`      | `number`  | `28`    | Pixel size of the square icon.                                               |\n| `active`    | `boolean` | `false` | Wave continuously. When `false`, the icon waves only on hover.               |\n| `amp`       | `number`  | `0.5`   | Peak sideways sway at the free (bottom) edge, in viewBox units. `0` = off.   |\n| `freq`      | `number`  | `0.5`   | Ripples along the length (1 = a single S from top to bottom).                |\n| `period`    | `number`  | `1000`  | Milliseconds per wave cycle. Lower = faster flapping.                        |\n| `className` | `string`  | -       | Applied to the root `\u003cdiv\u003e`; also forwards any other `\u003cdiv\u003e` props.          |\n\nThe icon draws with `stroke=\"currentColor\"`, so color it with CSS `color` on the element (or any parent).\n\n## How it works\n\nThe bookmark is the lucide outline in a `24x24` viewBox. Its top edge (`y=3`) is treated as the pinned hoist of a flag; everything below is cloth. `buildBookmarkFlagPath(phase)` walks the outline and offsets every point horizontally by\n\n```\ndx(y) = amp * u * sin(2π · freq · u + phase),   where u = (y - 3) / (21 - 3)\n```\n\n`u` is 0 at the pinned top and 1 at the free bottom, so the displacement vanishes at the top and is largest at the bottom - the shape snakes instead of sliding sideways. The straight edges are subdivided into 16 segments each so the rippled curve stays smooth.\n\n`useFlagWave` advances `phase` on a `requestAnimationFrame` loop and lerps the amplitude toward its target (`0.12` per frame), so the flag eases in and out. When the target is 0 and the amplitude has decayed near zero, it snaps back to the exact rest path and stops the loop. `prefers-reduced-motion` skips the loop entirely.\n\n`buildBookmarkFlagPath` and `useFlagWave` are exported too, if you want to drive your own SVG.\n\n## Demo app\n\nThis repo is also a tiny Next.js app showcasing the component. Run it locally:\n\n```bash\nnpm install\nnpm run dev\n# open http://localhost:3000\n```\n\n## Recording the GIF\n\nThe demo GIF is produced from the running demo with Playwright + ffmpeg:\n\n```bash\nnpm i -D playwright \u0026\u0026 npx playwright install chromium\nnpm run dev                                   # in one terminal\nDEMO_URL=http://localhost:3000 npm run record # in another\n# then convert the webm:\nffmpeg -y -i recording/*.webm \\\n  -vf \"fps=24,scale=820:-1:flags=lanczos,split[s0][s1];[s0]palettegen=max_colors=128[p];[s1][p]paletteuse=dither=bayer\" \\\n  -loop 0 public/demo.gif\n```\n\n## License\n\n[MIT](LICENSE) © [serafim](https://github.com/serafimcloud)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserafimcloud%2Fflag-wave-bookmark","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fserafimcloud%2Fflag-wave-bookmark","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserafimcloud%2Fflag-wave-bookmark/lists"}