Sha256: 8279bfc943f480be5838dfae96807db46feb435163b7cc7b5cecf2286c2b5528

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

# frozen_string_literal: true

require "view_component"

class CookiesComponent < ViewComponent::Base
  def initialize(text: nil, text2: [], url: nil)
    unless text
      text = []
      text << <<~EOS
        You may delete and block all cookies from this site,
        but parts of the site will not work.
      EOS
      text << <<~EOS
        Click "Accept" if you consent usage of cookies,
        otherwise click "Reject".
      EOS
    end

    @text = text
    @text2 = text2
    @url = url
  end

  slim_template <<~HEREDOC
    css:
      div#cookies {
        background: #000000;
        font-color: #ffffff;
        color: white;
        font-size: 1.2rem;
        left: 0px;
        opacity: 40%;
        position: fixed;
        right: 0;
        top: 0;
        z-index:1000;
      }
      div#cookies p {
        margin: 10px;
      }
      div#cookies .buttons {
        margin: 10px;
        text-align: center;
      }
      div#cookies .buttons a {
        font-size: 1.2rem;
        text-decoration: none;
      }

    #cookies
      - @url ||= "/"
      - [@text].flatten.each do |line|
        p = line.html_safe
      - [@text2].flatten.each do |line|
        p = line.html_safe
      .buttons
        button
          a href=helpers.cookies_path(cookiesOK: :x, url: @url) Accept
        button
          a href=helpers.cookies_path(url: @url) Reject
  HEREDOC
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
micoo-0.1.3 app/components/cookies_component.rb