@@ -2,6 +2,7 @@ import { Preset } from "lib/public/interface";
22import { FC } from "react" ;
33import { QRCodeCanvas } from "qrcode.react" ;
44import { encodeChain } from "lib/core/encoder" ;
5+ import ChainEditor from "./chain/ChainEditor" ;
56
67interface PresetDetailsProps {
78 preset : Preset ;
@@ -55,19 +56,38 @@ export const PresetDetails: FC<PresetDetailsProps> = ({ preset }) => {
5556 < div className = "mt-8" >
5657 < button
5758 onClick = { ( ) => {
58- const element = document . createElement ( "a" ) ;
59- const file = new Blob ( [ qrCode . qrCode ] , { type : "text/plain" } ) ;
60- element . href = URL . createObjectURL ( file ) ;
61- element . download = `${ preset . origin . artist } - ${ preset . origin . song } .txt` ;
62- document . body . appendChild ( element ) ;
63- element . click ( ) ;
64- document . body . removeChild ( element ) ;
59+ const canvas = document . querySelector ( "canvas" ) ;
60+ if ( ! canvas ) return ;
61+
62+ canvas . toBlob ( ( blob ) => {
63+ if ( ! blob ) return ;
64+
65+ const element = document . createElement ( "a" ) ;
66+ element . href = URL . createObjectURL ( blob ) ;
67+ element . download = `${ preset . origin . artist } - ${ preset . origin . song } ${ preset . origin . part } .png` ;
68+ document . body . appendChild ( element ) ;
69+ element . click ( ) ;
70+ document . body . removeChild ( element ) ;
71+ } , "image/png" ) ;
6572 } }
6673 className = "bg-pink-600 hover:bg-pink-700 text-white font-bold py-2 px-4 rounded transition-colors"
6774 >
6875 Download «{ preset . origin . song } { preset . origin . part } » patch file
6976 </ button >
7077 </ div >
78+
79+ { /* <div className="mt-8">
80+ <h2 className="text-2xl font-semibold mb-4 text-left">
81+ Chain Configuration
82+ </h2>
83+ <div className="bg-white/10 backdrop-blur-sm rounded-lg p-6 border border-white/20">
84+ <ChainEditor
85+ chain={preset.chain}
86+ onChange={() => {}}
87+ readonly={true}
88+ />
89+ </div>
90+ </div> */ }
7191 </ div >
7292
7393 < div className = "w-[300px] shrink-0" >
0 commit comments