Skip to content
This repository has been archived by the owner on Feb 13, 2025. It is now read-only.

Banner "glitches" on callback #10

Open
Schlomoh opened this issue Jul 8, 2024 · 4 comments
Open

Banner "glitches" on callback #10

Schlomoh opened this issue Jul 8, 2024 · 4 comments

Comments

@Schlomoh
Copy link
Owner

Schlomoh commented Jul 8, 2024

          done @Schlomoh 

Also, when using the component, whenever I hit refresh, the cookie banner comes and goes swifty (as if it glitches). Maybe you can improve it so that after accepting or rejecting, it does not load and show glitches.

Originally posted by @zriyansh in #9 (comment)

@Schlomoh
Copy link
Owner Author

Schlomoh commented Jul 8, 2024

@zriyansh, please provide some more information about your setup and implementation. Best to provide a reproducible example.

@zriyansh
Copy link
Contributor

zriyansh commented Jul 8, 2024

Steps to reporduce
I am using this blog template for my website - https://github.com/timlrx/tailwind-nextjs-starter-blog

Just use the compone that I requested you to add in the app/layout.tsx file.

     ... 
        <ThemeProviders>
          <Analytics analyticsConfig={siteMetadata.analytics as AnalyticsConfig} />
          <SectionContainer>
            <div className="flex h-screen flex-col justify-between font-sans">
              <SearchProvider>
                <Header />               
                <main className="mb-auto">{children}</main>
              </SearchProvider>
              <Footer />
              
            </div>
          </SectionContainer>
        </ThemeProviders>
        <CookieBanner />
      </body>
      {/* <script>
        <InjectCSS/>
      </script> */}
    </html>
  )
}

system:

  1. macOS 13.6.5 M1
  2. browser - chrome

sometimes the component load like this before it fully renders.
Screenshot 2024-07-08 at 4 52 32 PM

Full render example:

Screenshot 2024-07-08 at 4 53 32 PM

@Schlomoh

@zriyansh
Copy link
Contributor

zriyansh commented Jul 8, 2024

this is my component

'use client';

import { CookieBanner } from '@schlomoh/react-cookieconsent';
import React from 'react';
import Link from './Link'

const MyCookieBanner = () => {
    const Content = () => (
        <>
            <h3 className='text-sm'>Life is better with cookies 🍪</h3>
            <p className='text-xs'>This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt out if you wish. <Link href="/cookie" className='text-blue underline'>Cookie Policy</Link></p>
        </>
    )

    const MContent = () => (
        <>
            <h3 className='text-sm'>Manage your cookie settings.</h3>
            <p className='text-xs'>We use cookies and other tracking technologies to improve your experience on our website. We may store and/or access information on a device</p>
        </>
    )
    
    const containerStyle = {backgroundColor: 'white'};
    const buttonStyle = {borderRadius: 10}
    const primaryButtonStyle={...buttonStyle, backgroundColor:'green', fontSize: '12px', padding: '0px' }
    const secondaryButtonStyle={...buttonStyle, backgroundColor:'red', fontSize: '12px', padding: '5px' }
    
  return (
    <CookieBanner
        acceptButtonText='Accept'
        declineButtonText='Reject'
        headingColor='black'
        paragraphColor='grey'
        containerStyle={containerStyle}
        primaryButtonStyle={primaryButtonStyle}
        secondaryButtonStyle={secondaryButtonStyle}
        infoContent={<Content />}
        enableManagement
        managementContent={<MContent />}
        managementButtonText='Preferences'
        cookieCategories={['Analytics', 'Advertisement']}
        // accentColor = 'coral'
    />
  );
};

export default MyCookieBanner;
 

@zriyansh
Copy link
Contributor

zriyansh commented Jul 8, 2024

Screen.Recording.2024-07-08.at.4.57.41.PM.mov

video of the glitch @Schlomoh

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants