├── .github └── workflows │ └── deploy.yml ├── .gitignore ├── .husky └── pre-commit ├── .prettierrc ├── LICENSE ├── README.md ├── demo ├── .gitignore ├── README.md ├── components.json ├── index.html ├── package.json ├── postcss.config.js ├── public │ └── favicon.svg ├── src │ ├── App.tsx │ ├── assets │ │ ├── avatar.jpg │ │ ├── github.svg │ │ └── mask.svg │ ├── components │ │ ├── danmu │ │ │ ├── Container.tsx │ │ │ ├── Danmaku.tsx │ │ │ ├── TopBar.tsx │ │ │ └── Transmitter.tsx │ │ ├── sidebar │ │ │ ├── SidebarAreaX.tsx │ │ │ ├── SidebarAreaY.tsx │ │ │ ├── SidebarDirection.tsx │ │ │ ├── SidebarFreeze.tsx │ │ │ ├── SidebarFrequency.tsx │ │ │ ├── SidebarGap.tsx │ │ │ ├── SidebarModeSelect.tsx │ │ │ ├── SidebarMoveDuration.tsx │ │ │ ├── SidebarNumbers.tsx │ │ │ ├── SidebarOcclusion.tsx │ │ │ ├── SidebarOpacity.tsx │ │ │ ├── SidebarRate.tsx │ │ │ ├── SidebarShowAndHide.tsx │ │ │ ├── SidebarSpeed.tsx │ │ │ ├── SidebarStartAndStop.tsx │ │ │ └── index.tsx │ │ └── ui │ │ │ ├── avatar.tsx │ │ │ ├── badge.tsx │ │ │ ├── button.tsx │ │ │ ├── input.tsx │ │ │ ├── label.tsx │ │ │ ├── popover.tsx │ │ │ ├── select.tsx │ │ │ ├── sheet.tsx │ │ │ ├── slider.tsx │ │ │ ├── switch.tsx │ │ │ ├── tabs.tsx │ │ │ ├── textarea.tsx │ │ │ ├── toast.tsx │ │ │ ├── toaster.tsx │ │ │ ├── tooltip.tsx │ │ │ └── use-toast.ts │ ├── globals.css │ ├── i18n │ │ ├── en.ts │ │ └── zh.ts │ ├── lib │ │ └── utils.ts │ ├── main.tsx │ ├── manager.tsx │ ├── types.ts │ └── vite-env.d.ts ├── tailwind.config.js ├── tsconfig.json └── vite.config.ts ├── docs ├── .vitepress │ ├── config │ │ ├── en.ts │ │ ├── index.ts │ │ ├── shared.ts │ │ └── zh.ts │ └── theme │ │ ├── index.ts │ │ └── main.css ├── en │ ├── cases │ │ ├── anti-occlusion.md │ │ ├── cooldown.md │ │ ├── custom-container.md │ │ ├── custom-danmaku.md │ │ ├── filter-keyword.md │ │ ├── fixed.md │ │ ├── image.md │ │ ├── like.md │ │ ├── loop.md │ │ ├── recommend.md │ │ ├── simplified-mode.md │ │ ├── track-settings.md │ │ └── uniform-speed.md │ ├── guide │ │ ├── create-plugin.md │ │ ├── getting-started.md │ │ └── typescript-interface.md │ ├── index.md │ └── reference │ │ ├── container-api.md │ │ ├── danmaku-api.md │ │ ├── danmaku-hooks.md │ │ ├── danmaku-properties.md │ │ ├── manager-api.md │ │ ├── manager-configuration.md │ │ ├── manager-hooks.md │ │ ├── manager-properties.md │ │ └── track-api.md ├── package.json ├── public │ ├── favicon.svg │ └── logo.svg └── zh │ ├── cases │ ├── anti-occlusion.md │ ├── cooldown.md │ ├── custom-container.md │ ├── custom-danmaku.md │ ├── filter-keyword.md │ ├── fixed.md │ ├── image.md │ ├── like.md │ ├── loop.md │ ├── recommend.md │ ├── simplified-mode.md │ ├── track-settings.md │ └── uniform-speed.md │ ├── guide │ ├── create-plugin.md │ ├── getting-started.md │ └── typescript-interface.md │ ├── index.md │ └── reference │ ├── container-api.md │ ├── danmaku-api.md │ ├── danmaku-hooks.md │ ├── danmaku-properties.md │ ├── manager-api.md │ ├── manager-configuration.md │ ├── manager-hooks.md │ ├── manager-properties.md │ └── track-api.md ├── jest.config.js ├── package.json ├── pnpm-lock.yaml ├── pnpm-workspace.yaml ├── release.ts ├── rollup.config.mjs ├── src ├── __tests__ │ └── index.spec.ts ├── container.ts ├── danmaku │ ├── facile.ts │ └── flexible.ts ├── engine.ts ├── global.d.ts ├── index.ts ├── lifeCycle.ts ├── manager.ts ├── track.ts ├── types.ts └── utils.ts └── tsconfig.json /.github/workflows/deploy.yml: -------------------------------------------------------------------------------- 1 | name: Deploy 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | build-and-deploy: 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - name: Checkout repository 14 | uses: actions/checkout@v2 15 | 16 | - name: Set up Node.js 17 | uses: actions/setup-node@v2 18 | with: 19 | node-version: '20' 20 | 21 | - name: Install pnpm 22 | uses: pnpm/action-setup@v2 23 | with: 24 | version: 9.1.3 25 | 26 | - name: Install dependencies 27 | run: pnpm install 28 | 29 | - name: Build src 30 | run: pnpm run build:core 31 | 32 | - name: Build demo 33 | run: pnpm run build:demo 34 | 35 | - name: Build docs 36 | run: pnpm run build:docs 37 | 38 | - name: Deploy demo to GitHub Pages 39 | uses: peaceiris/actions-gh-pages@v3 40 | with: 41 | github_token: ${{ secrets.GITHUB_TOKEN }} 42 | publish_dir: ./demo/dist 43 | 44 | - name: Deploy docs to GitHub Pages 45 | uses: peaceiris/actions-gh-pages@v3 46 | with: 47 | github_token: ${{ secrets.GITHUB_TOKEN }} 48 | publish_dir: ./docs/.vitepress/dist 49 | destination_dir: ./document 50 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .vscode 3 | dist 4 | cache 5 | test.js 6 | test.ts 7 | node_modules 8 | tsconfig.tsbuildinfo -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . "$(dirname "$0")/_/husky.sh" 3 | 4 | npx lint-staged -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "semi": true, 3 | "printWidth": 80, 4 | "singleQuote": true, 5 | "endOfLine": "lf", 6 | "trailingComma": "all" 7 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2024-present, chentao. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 |

danmu

3 | 4 | [![NPM version](https://img.shields.io/npm/v/danmu.svg)](https://www.npmjs.com/package/danmu) [![build status](https://github.com/imtaotao/danmu/actions/workflows/deploy.yml/badge.svg?branch=master)](https://github.com/imtaotao/danmu/actions/workflows/deploy.yml) 5 | 6 |
7 | 8 | Welcome to the Danmu project! 🎉 This repository is dedicated to providing a robust and user-friendly danmaku solution. Whether you are building an interactive video streaming platform or want to enhance live interactions during events, Danmu got you covered! 9 | 10 | - **Example Project**: https://imtaotao.github.io/danmu/ 11 | 12 | - **Official Documentation**: https://imtaotao.github.io/danmu/document/en/ 13 | 14 |

15 | 16 | ## Why Choose Danmu? 💭 17 | 18 | - 🍃 **Lightweight**: Danmu is designed to be minimal yet powerful. 19 | - 🧩 **Customizable**: Tailor the functionality to fit your specific needs with extensive customization options. 20 | - 🌺 **User Friendly**: Easy to integrate and use, elevating user experience on your platform. 21 | - 🎯 **Full-Featured**: Provides APIs that meet a variety of business needs. 22 | 23 | ## Getting Started 🌟 24 | 25 | To get started with Danmu, please refer to our [**official documentation**](https://imtaotao.github.io/danmu/document/en/guide/getting-started.html), which provides detailed instructions on installation and configurations. 26 | 27 | Thank you for considering Danmu for your project! We are excited to see what you will build with it 😁. 28 | -------------------------------------------------------------------------------- /demo/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /demo/README.md: -------------------------------------------------------------------------------- 1 | # Demo 2 | 3 | This is a demo, deployed on gh-pages. 4 | -------------------------------------------------------------------------------- /demo/components.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://ui.shadcn.com/schema.json", 3 | "style": "default", 4 | "rsc": true, 5 | "tsx": true, 6 | "tailwind": { 7 | "config": "tailwind.config.js", 8 | "css": "src/globals.css", 9 | "baseColor": "slate", 10 | "cssVariables": true, 11 | "prefix": "" 12 | }, 13 | "aliases": { 14 | "components": "@/components", 15 | "utils": "@/lib/utils" 16 | } 17 | } -------------------------------------------------------------------------------- /demo/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Danmu 🌘 Collision detection, highly customized danmu screen styles, you deserve it 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /demo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "demo", 3 | "private": true, 4 | "scripts": { 5 | "dev": "vite", 6 | "a": "pnpx shadcn-ui add", 7 | "build": "tsc -b && vite build", 8 | "preview": "vite preview" 9 | }, 10 | "dependencies": { 11 | "@radix-ui/react-alert-dialog": "^1.1.1", 12 | "@radix-ui/react-avatar": "^1.1.0", 13 | "@radix-ui/react-checkbox": "^1.1.1", 14 | "@radix-ui/react-dialog": "^1.1.1", 15 | "@radix-ui/react-label": "^2.1.0", 16 | "@radix-ui/react-menubar": "^1.1.1", 17 | "@radix-ui/react-popover": "^1.1.1", 18 | "@radix-ui/react-radio-group": "^1.2.0", 19 | "@radix-ui/react-select": "^2.1.1", 20 | "@radix-ui/react-slider": "^1.2.0", 21 | "@radix-ui/react-slot": "^1.1.0", 22 | "@radix-ui/react-switch": "^1.1.0", 23 | "@radix-ui/react-tabs": "^1.1.0", 24 | "@radix-ui/react-toast": "^1.2.1", 25 | "@radix-ui/react-toggle": "^1.1.0", 26 | "@radix-ui/react-toggle-group": "^1.1.0", 27 | "@radix-ui/react-tooltip": "^1.1.2", 28 | "aidly": "^1.9.0", 29 | "class-variance-authority": "^0.7.0", 30 | "clsx": "^2.1.1", 31 | "danmu": "workspace:*", 32 | "i18next": "^23.12.2", 33 | "i18next-browser-languagedetector": "^8.0.0", 34 | "lucide-react": "^0.396.0", 35 | "react": "^18.3.1", 36 | "react-dom": "^18.3.1", 37 | "react-i18next": "^15.0.0", 38 | "react-resizable-panels": "^2.0.19", 39 | "tailwind-merge": "^2.3.0", 40 | "tailwindcss-animate": "^1.0.7" 41 | }, 42 | "devDependencies": { 43 | "@types/react": "^18.3.3", 44 | "@types/react-dom": "^18.3.0", 45 | "@vitejs/plugin-react": "^4.3.1", 46 | "autoprefixer": "^10.4.19", 47 | "postcss": "^8.4.38", 48 | "tailwindcss": "^3.4.4", 49 | "typescript": "^5.8.3", 50 | "vite": "^5.3.1" 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /demo/postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | }; 7 | -------------------------------------------------------------------------------- /demo/public/favicon.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /demo/src/App.tsx: -------------------------------------------------------------------------------- 1 | import type { Manager } from 'danmu'; 2 | import type { DanmakuValue } from '@/types'; 3 | import { cn, isMobile } from '@/lib/utils'; 4 | import { Sidebar } from '@/components/sidebar'; 5 | import { Toaster } from '@/components/ui/toaster'; 6 | import { TopBar } from '@/components/danmu/TopBar'; 7 | import { Container } from '@/components/danmu/Container'; 8 | import { Transmitter } from '@/components/danmu/Transmitter'; 9 | 10 | export function App({ manager }: { manager: Manager }) { 11 | return ( 12 |
13 |
19 | {isMobile ? null : ( 20 |
21 | 22 |
23 | )} 24 |
25 |
31 | 32 | 33 |
34 | {isMobile ? null : ( 35 |
36 | 37 |
38 | )} 39 |
40 |
41 | 42 |
43 | ); 44 | } 45 | -------------------------------------------------------------------------------- /demo/src/assets/avatar.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imtaotao/danmu/9ca0f4e567526db43766fb2f522a155efe814ab6/demo/src/assets/avatar.jpg -------------------------------------------------------------------------------- /demo/src/assets/github.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /demo/src/assets/mask.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /demo/src/components/danmu/Container.tsx: -------------------------------------------------------------------------------- 1 | import { useEffect, useRef, memo } from 'react'; 2 | import { Maximize } from 'lucide-react'; 3 | import type { Manager } from 'danmu'; 4 | import type { DanmakuValue } from '@/types'; 5 | 6 | export const Container = memo( 7 | ({ manager }: { manager: Manager }) => { 8 | const ref = useRef(null); 9 | 10 | useEffect(() => { 11 | const format = () => { 12 | manager.nextFrame(() => { 13 | if (ref.current) { 14 | manager.mount(ref.current); 15 | } 16 | }); 17 | }; 18 | 19 | if (ref.current) { 20 | manager.mount(ref.current); 21 | manager.startPlaying(); 22 | document.addEventListener('fullscreenchange', format); 23 | } 24 | 25 | return () => { 26 | document.removeEventListener('fullscreenchange', format); 27 | }; 28 | }, []); 29 | 30 | return ( 31 |
37 | { 42 | if (!document.fullscreenElement) { 43 | if (ref.current) { 44 | manager.each((dm) => { 45 | dm.destroy(); 46 | }); 47 | ref.current.requestFullscreen(); 48 | } 49 | } else { 50 | document.exitFullscreen(); 51 | } 52 | }} 53 | /> 54 |
55 | ); 56 | }, 57 | ); 58 | -------------------------------------------------------------------------------- /demo/src/components/danmu/Danmaku.tsx: -------------------------------------------------------------------------------- 1 | import { useState } from 'react'; 2 | import { ThumbsUp } from 'lucide-react'; 3 | import { useTranslation } from 'react-i18next'; 4 | import type { Danmaku, Manager } from 'danmu'; 5 | import type { Statuses, DanmakuValue } from '@/types'; 6 | import { cn } from '@/lib/utils'; 7 | import avatarPath from '@/assets/avatar.jpg'; 8 | import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; 9 | import { 10 | Popover, 11 | PopoverContent, 12 | PopoverTrigger, 13 | } from '@/components/ui/popover'; 14 | 15 | // Render file:demo/src/manager.tsx 16 | export const DanmakuComponent = ({ 17 | manager, 18 | danmaku, 19 | }: { 20 | danmaku: Danmaku; 21 | manager: Manager; 22 | }) => { 23 | const { t } = useTranslation(); 24 | const [open, setOpen] = useState(false); 25 | let isSelf; 26 | let content; 27 | if (typeof danmaku.data === 'string') { 28 | isSelf = true; 29 | content = danmaku.data; 30 | } else { 31 | isSelf = danmaku.data.isSelf; 32 | content = danmaku.data.content; 33 | } 34 | 35 | danmaku.use({ 36 | pause() { 37 | setOpen(true); 38 | }, 39 | resume() { 40 | setOpen(false); 41 | }, 42 | beforeMove(dm) { 43 | for (const key in manager.statuses) { 44 | dm.setStyle( 45 | key as keyof Statuses, 46 | manager.statuses[key as keyof Statuses], 47 | ); 48 | } 49 | }, 50 | }); 51 | 52 | return ( 53 |
54 | 55 | 56 |
danmaku.pause()} 58 | onMouseLeave={() => { 59 | if (!manager.isFreeze()) { 60 | danmaku.resume(); 61 | } 62 | }} 63 | onClick={() => { 64 | setOpen(false); 65 | setTimeout(() => danmaku.destroy('mark'), 100); 66 | }} 67 | className={cn( 68 | isSelf ? 'border-2 border-solid border-teal-500' : '', 69 | 'py-[5px] px-3 rounded-xl font-bold text-slate-900 text-center cursor-pointer bg-gray-300 hover:bg-gray-400 flex items-center', 70 | )} 71 | > 72 | 73 | 74 | CN 75 | 76 | 77 | {danmaku.type === 'flexible' 78 | ? `${t('flexibleDanmaku')} -- ${content}` 79 | : content} 80 | 81 | 82 |
83 |
84 | 85 | {t('thisIsA')} 86 | 87 | {danmaku.type === 'flexible' 88 | ? t('flexibleDanmaku') 89 | : t('facileDanmaku')} 90 | {danmaku.isFixedDuration ? ` (${t('correctedDuration')})` : ''} 91 | 92 | 93 |
94 |
95 | ); 96 | }; 97 | -------------------------------------------------------------------------------- /demo/src/components/danmu/TopBar.tsx: -------------------------------------------------------------------------------- 1 | import { useTranslation } from 'react-i18next'; 2 | import { cn, isMobile } from '@/lib/utils'; 3 | import githubLogo from '@/assets/github.svg'; 4 | import { 5 | Select, 6 | SelectContent, 7 | SelectItem, 8 | SelectTrigger, 9 | SelectValue, 10 | } from '@/components/ui/select'; 11 | 12 | export function TopBar() { 13 | const { t, i18n } = useTranslation(); 14 | 15 | return ( 16 |
17 | 22 | github logo 27 | 28 | 40 |
41 | ); 42 | } 43 | -------------------------------------------------------------------------------- /demo/src/components/sidebar/SidebarAreaX.tsx: -------------------------------------------------------------------------------- 1 | import { memo } from 'react'; 2 | import { Dog } from 'lucide-react'; 3 | import { useTranslation } from 'react-i18next'; 4 | import type { Manager } from 'danmu'; 5 | import type { DanmakuValue } from '@/types'; 6 | import { Label } from '@/components/ui/label'; 7 | import { Slider } from '@/components/ui/slider'; 8 | 9 | export const SidebarAreaX = memo( 10 | ({ manager }: { manager: Manager }) => { 11 | const { t } = useTranslation(); 12 | 13 | return ( 14 |
15 | 19 | { 26 | manager.setArea({ 27 | x: { 28 | end: `${v[1]}%`, 29 | start: `${v[0]}%`, 30 | }, 31 | }); 32 | }} 33 | /> 34 |
35 | ); 36 | }, 37 | ); 38 | -------------------------------------------------------------------------------- /demo/src/components/sidebar/SidebarAreaY.tsx: -------------------------------------------------------------------------------- 1 | import { memo } from 'react'; 2 | import { Dog } from 'lucide-react'; 3 | import { useTranslation } from 'react-i18next'; 4 | import type { Manager } from 'danmu'; 5 | import type { DanmakuValue } from '@/types'; 6 | import { Label } from '@/components/ui/label'; 7 | import { Slider } from '@/components/ui/slider'; 8 | 9 | export const SidebarAreaY = memo( 10 | ({ manager }: { manager: Manager }) => { 11 | const { t } = useTranslation(); 12 | 13 | return ( 14 |
15 | 19 | { 26 | manager.setArea({ 27 | y: { 28 | end: `${v[1]}%`, 29 | start: `${v[0]}%`, 30 | }, 31 | }); 32 | }} 33 | /> 34 |
35 | ); 36 | }, 37 | ); 38 | -------------------------------------------------------------------------------- /demo/src/components/sidebar/SidebarDirection.tsx: -------------------------------------------------------------------------------- 1 | import { memo } from 'react'; 2 | import { Bone } from 'lucide-react'; 3 | import { useTranslation } from 'react-i18next'; 4 | import type { Manager } from 'danmu'; 5 | import type { DanmakuValue } from '@/types'; 6 | import { Label } from '@/components/ui/label'; 7 | import { Switch } from '@/components/ui/switch'; 8 | 9 | export const SidebarDirection = memo( 10 | ({ manager }: { manager: Manager }) => { 11 | const { t } = useTranslation(); 12 | 13 | return ( 14 |
15 | 22 | 26 | manager.updateOptions({ 27 | direction: v ? 'right' : 'left', 28 | }) 29 | } 30 | /> 31 |
32 | ); 33 | }, 34 | ); 35 | -------------------------------------------------------------------------------- /demo/src/components/sidebar/SidebarFreeze.tsx: -------------------------------------------------------------------------------- 1 | import { memo } from 'react'; 2 | import { Shell } from 'lucide-react'; 3 | import { useTranslation } from 'react-i18next'; 4 | import type { Manager } from 'danmu'; 5 | import type { DanmakuValue } from '@/types'; 6 | import { Label } from '@/components/ui/label'; 7 | import { Switch } from '@/components/ui/switch'; 8 | 9 | export const SidebarFreeze = memo( 10 | ({ manager }: { manager: Manager }) => { 11 | const { t } = useTranslation(); 12 | 13 | return ( 14 |
15 | 22 | { 25 | // Do not trigger the built-in `pause` and `resume` events 26 | const options = { preventEvents: ['pause', 'resume'] }; 27 | v ? manager.freeze(options) : manager.unfreeze(options); 28 | }} 29 | /> 30 |
31 | ); 32 | }, 33 | ); 34 | -------------------------------------------------------------------------------- /demo/src/components/sidebar/SidebarFrequency.tsx: -------------------------------------------------------------------------------- 1 | import { memo } from 'react'; 2 | import { throttle } from 'aidly'; 3 | import { Fish, CircleAlert } from 'lucide-react'; 4 | import { useTranslation } from 'react-i18next'; 5 | import type { Manager } from 'danmu'; 6 | import type { DanmakuValue } from '@/types'; 7 | import { Label } from '@/components/ui/label'; 8 | import { Input } from '@/components/ui/input'; 9 | import { 10 | Tooltip, 11 | TooltipContent, 12 | TooltipProvider, 13 | TooltipTrigger, 14 | } from '@/components/ui/tooltip'; 15 | 16 | export const SidebarFrequency = memo( 17 | ({ manager }: { manager: Manager }) => { 18 | const { t } = useTranslation(); 19 | 20 | return ( 21 |
22 | 36 | { 42 | manager.updateOptions({ interval: Number(e.target.value) }); 43 | })} 44 | /> 45 |
46 | ); 47 | }, 48 | ); 49 | -------------------------------------------------------------------------------- /demo/src/components/sidebar/SidebarGap.tsx: -------------------------------------------------------------------------------- 1 | import { memo } from 'react'; 2 | import { throttle } from 'aidly'; 3 | import { useTranslation } from 'react-i18next'; 4 | import { Squirrel, CircleAlert } from 'lucide-react'; 5 | import type { Manager } from 'danmu'; 6 | import type { DanmakuValue } from '@/types'; 7 | import { Label } from '@/components/ui/label'; 8 | import { Input } from '@/components/ui/input'; 9 | import { 10 | Tooltip, 11 | TooltipContent, 12 | TooltipProvider, 13 | TooltipTrigger, 14 | } from '@/components/ui/tooltip'; 15 | 16 | export const SidebarGap = memo( 17 | ({ manager }: { manager: Manager }) => { 18 | const { t } = useTranslation(); 19 | 20 | return ( 21 |
22 | 36 | { 42 | manager.updateOptions({ gap: Number(e.target.value) }); 43 | })} 44 | /> 45 |
46 | ); 47 | }, 48 | ); 49 | -------------------------------------------------------------------------------- /demo/src/components/sidebar/SidebarModeSelect.tsx: -------------------------------------------------------------------------------- 1 | import { memo } from 'react'; 2 | import { useTranslation } from 'react-i18next'; 3 | import { Snail, CircleAlert } from 'lucide-react'; 4 | import type { Mode, Manager } from 'danmu'; 5 | import type { DanmakuValue } from '@/types'; 6 | import { Label } from '@/components/ui/label'; 7 | import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs'; 8 | import { 9 | Tooltip, 10 | TooltipContent, 11 | TooltipProvider, 12 | TooltipTrigger, 13 | } from '@/components/ui/tooltip'; 14 | 15 | export const SidebarModeSelect = memo( 16 | ({ manager }: { manager: Manager }) => { 17 | const { t } = useTranslation(); 18 | 19 | return ( 20 |
21 | 43 | 46 | manager.updateOptions({ 47 | mode: e.target.textContent?.trim() as Mode, 48 | }) 49 | } 50 | > 51 | 52 | 53 | none 54 | 55 | 56 | strict 57 | 58 | 59 | adaptive 60 | 61 | 62 | 63 |
64 | ); 65 | }, 66 | ); 67 | -------------------------------------------------------------------------------- /demo/src/components/sidebar/SidebarMoveDuration.tsx: -------------------------------------------------------------------------------- 1 | import { memo } from 'react'; 2 | import { throttle } from 'aidly'; 3 | import { useTranslation } from 'react-i18next'; 4 | import { Rabbit, CircleAlert } from 'lucide-react'; 5 | import type { Manager } from 'danmu'; 6 | import type { DanmakuValue } from '@/types'; 7 | import { Label } from '@/components/ui/label'; 8 | import { Input } from '@/components/ui/input'; 9 | import { 10 | Tooltip, 11 | TooltipContent, 12 | TooltipProvider, 13 | TooltipTrigger, 14 | } from '@/components/ui/tooltip'; 15 | 16 | export const SidebarMoveDuration = memo( 17 | ({ manager }: { manager: Manager }) => { 18 | const { t } = useTranslation(); 19 | 20 | return ( 21 |
22 | 36 | { 42 | manager.updateOptions({ 43 | durationRange: [ 44 | Number(e.target.value), 45 | manager.options.durationRange[1], 46 | ], 47 | }); 48 | })} 49 | /> 50 | { 56 | manager.setDurationRange([ 57 | manager.options.durationRange[0], 58 | Number(e.target.value), 59 | ]); 60 | })} 61 | /> 62 |
63 | ); 64 | }, 65 | ); 66 | -------------------------------------------------------------------------------- /demo/src/components/sidebar/SidebarNumbers.tsx: -------------------------------------------------------------------------------- 1 | import { memo, useState, useEffect } from 'react'; 2 | import { Asterisk } from 'lucide-react'; 3 | import { useTranslation } from 'react-i18next'; 4 | import type { Manager } from 'danmu'; 5 | import type { DanmakuValue } from '@/types'; 6 | import { Label } from '@/components/ui/label'; 7 | import { Badge } from '@/components/ui/badge'; 8 | 9 | export const SidebarNumbers = memo( 10 | ({ manager }: { manager: Manager }) => { 11 | const { t } = useTranslation(); 12 | const [allNumber, setAllNumber] = useState(0); 13 | const [stashNumber, setStashNumber] = useState(0); 14 | const [renderNumber, setRenderNumber] = useState(0); 15 | 16 | useEffect(() => { 17 | const name = 'DanmakuNumber'; 18 | const update = () => { 19 | const { all, view, stash } = manager.len(); 20 | setAllNumber(all); 21 | setStashNumber(stash); 22 | setRenderNumber(view); 23 | }; 24 | manager.use({ 25 | name, 26 | push: () => update(), 27 | clear: () => update(), 28 | $destroyed: () => update(), 29 | $beforeMove: () => update(), 30 | }); 31 | return () => { 32 | manager.remove(name); 33 | }; 34 | }, [manager]); 35 | 36 | return ( 37 | <> 38 |
39 | 43 | {renderNumber} 44 |
45 |
46 | 50 | {stashNumber} 51 |
52 |
53 | 57 | {allNumber} 58 |
59 | 60 | ); 61 | }, 62 | ); 63 | -------------------------------------------------------------------------------- /demo/src/components/sidebar/SidebarOcclusion.tsx: -------------------------------------------------------------------------------- 1 | import { memo } from 'react'; 2 | import { VenetianMask } from 'lucide-react'; 3 | import { useTranslation } from 'react-i18next'; 4 | import type { Manager } from 'danmu'; 5 | import type { DanmakuValue } from '@/types'; 6 | import { Label } from '@/components/ui/label'; 7 | import { Switch } from '@/components/ui/switch'; 8 | import maskPath from '@/assets/mask.svg'; 9 | 10 | export const SidebarOcclusion = memo( 11 | ({ manager }: { manager: Manager }) => { 12 | const { t } = useTranslation(); 13 | 14 | return ( 15 |
16 | 23 | { 26 | // The second parameter is optional, If not passed, the default is the built-in danmaku container. 27 | // But it should be noted that the danmaku container will change with the display area, so the second parameter may be required. 28 | manager.updateOccludedUrl(v ? maskPath : '', '#RenderContainer'); 29 | }} 30 | /> 31 |
32 | ); 33 | }, 34 | ); 35 | -------------------------------------------------------------------------------- /demo/src/components/sidebar/SidebarOpacity.tsx: -------------------------------------------------------------------------------- 1 | import { memo } from 'react'; 2 | import { throttle } from 'aidly'; 3 | import { PawPrint } from 'lucide-react'; 4 | import { useTranslation } from 'react-i18next'; 5 | import type { Manager } from 'danmu'; 6 | import type { DanmakuValue } from '@/types'; 7 | import { Label } from '@/components/ui/label'; 8 | import { Slider } from '@/components/ui/slider'; 9 | 10 | export const SidebarOpacity = memo( 11 | ({ manager }: { manager: Manager }) => { 12 | const { t } = useTranslation(); 13 | 14 | return ( 15 |
16 | 20 | { 26 | manager.setOpacity(v[0] / 100); 27 | })} 28 | /> 29 |
30 | ); 31 | }, 32 | ); 33 | -------------------------------------------------------------------------------- /demo/src/components/sidebar/SidebarRate.tsx: -------------------------------------------------------------------------------- 1 | import { memo } from 'react'; 2 | import { throttle } from 'aidly'; 3 | import { useTranslation } from 'react-i18next'; 4 | import { Squirrel, CircleAlert } from 'lucide-react'; 5 | import type { Manager } from 'danmu'; 6 | import type { DanmakuValue } from '@/types'; 7 | import { Label } from '@/components/ui/label'; 8 | import { Input } from '@/components/ui/input'; 9 | import { 10 | Tooltip, 11 | TooltipContent, 12 | TooltipProvider, 13 | TooltipTrigger, 14 | } from '@/components/ui/tooltip'; 15 | 16 | export const SidebarRate = memo( 17 | ({ manager }: { manager: Manager }) => { 18 | const { t } = useTranslation(); 19 | 20 | return ( 21 |
22 | 36 | { 42 | manager.setRate(Number(e.target.value)); 43 | })} 44 | /> 45 |
46 | ); 47 | }, 48 | ); 49 | -------------------------------------------------------------------------------- /demo/src/components/sidebar/SidebarShowAndHide.tsx: -------------------------------------------------------------------------------- 1 | import { memo } from 'react'; 2 | import { Turtle } from 'lucide-react'; 3 | import { useTranslation } from 'react-i18next'; 4 | import type { Manager } from 'danmu'; 5 | import type { DanmakuValue } from '@/types'; 6 | import { Label } from '@/components/ui/label'; 7 | import { Switch } from '@/components/ui/switch'; 8 | 9 | export const SidebarShowAndHide = memo( 10 | ({ manager }: { manager: Manager }) => { 11 | const { t } = useTranslation(); 12 | 13 | return ( 14 |
15 | 22 | { 26 | v ? manager.show() : manager.hide(); 27 | }} 28 | /> 29 |
30 | ); 31 | }, 32 | ); 33 | -------------------------------------------------------------------------------- /demo/src/components/sidebar/SidebarSpeed.tsx: -------------------------------------------------------------------------------- 1 | import { memo } from 'react'; 2 | import { throttle } from 'aidly'; 3 | import { useTranslation } from 'react-i18next'; 4 | import { Squirrel, CircleAlert } from 'lucide-react'; 5 | import type { Manager } from 'danmu'; 6 | import type { DanmakuValue } from '@/types'; 7 | import { Label } from '@/components/ui/label'; 8 | import { Input } from '@/components/ui/input'; 9 | import { 10 | Tooltip, 11 | TooltipContent, 12 | TooltipProvider, 13 | TooltipTrigger, 14 | } from '@/components/ui/tooltip'; 15 | 16 | export const SidebarSpeed = memo( 17 | ({ manager }: { manager: Manager }) => { 18 | const { t } = useTranslation(); 19 | 20 | return ( 21 |
22 | 36 | { 42 | manager.setSpeed(Number(e.target.value)); 43 | })} 44 | /> 45 |
46 | ); 47 | }, 48 | ); 49 | -------------------------------------------------------------------------------- /demo/src/components/sidebar/SidebarStartAndStop.tsx: -------------------------------------------------------------------------------- 1 | import { memo, useState, useEffect } from 'react'; 2 | import { Bird } from 'lucide-react'; 3 | import { useTranslation } from 'react-i18next'; 4 | import type { Manager } from 'danmu'; 5 | import type { DanmakuValue } from '@/types'; 6 | import { Label } from '@/components/ui/label'; 7 | import { Switch } from '@/components/ui/switch'; 8 | 9 | export const SidebarStartAndStop = memo( 10 | ({ manager }: { manager: Manager }) => { 11 | const { t } = useTranslation(); 12 | const [checked, setChecked] = useState(manager.isPlaying()); 13 | 14 | useEffect(() => { 15 | manager.use({ 16 | stop: () => setChecked(false), 17 | start: () => setChecked(true), 18 | }); 19 | }, [manager]); 20 | 21 | return ( 22 |
23 | 30 | 34 | v ? manager.startPlaying() : manager.stopPlaying() 35 | } 36 | /> 37 |
38 | ); 39 | }, 40 | ); 41 | -------------------------------------------------------------------------------- /demo/src/components/sidebar/index.tsx: -------------------------------------------------------------------------------- 1 | import type { Manager } from 'danmu'; 2 | import type { DanmakuValue } from '@/types'; 3 | import { SidebarGap } from '@/components/sidebar/SidebarGap'; 4 | import { SidebarRate } from '@/components/sidebar/SidebarRate'; 5 | import { SidebarSpeed } from '@/components/sidebar/SidebarSpeed'; 6 | import { SidebarAreaX } from '@/components/sidebar/SidebarAreaX'; 7 | import { SidebarAreaY } from '@/components/sidebar/SidebarAreaY'; 8 | import { SidebarFreeze } from '@/components/sidebar/SidebarFreeze'; 9 | import { SidebarOpacity } from '@/components/sidebar/SidebarOpacity'; 10 | import { SidebarNumbers } from '@/components/sidebar/SidebarNumbers'; 11 | import { SidebarDirection } from '@/components/sidebar/SidebarDirection'; 12 | import { SidebarFrequency } from '@/components/sidebar/SidebarFrequency'; 13 | import { SidebarOcclusion } from '@/components/sidebar/SidebarOcclusion'; 14 | import { SidebarModeSelect } from '@/components/sidebar/SidebarModeSelect'; 15 | import { SidebarShowAndHide } from '@/components/sidebar/SidebarShowAndHide'; 16 | import { SidebarMoveDuration } from '@/components/sidebar/SidebarMoveDuration'; 17 | import { SidebarStartAndStop } from '@/components/sidebar/SidebarStartAndStop'; 18 | 19 | export const Sidebar = ({ manager }: { manager: Manager }) => { 20 | return ( 21 | <> 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | ); 39 | }; 40 | -------------------------------------------------------------------------------- /demo/src/components/ui/avatar.tsx: -------------------------------------------------------------------------------- 1 | 'use client'; 2 | 3 | import * as React from 'react'; 4 | import * as AvatarPrimitive from '@radix-ui/react-avatar'; 5 | 6 | import { cn } from '@/lib/utils'; 7 | 8 | const Avatar = React.forwardRef< 9 | React.ElementRef, 10 | React.ComponentPropsWithoutRef 11 | >(({ className, ...props }, ref) => ( 12 | 20 | )); 21 | Avatar.displayName = AvatarPrimitive.Root.displayName; 22 | 23 | const AvatarImage = React.forwardRef< 24 | React.ElementRef, 25 | React.ComponentPropsWithoutRef 26 | >(({ className, ...props }, ref) => ( 27 | 32 | )); 33 | AvatarImage.displayName = AvatarPrimitive.Image.displayName; 34 | 35 | const AvatarFallback = React.forwardRef< 36 | React.ElementRef, 37 | React.ComponentPropsWithoutRef 38 | >(({ className, ...props }, ref) => ( 39 | 47 | )); 48 | AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName; 49 | 50 | export { Avatar, AvatarImage, AvatarFallback }; 51 | -------------------------------------------------------------------------------- /demo/src/components/ui/badge.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import { cva, type VariantProps } from 'class-variance-authority'; 3 | 4 | import { cn } from '@/lib/utils'; 5 | 6 | const badgeVariants = cva( 7 | 'inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2', 8 | { 9 | variants: { 10 | variant: { 11 | default: 12 | 'border-transparent bg-primary text-primary-foreground hover:bg-primary/80', 13 | secondary: 14 | 'border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80', 15 | destructive: 16 | 'border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80', 17 | outline: 'text-foreground', 18 | }, 19 | }, 20 | defaultVariants: { 21 | variant: 'default', 22 | }, 23 | }, 24 | ); 25 | 26 | export interface BadgeProps 27 | extends React.HTMLAttributes, 28 | VariantProps {} 29 | 30 | function Badge({ className, variant, ...props }: BadgeProps) { 31 | return ( 32 |
33 | ); 34 | } 35 | 36 | export { Badge, badgeVariants }; 37 | -------------------------------------------------------------------------------- /demo/src/components/ui/button.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import { Slot } from '@radix-ui/react-slot'; 3 | import { cva, type VariantProps } from 'class-variance-authority'; 4 | 5 | import { cn } from '@/lib/utils'; 6 | 7 | const buttonVariants = cva( 8 | 'inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50', 9 | { 10 | variants: { 11 | variant: { 12 | default: 'bg-primary text-primary-foreground hover:bg-primary/90', 13 | destructive: 14 | 'bg-destructive text-destructive-foreground hover:bg-destructive/90', 15 | outline: 16 | 'border border-input bg-background hover:bg-accent hover:text-accent-foreground', 17 | secondary: 18 | 'bg-secondary text-secondary-foreground hover:bg-secondary/80', 19 | ghost: 'hover:bg-accent hover:text-accent-foreground', 20 | link: 'text-primary underline-offset-4 hover:underline', 21 | }, 22 | size: { 23 | default: 'h-10 px-4 py-2', 24 | sm: 'h-9 rounded-md px-3', 25 | lg: 'h-11 rounded-md px-8', 26 | icon: 'h-10 w-10', 27 | }, 28 | }, 29 | defaultVariants: { 30 | variant: 'default', 31 | size: 'default', 32 | }, 33 | }, 34 | ); 35 | 36 | export interface ButtonProps 37 | extends React.ButtonHTMLAttributes, 38 | VariantProps { 39 | asChild?: boolean; 40 | } 41 | 42 | const Button = React.forwardRef( 43 | ({ className, variant, size, asChild = false, ...props }, ref) => { 44 | const Comp = asChild ? Slot : 'button'; 45 | return ( 46 | 51 | ); 52 | }, 53 | ); 54 | Button.displayName = 'Button'; 55 | 56 | export { Button, buttonVariants }; 57 | -------------------------------------------------------------------------------- /demo/src/components/ui/input.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | 3 | import { cn } from '@/lib/utils'; 4 | 5 | export interface InputProps 6 | extends React.InputHTMLAttributes {} 7 | 8 | const Input = React.forwardRef( 9 | ({ className, type, ...props }, ref) => { 10 | return ( 11 | 20 | ); 21 | }, 22 | ); 23 | Input.displayName = 'Input'; 24 | 25 | export { Input }; 26 | -------------------------------------------------------------------------------- /demo/src/components/ui/label.tsx: -------------------------------------------------------------------------------- 1 | 'use client'; 2 | 3 | import * as React from 'react'; 4 | import * as LabelPrimitive from '@radix-ui/react-label'; 5 | import { cva, type VariantProps } from 'class-variance-authority'; 6 | 7 | import { cn } from '@/lib/utils'; 8 | 9 | const labelVariants = cva( 10 | 'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70', 11 | ); 12 | 13 | const Label = React.forwardRef< 14 | React.ElementRef, 15 | React.ComponentPropsWithoutRef & 16 | VariantProps 17 | >(({ className, ...props }, ref) => ( 18 | 23 | )); 24 | Label.displayName = LabelPrimitive.Root.displayName; 25 | 26 | export { Label }; 27 | -------------------------------------------------------------------------------- /demo/src/components/ui/popover.tsx: -------------------------------------------------------------------------------- 1 | 'use client'; 2 | 3 | import * as React from 'react'; 4 | import * as PopoverPrimitive from '@radix-ui/react-popover'; 5 | 6 | import { cn } from '@/lib/utils'; 7 | 8 | const Popover = PopoverPrimitive.Root; 9 | 10 | const PopoverTrigger = PopoverPrimitive.Trigger; 11 | 12 | const PopoverContent = React.forwardRef< 13 | React.ElementRef, 14 | React.ComponentPropsWithoutRef 15 | >(({ className, align = 'center', sideOffset = 4, ...props }, ref) => ( 16 | 17 | 27 | 28 | )); 29 | PopoverContent.displayName = PopoverPrimitive.Content.displayName; 30 | 31 | export { Popover, PopoverTrigger, PopoverContent }; 32 | -------------------------------------------------------------------------------- /demo/src/components/ui/sheet.tsx: -------------------------------------------------------------------------------- 1 | 'use client'; 2 | 3 | import * as React from 'react'; 4 | import * as SheetPrimitive from '@radix-ui/react-dialog'; 5 | import { cva, type VariantProps } from 'class-variance-authority'; 6 | import { X } from 'lucide-react'; 7 | 8 | import { cn } from '@/lib/utils'; 9 | 10 | const Sheet = SheetPrimitive.Root; 11 | 12 | const SheetTrigger = SheetPrimitive.Trigger; 13 | 14 | const SheetClose = SheetPrimitive.Close; 15 | 16 | const SheetPortal = SheetPrimitive.Portal; 17 | 18 | const SheetOverlay = React.forwardRef< 19 | React.ElementRef, 20 | React.ComponentPropsWithoutRef 21 | >(({ className, ...props }, ref) => ( 22 | 30 | )); 31 | SheetOverlay.displayName = SheetPrimitive.Overlay.displayName; 32 | 33 | const sheetVariants = cva( 34 | 'fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500', 35 | { 36 | variants: { 37 | side: { 38 | top: 'inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top', 39 | bottom: 40 | 'inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom', 41 | left: 'inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm', 42 | right: 43 | 'inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm', 44 | }, 45 | }, 46 | defaultVariants: { 47 | side: 'right', 48 | }, 49 | }, 50 | ); 51 | 52 | interface SheetContentProps 53 | extends React.ComponentPropsWithoutRef, 54 | VariantProps {} 55 | 56 | const SheetContent = React.forwardRef< 57 | React.ElementRef, 58 | SheetContentProps 59 | >(({ side = 'right', className, children, ...props }, ref) => ( 60 | 61 | 62 | 67 | {children} 68 | 69 | 70 | Close 71 | 72 | 73 | 74 | )); 75 | SheetContent.displayName = SheetPrimitive.Content.displayName; 76 | 77 | const SheetHeader = ({ 78 | className, 79 | ...props 80 | }: React.HTMLAttributes) => ( 81 |
88 | ); 89 | SheetHeader.displayName = 'SheetHeader'; 90 | 91 | const SheetFooter = ({ 92 | className, 93 | ...props 94 | }: React.HTMLAttributes) => ( 95 |
102 | ); 103 | SheetFooter.displayName = 'SheetFooter'; 104 | 105 | const SheetTitle = React.forwardRef< 106 | React.ElementRef, 107 | React.ComponentPropsWithoutRef 108 | >(({ className, ...props }, ref) => ( 109 | 114 | )); 115 | SheetTitle.displayName = SheetPrimitive.Title.displayName; 116 | 117 | const SheetDescription = React.forwardRef< 118 | React.ElementRef, 119 | React.ComponentPropsWithoutRef 120 | >(({ className, ...props }, ref) => ( 121 | 126 | )); 127 | SheetDescription.displayName = SheetPrimitive.Description.displayName; 128 | 129 | export { 130 | Sheet, 131 | SheetPortal, 132 | SheetOverlay, 133 | SheetTrigger, 134 | SheetClose, 135 | SheetContent, 136 | SheetHeader, 137 | SheetFooter, 138 | SheetTitle, 139 | SheetDescription, 140 | }; 141 | -------------------------------------------------------------------------------- /demo/src/components/ui/slider.tsx: -------------------------------------------------------------------------------- 1 | 'use client'; 2 | 3 | import * as React from 'react'; 4 | import * as SliderPrimitive from '@radix-ui/react-slider'; 5 | 6 | import { cn } from '@/lib/utils'; 7 | 8 | const Slider = React.forwardRef< 9 | React.ElementRef, 10 | React.ComponentPropsWithoutRef 11 | >(({ className, ...props }, ref) => ( 12 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | )); 27 | Slider.displayName = SliderPrimitive.Root.displayName; 28 | 29 | export { Slider }; 30 | -------------------------------------------------------------------------------- /demo/src/components/ui/switch.tsx: -------------------------------------------------------------------------------- 1 | 'use client'; 2 | 3 | import * as React from 'react'; 4 | import * as SwitchPrimitives from '@radix-ui/react-switch'; 5 | 6 | import { cn } from '@/lib/utils'; 7 | 8 | const Switch = React.forwardRef< 9 | React.ElementRef, 10 | React.ComponentPropsWithoutRef 11 | >(({ className, ...props }, ref) => ( 12 | 20 | 25 | 26 | )); 27 | Switch.displayName = SwitchPrimitives.Root.displayName; 28 | 29 | export { Switch }; 30 | -------------------------------------------------------------------------------- /demo/src/components/ui/tabs.tsx: -------------------------------------------------------------------------------- 1 | 'use client'; 2 | 3 | import * as React from 'react'; 4 | import * as TabsPrimitive from '@radix-ui/react-tabs'; 5 | 6 | import { cn } from '@/lib/utils'; 7 | 8 | const Tabs = TabsPrimitive.Root; 9 | 10 | const TabsList = React.forwardRef< 11 | React.ElementRef, 12 | React.ComponentPropsWithoutRef 13 | >(({ className, ...props }, ref) => ( 14 | 22 | )); 23 | TabsList.displayName = TabsPrimitive.List.displayName; 24 | 25 | const TabsTrigger = React.forwardRef< 26 | React.ElementRef, 27 | React.ComponentPropsWithoutRef 28 | >(({ className, ...props }, ref) => ( 29 | 37 | )); 38 | TabsTrigger.displayName = TabsPrimitive.Trigger.displayName; 39 | 40 | const TabsContent = React.forwardRef< 41 | React.ElementRef, 42 | React.ComponentPropsWithoutRef 43 | >(({ className, ...props }, ref) => ( 44 | 52 | )); 53 | TabsContent.displayName = TabsPrimitive.Content.displayName; 54 | 55 | export { Tabs, TabsList, TabsTrigger, TabsContent }; 56 | -------------------------------------------------------------------------------- /demo/src/components/ui/textarea.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | 3 | import { cn } from '@/lib/utils'; 4 | 5 | export interface TextareaProps 6 | extends React.TextareaHTMLAttributes {} 7 | 8 | const Textarea = React.forwardRef( 9 | ({ className, ...props }, ref) => { 10 | return ( 11 |