0xdhrv/oneko
关于
A tiny pixel cat for React, installable as a shadcn registry component
网站与应用开发实测星标增长
- 24小时
- 0
- 7天
- +1
- 15天
- +1
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文Oneko
A tiny pixel cat for your website. React, Svelte, Vue, Solid, one script tag, or every site in Chrome.
Playground · Studio · Documentation
Oneko follows the pointer, naps when things are quiet, and shares cat-themed thoughts. It comes with 24 pixel-art coats, optional sounds, keep-out zones, and a studio for designing your own cat.
- A parade of cats: mount several and set
chase="cat"so each follows the one before it. - Page reactions:
napWhileTyping,followFocus, andperchOnHover. - Visitor controls: a remembered hide toggle (
setCatsHiddenordata-oneko-toggle) and a keyboard-reachablepettablecat. - Play:
grabbablecats can be tossed,treatsturns a double-click into a fish, anddata-oneko-knockableanddata-oneko-boxgive resting cats something to knock over or sit in. - Tour cat:
goTo,say,sit, andfollowfrom a React ref,createOneko, or<oneko-cat>, plusdata-oneko-saycomments andonPet,onCatchCursor,onSleep,onToss, andonTreatevents. - Seasons and moods: a holiday hat around Halloween, the winter holidays, and New Year
(
seasonal={false}to opt out), cat hours withtimeOfDay, and greetings for returning visitors withaffection. - Hosted coats: wear any 256 × 128 sprite sheet by URL, and share it with
/studio?sprite=https://…. - Studio: draw every frame, record your own sounds, and share the whole cat in a link at
/studio.
React
Install the shadcn registry item. You get the source, so the code is yours to change.
npx shadcn@latest add https://oneko.dhrv.pw/r/oneko.json
Render one Oneko from a client component. It mounts itself on document.body.
"use client";
import Oneko from "@/components/oneko";
export function CatLayer() {
return <Oneko skin="calico" bubbleText="treat inspection in progress" />;
}
In Next.js App Router, load it with dynamic(..., { ssr: false }) from a client wrapper. See the
installation guide.
Named skins load in one chunk the first time one is used. For the classic coat only (plus custom
sprites), install https://oneko.dhrv.pw/r/oneko-classic.json instead.
Svelte, Vue, and Solid
Download the component into your project. It takes the same props as the React component.
curl -o src/lib/Oneko.svelte https://oneko.dhrv.pw/frameworks/Oneko.svelte
<script>
import Oneko from "$lib/Oneko.svelte";
</script>
<Oneko skin="calico" meow />
curl -o src/components/Oneko.vue https://oneko.dhrv.pw/frameworks/Oneko.vue
<script setup>
import Oneko from "./components/Oneko.vue";
</script>
<template>
<Oneko skin="calico" :speed="12" meow @state-change="console.log" />
</template>
curl -o src/components/Oneko.tsx https://oneko.dhrv.pw/frameworks/Oneko.solid.tsx
import Oneko from "./components/Oneko";
export default function App() {
return <Oneko skin="calico" meow onStateChange={console.log} />;
}
Each loads the engine from the hosted build in the browser, so SvelteKit, Nuxt, and SolidStart can render them during SSR. See the framework guide.
npm
To bundle the engine and coats instead of loading them from oneko.dhrv.pw, install the package.
npm install oneko
import Oneko from "oneko"; // React
import Oneko from "oneko/vue";
import Oneko from "oneko/svelte";
import Oneko from "oneko/solid";
import { createOneko } from "oneko/vanilla";
See the package README for sounds and SSR notes.
Any other site
Astro, Hugo, WordPress, or plain HTML can use one script tag. Options are data- attributes named
after the props.
<script type="module" src="https://oneko.dhrv.pw/oneko.js" data-skin="calico" data-meow></script>
You can also use a <oneko-cat> element, which fires statechange events and works in Angular,
Lit, and other frameworks, or the createOneko() API. See
Without React.
Chrome extension
The extension puts the cat on every site you visit, with a toolbar popup for the coat, size, sounds, and a per-site switch.
Documentation
The documentation covers every prop, skins, zones, sounds, events, and the studio. Agents can read the Markdown version or llms.txt.
Development
pnpm install
pnpm dev
pnpm lint
pnpm fmt:check
pnpm test
pnpm test:browser
pnpm build
pnpm build regenerates the registry and public/oneko.js before building the site.
pnpm build:package builds the npm package in packages/oneko/dist, and pnpm build:extension
builds the Chrome extension and its Web Store zip in dist/. To deploy
to Cloudflare Workers, run pnpm preview locally, then pnpm deploy. See the
development notes for details.
| Path | Purpose |
|---|---|
components/oneko.tsx |
Installable React component. |
hooks/ and lib/oneko/ |
Animation hook and engine. |
lib/oneko/vanilla*.ts |
Framework-free build served as /oneko.js. |
public/frameworks/ |
Svelte, Vue, and Solid components. |
packages/oneko/ |
npm package and its framework entries. |
extension/ |
Chrome extension. |
registry.json |
Source manifest for the shadcn registry. |
app/ |
Playground, studio, and documentation. |
Credits
Oneko is inspired by adryd325/oneko.js and the skin gallery in oneko-swift. The sprite artwork belongs to its original creators; see skin credits.
Code is available under the MIT License.
探索相关项目
加载中…