elao/consent-bundle

Symfony 的同意束。提供符合 RGPD 标准的同意提示。

安装次数: 12,236

依赖项: 0

建议者: 0

安全: 0

星标: 2

关注者: 5

分支: 0

公开问题: 3

类型:symfony-bundle

dev-master / 1.0.x-dev 2023-02-22 09:00 UTC

This package is auto-updated.

Last update: 2024-09-20 15:14:11 UTC


README

此插件提供了一个“cookies toast”,允许在用户同意之前使用跟踪脚本或cookie。

Blue

Green

Green

安装

composer require elao/consent-bundle

在您的 bundles.php 文件中

return [
+    Elao\Bundle\ConsentBundle\ElaoConsentBundle::class => ['all' => true],
];

配置

默认情况下,该插件提供了一种名为 default 的单一同意类型。

您可以用一个或多个自定义同意来替换此默认同意

elao_consent:
    consents:
        foobar:
            label: Consent to foobar
        barfoo:
            label: Consent to barfoo

您还可以配置包含用户同意的cookie

elao_consents:
    cookie:
        name: "consent"
        ttl: 15552000 # 6 months

使用方法

在 Twig 中使用默认同意

{% if has_user_consent() %}
    <script>
        // your script requiring consent here
    </script>
{% endif %}

使用多个同意

{% if has_user_consent('foobar') %}
    <script>
        // your script requiring consent here
    </script>
{% endif %}
{% if has_user_consent('barfoo') %}
    <script>
        // your script requiring consent here
    </script>
{% endif %}

覆盖颜色

在您的 CSS 中

.elao-consent {
    --elao-consent-primary: #007bff;
    --elao-consent-primary-dark: #256cdf;
    --elao-consent-secondary: #dfebfa;
    --elao-consent-secondary-dark: #cadef8;
    --elao-consent-danger: #ef4055;
    --elao-consent-neutral: #eae8e8;
    --elao-consent-light: #fff;
    --elao-consent-dark: #252525;
}

SASS 示例

.elao-consent {
    $elao-consent-base-color: #FFCA29;
  
    --elao-consent-primary: #{$elao-consent-base-color};
    --elao-consent-primary-dark: #{darken($elao-consent-base-color, 1%)};
    --elao-consent-secondary: #{lighten($elao-consent-base-color, 50%)};
    --elao-consent-secondary-dark: #{darken(lighten($elao-consent-base-color, 50%), 1%)};
}