Skip to content

casjay-templates/cookieconsent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Extended Cookie Consent

Build Status License: MIT GitHub Pages

An enhanced, GDPR-compliant cookie consent library with granular controls, modern UI, and comprehensive compliance features. Built as an extension of the popular Osano Cookie Consent library.

πŸš€ Features

  • πŸͺ Granular Cookie Controls - Let users choose specific cookie categories
  • ⚑ Modern UI/UX - Beautiful, responsive design with smooth animations
  • πŸ”’ GDPR Compliant - Built-in compliance with GDPR, CCPA, and other privacy laws
  • πŸ“Š Analytics Integration - Seamless integration with Google Analytics, GTM
  • 🎨 21+ Beautiful Themes - Including Dracula, GitHub, Material, VS Code, and more
  • πŸ“ 10 Position Options - From corner popups to full-width bars and center modals
  • πŸ“± Mobile Optimized - Perfect responsive design for all devices
  • πŸŒ™ Dark Mode Support - Automatic dark/light theme detection plus custom dark themes
  • β™Ώ Accessibility - Full keyboard navigation and screen reader support
  • πŸ” Audit Trail - Optional consent recording for compliance

πŸ“¦ Installation

CDN (Recommended)

<!-- CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/casjay-templates/cookieconsent@main/dist/cookieconsent.min.css">

<!-- JavaScript -->
<script src="https://cdn.jsdelivr.net/gh/casjay-templates/cookieconsent@main/dist/cookieconsent.min.js"></script>

GitHub Raw

<!-- CSS -->
<link rel="stylesheet" href="https://raw.githubusercontent.com/casjay-templates/cookieconsent/main/dist/cookieconsent.min.css">

<!-- JavaScript -->
<script src="https://raw.githubusercontent.com/casjay-templates/cookieconsent/main/dist/cookieconsent.min.js"></script>

npm

npm install @casjay-templates/cookieconsent

πŸš€ Quick Start

Basic Usage

// Initialize with default settings
cookieconsent.extended.init({
  content: {
    header: 'We use cookies',
    message: 'This website uses cookies to enhance your experience.',
    acceptAll: 'Accept All',
    rejectAll: 'Reject All'
  }
});

Advanced Configuration with Themes

cookieconsent.extended.init({
  ui: {
    position: 'center-modal',
    theme: 'dracula',
    showPreferences: true,
    animationType: 'bounce',
    backdrop: true
  },
  
  categories: {
    necessary: {
      enabled: true,
      locked: true,
      name: 'Essential Cookies',
      description: 'Required for basic website functionality'
    },
    analytics: {
      enabled: false,
      locked: false,
      name: 'Analytics Cookies',
      description: 'Help us understand how visitors use our website'
    },
    marketing: {
      enabled: false,
      locked: false,
      name: 'Marketing Cookies',
      description: 'Used to deliver personalized advertisements'
    }
  },
  
  analytics: {
    enabled: true,
    gtag: true
  },
  
  callbacks: {
    onAcceptAll: function(categories) {
      // Initialize all tracking
      gtag('config', 'GA_MEASUREMENT_ID');
    },
    
    onCategoryToggle: function(category, enabled) {
      console.log(\`\${category} cookies \${enabled ? 'enabled' : 'disabled'}\`);
    }
  }
});

Theme and Position Examples

// Dracula theme with center modal
cookieconsent.extended.init({
  ui: { theme: 'dracula', position: 'center-modal' }
});

// GitHub Dark theme with bottom bar
cookieconsent.extended.init({
  ui: { theme: 'github-dark', position: 'bottom-bar' }
});

// Material Light theme with top-right corner
cookieconsent.extended.init({
  ui: { theme: 'material-light', position: 'top-right' }
});

Checking Consent Status

// Check if user has consented to analytics
if (cookieconsent.extended.hasConsent('analytics')) {
  // Initialize analytics
  gtag('config', 'GA_MEASUREMENT_ID');
}

// Get all consented categories
const consent = cookieconsent.extended.getConsent();
console.log('Consented categories:', consent);

// Get audit trail (if enabled)
const auditTrail = cookieconsent.extended.getAuditTrail();
console.log('Consent history:', auditTrail);

🎨 Themes & Customization

🌈 Available Themes (21)

Light Themes (10)

  • github-light - Clean GitHub-inspired design
  • material-light - Google Material Design
  • tailwind-light - Tailwind CSS styling
  • bootstrap-light - Bootstrap framework colors
  • ant-light - Ant Design system
  • chakra-light - Chakra UI theme
  • mantine-light - Mantine framework
  • semantic-light - Semantic UI styling
  • bulma-light - Bulma CSS framework
  • foundation-light - Foundation framework

Dark Themes (11)

  • dracula - Popular Dracula color scheme
  • github-dark - GitHub's dark mode
  • material-dark - Material Design dark
  • tailwind-dark - Tailwind dark mode
  • vscode-dark - Visual Studio Code dark
  • atom-dark - Atom editor theme
  • sublime-dark - Sublime Text colors
  • nord-dark - Nord color palette
  • discord-dark - Discord app styling
  • slack-dark - Slack app theme
  • notion-dark - Notion app colors

πŸ“ Position Options (10)

  • bottom-right - Corner popup (default)
  • bottom-left - Bottom left corner
  • bottom-center - Bottom center
  • bottom-bar - Full-width bottom bar
  • top-right - Top right corner
  • top-left - Top left corner
  • top-center - Top center
  • top-bar - Full-width top bar
  • center - Center of screen
  • center-modal - Center modal with backdrop

🎬 Animation Types

  • slide - Smooth slide animation (default)
  • fade - Fade in/out effect
  • bounce - Bouncy entrance

πŸ› οΈ Theme API

// Get all available themes
const themes = cookieconsent.extended.getAvailableThemes();

// Get only light themes
const lightThemes = cookieconsent.extended.getThemesByType('light');

// Get only dark themes
const darkThemes = cookieconsent.extended.getThemesByType('dark');

// Get available positions
const positions = cookieconsent.extended.getAvailablePositions();

🎨 Custom Styling

You can override theme variables with CSS:

.cc-popup-extended.cc-theme-dracula {
  --cc-primary-color: #your-custom-color;
  --cc-background: #your-background;
  --cc-text-primary: #your-text-color;
}

πŸ“š Documentation

πŸ”§ Development

Building from Source

# Clone the repository
git clone https://github.com/casjay-templates/cookieconsent.git
cd cookieconsent

# Install dependencies
npm install

# Build the project
npm run build

# Start development server
npm run dev

Project Structure

cookieconsent/
β”œβ”€β”€ src/                    # Source files
β”‚   β”œβ”€β”€ cookieconsent-extended.js
β”‚   └── cookieconsent-extended.css
β”œβ”€β”€ dist/                   # Built files
β”œβ”€β”€ docs/                   # Documentation and demo
β”œβ”€β”€ examples/              # Usage examples
└── build/                 # Build scripts

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Built upon the excellent Osano Cookie Consent library
  • Inspired by modern privacy requirements and user experience best practices

πŸ“ž Support


Made with ❀️ by CasJay Templates

About

Repo for cookieconsent

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors