-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
587bd8f
commit 0e9d454
Showing
7 changed files
with
219 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { Label } from "@/components/ui/label"; | ||
import { Slider } from "@/components/ui/slider"; | ||
import { Knob, Pointer, Scale, Arc, Value } from "rc-knob"; | ||
import { useState } from "react"; | ||
|
||
export default function AudioMixer({ name }: { name: string }) { | ||
const defaultValue = [50]; | ||
const [value, setValue] = useState(defaultValue); | ||
const htmlName = name.toLowerCase().replace(" ", "_"); | ||
|
||
return ( | ||
<div className="flex h-full w-max flex-col-reverse items-center justify-center"> | ||
<Label htmlFor={htmlName} className="mt-4"> | ||
{name} | ||
</Label> | ||
{/* <Knob | ||
size={100} | ||
angleOffset={220} | ||
angleRange={280} | ||
steps={10} | ||
snap={true} | ||
min={0} | ||
max={100} | ||
// onChange={(value) => console.log(value)} | ||
> | ||
<Arc arcWidth={5} color="#FC5A96" radius={47.5} /> | ||
<Pointer width={5} radius={40} type="circle" color="#FC5A96" /> | ||
<Value marginBottom={40} className="value" /> | ||
</Knob> */} | ||
<p className="w-14 text-center text-card-foreground">{value}</p> | ||
<Slider | ||
name={htmlName} | ||
min={0} | ||
max={100} | ||
value={value} | ||
defaultValue={defaultValue} | ||
onValueChange={(val) => setValue(val)} | ||
orientation="vertical" | ||
/> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"use client"; | ||
import React from "react"; | ||
import { createPortal } from "react-dom"; | ||
import { Knob, Pointer, Scale, Arc, Value } from "rc-knob"; | ||
|
||
interface KnobPortalProps { | ||
value: number; | ||
onChange: (value: number) => void; | ||
} | ||
|
||
const KnobPortal: React.FC<KnobPortalProps> = ({ value, onChange }) => { | ||
return createPortal( | ||
<Knob | ||
size={100} | ||
angleOffset={220} | ||
angleRange={280} | ||
steps={10} | ||
snap={true} | ||
min={0} | ||
max={100} | ||
value={value} | ||
onChange={onChange} | ||
ariaLabelledBy="knob-label" | ||
ariaValueText={`Value: ${value}`} | ||
> | ||
<Arc arcWidth={5} color="#FC5A96" radius={47.5} /> | ||
<Pointer width={5} radius={40} type="circle" color="#FC5A96" /> | ||
<Value marginBottom={40} className="value" /> | ||
</Knob>, | ||
document.body, // Render the Knob at the end of the body | ||
); | ||
}; | ||
|
||
export default KnobPortal; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// rc-knob.d.ts | ||
declare module "rc-knob" { | ||
import { ReactNode, FC } from "react"; | ||
|
||
interface KnobProps { | ||
min?: number; | ||
max?: number; | ||
value?: number; | ||
angleOffset?: number; | ||
angleRange?: number; | ||
size?: number; | ||
steps?: number; | ||
snap?: boolean; | ||
ariaValueText?: string; | ||
ariaLabelledBy?: string; | ||
onChange?: (value: number) => void; | ||
className?: string; | ||
children?: ReactNode; | ||
} | ||
|
||
interface PointerProps { | ||
width?: number; | ||
height?: number; | ||
angleOffset?: number; | ||
angleRange?: number; | ||
percentage?: number; | ||
radius?: number; | ||
center?: number; | ||
type?: "rect" | "circle"; | ||
color?: string; | ||
className?: string; | ||
} | ||
|
||
interface ScaleProps { | ||
angleRange?: number; | ||
steps?: number; | ||
type?: "rect" | "circle"; | ||
radius?: number; | ||
tickWidth?: number; | ||
tickHeight?: number; | ||
angleOffset?: number; | ||
center?: number; | ||
color?: string; | ||
activeColor?: string; | ||
className?: string; | ||
activeClassName?: string; | ||
fn?: (props: any) => ReactNode; | ||
percentage?: number; | ||
} | ||
|
||
interface ArcProps { | ||
color?: string; | ||
background?: string; | ||
percentage?: number; | ||
angleOffset?: number; | ||
angleRange?: number; | ||
radius?: number; | ||
arcWidth?: number; | ||
center?: number; | ||
} | ||
|
||
interface ValueProps { | ||
value?: number; | ||
size?: number; | ||
decimalPlace?: number; | ||
className?: string; | ||
marginBottom?: number; | ||
} | ||
|
||
export const Knob: FC<KnobProps>; | ||
export const Pointer: FC<PointerProps>; | ||
export const Scale: FC<ScaleProps>; | ||
export const Arc: FC<ArcProps>; | ||
export const Value: FC<ValueProps>; | ||
} |