@@ -154,13 +154,46 @@ class FriendshipGreetingApp {
154154 const actionButtons = document . querySelector ( '.action-buttons' ) ;
155155 const createOwnBtn = document . createElement ( 'button' ) ;
156156 createOwnBtn . id = 'createOwnBtn' ;
157- createOwnBtn . className = 'action-btn' ;
158- createOwnBtn . innerHTML = '<i class="fas fa-plus"></i> Create Your Own' ;
159- createOwnBtn . style . background = '#667eea' ;
160- createOwnBtn . style . color = 'white' ;
161- createOwnBtn . style . border = '2px solid #667eea' ;
157+ createOwnBtn . className = 'create-own-btn' ;
158+ createOwnBtn . innerHTML = '<i class="fas fa-magic"></i> Create Your Own Greeting' ;
159+
160+ // Enhanced styling for full width and animations
161+ createOwnBtn . style . cssText = `
162+ width: 100%;
163+ padding: 18px 24px;
164+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
165+ color: white;
166+ border: none;
167+ border-radius: 15px;
168+ font-size: 18px;
169+ font-weight: 600;
170+ cursor: pointer;
171+ transition: all 0.3s ease;
172+ box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
173+ animation: pulseGlow 2s infinite;
174+ margin-top: 20px;
175+ position: relative;
176+ overflow: hidden;
177+ ` ;
178+
179+ // Add hover effects
180+ createOwnBtn . addEventListener ( 'mouseenter' , ( ) => {
181+ createOwnBtn . style . transform = 'translateY(-3px) scale(1.02)' ;
182+ createOwnBtn . style . boxShadow = '0 12px 35px rgba(102, 126, 234, 0.4)' ;
183+ } ) ;
184+
185+ createOwnBtn . addEventListener ( 'mouseleave' , ( ) => {
186+ createOwnBtn . style . transform = 'translateY(0) scale(1)' ;
187+ createOwnBtn . style . boxShadow = '0 8px 25px rgba(102, 126, 234, 0.3)' ;
188+ } ) ;
162189
163190 createOwnBtn . addEventListener ( 'click' , ( ) => {
191+ // Add click animation
192+ createOwnBtn . style . transform = 'scale(0.98)' ;
193+ setTimeout ( ( ) => {
194+ createOwnBtn . style . transform = 'scale(1)' ;
195+ } , 150 ) ;
196+
164197 // Remove the greeting parameter from URL and reload
165198 const url = new URL ( window . location ) ;
166199 url . searchParams . delete ( 'greeting' ) ;
@@ -686,9 +719,14 @@ class FriendshipGreetingApp {
686719
687720 async uploadToImgBB ( file ) {
688721 const apiKey = '0ee3a371cdad624b9a1bacb8dc3c1696' ;
722+
723+ // Compress image if it's too large to maintain quality
724+ const compressedFile = await this . compressImage ( file ) ;
725+
689726 const formData = new FormData ( ) ;
690727 formData . append ( 'key' , apiKey ) ;
691- formData . append ( 'image' , file ) ;
728+ formData . append ( 'image' , compressedFile ) ;
729+ formData . append ( 'expiration' , '15552000' ) ; // 6 months in seconds
692730
693731 const response = await fetch ( 'https://api.imgbb.com/1/upload' , {
694732 method : 'POST' ,
@@ -706,6 +744,37 @@ class FriendshipGreetingApp {
706744 throw new Error ( 'ImgBB upload failed' ) ;
707745 }
708746 }
747+
748+ async compressImage ( file , maxWidth = 1920 , maxHeight = 1080 , quality = 0.9 ) {
749+ return new Promise ( ( resolve ) => {
750+ const canvas = document . createElement ( 'canvas' ) ;
751+ const ctx = canvas . getContext ( '2d' ) ;
752+ const img = new Image ( ) ;
753+
754+ img . onload = ( ) => {
755+ // Calculate new dimensions while maintaining aspect ratio
756+ let { width, height } = img ;
757+
758+ if ( width > maxWidth || height > maxHeight ) {
759+ const ratio = Math . min ( maxWidth / width , maxHeight / height ) ;
760+ width *= ratio ;
761+ height *= ratio ;
762+ }
763+
764+ canvas . width = width ;
765+ canvas . height = height ;
766+
767+ // Draw and compress
768+ ctx . drawImage ( img , 0 , 0 , width , height ) ;
769+
770+ canvas . toBlob ( ( blob ) => {
771+ resolve ( blob ) ;
772+ } , 'image/jpeg' , quality ) ;
773+ } ;
774+
775+ img . src = URL . createObjectURL ( file ) ;
776+ } ) ;
777+ }
709778}
710779
711780// Initialize the app when DOM is loaded
0 commit comments