@@ -46,10 +46,10 @@ export default function PlanDetailsClient({
46
46
if ( ! element ) throw new Error ( 'Plan element not found' ) ;
47
47
48
48
const backgroundColor = resolvedTheme === 'dark' ? '#0a0a0a' : '#ffffff' ;
49
- const logoSrc =
50
- resolvedTheme === 'dark'
51
- ? '/media/official-logos/light-logo.png'
52
- : '/media/official-logos/dark-logo.png' ;
49
+ // const logoSrc =
50
+ // resolvedTheme === 'dark'
51
+ // ? '/media/official-logos/light-logo.png'
52
+ // : '/media/official-logos/dark-logo.png';
53
53
54
54
try {
55
55
const canvas = await html2canvas ( element , {
@@ -68,63 +68,63 @@ export default function PlanDetailsClient({
68
68
} ,
69
69
} ) ;
70
70
71
- const ctx = canvas . getContext ( '2d' ) ;
72
- const logo = new window . Image ( ) ;
73
- logo . crossOrigin = 'anonymous' ;
74
- logo . src = logoSrc ;
75
- logo . onload = ( ) => {
76
- if ( ctx ) {
77
- const logoWidth = 60 ;
78
- const logoHeight = 60 ;
79
- const logoPosition :
80
- | 'center'
81
- | 'top-left'
82
- | 'top-right'
83
- | 'bottom-left'
84
- | 'bottom-right' = 'bottom-right' ;
85
- const margin = 32 ;
86
- let x = 0 ;
87
- let y = 0 ;
88
- switch ( logoPosition ) {
89
- case 'center' :
90
- x = ( canvas . width - logoWidth ) / 2 ;
91
- y = ( canvas . height - logoHeight ) / 2 ;
92
- break ;
93
- case 'top-left' :
94
- x = margin ;
95
- y = margin ;
96
- break ;
97
- case 'top-right' :
98
- x = canvas . width - logoWidth - margin ;
99
- y = margin ;
100
- break ;
101
- case 'bottom-left' :
102
- x = margin ;
103
- y = canvas . height - logoHeight - margin ;
104
- break ;
105
- case 'bottom-right' :
106
- x = canvas . width - logoWidth - margin ;
107
- y = canvas . height - logoHeight - margin ;
108
- break ;
109
- default :
110
- x = ( canvas . width - logoWidth ) / 2 ;
111
- y = ( canvas . height - logoHeight ) / 2 ;
112
- }
113
- ctx . drawImage ( logo , x , y , logoWidth , logoHeight ) ;
114
- }
115
- const link = document . createElement ( 'a' ) ;
116
- link . download = `plan-${ plan . id } .png` ;
117
- link . href = canvas . toDataURL ( 'image/png' , 2.0 ) ;
118
- link . click ( ) ;
119
- } ;
120
- logo . onerror = ( e ) => {
121
- console . error ( 'Logo failed to load:' , logoSrc , e ) ;
122
- alert ( 'Logo failed to load! Check the path and file type.' ) ;
123
- const link = document . createElement ( 'a' ) ;
124
- link . download = `plan-${ plan . id } .png` ;
125
- link . href = canvas . toDataURL ( 'image/png' , 2.0 ) ;
126
- link . click ( ) ;
127
- } ;
71
+ // const ctx = canvas.getContext('2d');
72
+ // const logo = new window.Image();
73
+ // logo.crossOrigin = 'anonymous';
74
+ // logo.src = logoSrc;
75
+ // logo.onload = () => {
76
+ // if (ctx) {
77
+ // const logoWidth = 60;
78
+ // const logoHeight = 60;
79
+ // const logoPosition:
80
+ // | 'center'
81
+ // | 'top-left'
82
+ // | 'top-right'
83
+ // | 'bottom-left'
84
+ // | 'bottom-right' = 'bottom-right';
85
+ // const margin = 32;
86
+ // let x = 0;
87
+ // let y = 0;
88
+ // switch (logoPosition) {
89
+ // case 'center':
90
+ // x = (canvas.width - logoWidth) / 2;
91
+ // y = (canvas.height - logoHeight) / 2;
92
+ // break;
93
+ // case 'top-left':
94
+ // x = margin;
95
+ // y = margin;
96
+ // break;
97
+ // case 'top-right':
98
+ // x = canvas.width - logoWidth - margin;
99
+ // y = margin;
100
+ // break;
101
+ // case 'bottom-left':
102
+ // x = margin;
103
+ // y = canvas.height - logoHeight - margin;
104
+ // break;
105
+ // case 'bottom-right':
106
+ // x = canvas.width - logoWidth - margin;
107
+ // y = canvas.height - logoHeight - margin;
108
+ // break;
109
+ // default:
110
+ // x = (canvas.width - logoWidth) / 2;
111
+ // y = (canvas.height - logoHeight) / 2;
112
+ // }
113
+ // ctx.drawImage(logo, x, y, logoWidth, logoHeight);
114
+ // }
115
+ const link = document . createElement ( 'a' ) ;
116
+ link . download = `plan-${ plan . id } .png` ;
117
+ link . href = canvas . toDataURL ( 'image/png' , 2.0 ) ;
118
+ link . click ( ) ;
119
+
120
+ // logo.onerror = (e) => {
121
+ // console.error('Logo failed to load:', logoSrc, e);
122
+ // alert('Logo failed to load! Check the path and file type.');
123
+ // const link = document.createElement('a');
124
+ // link.download = `plan-${plan.id}.png`;
125
+ // link.href = canvas.toDataURL('image/png', 2.0);
126
+ // link.click();
127
+ // };
128
128
} catch ( error ) {
129
129
console . error ( 'Error generating PNG:' , error ) ;
130
130
throw error ;
0 commit comments