Card

Introduction

Name: didomi-card Component type: card Extends: DidomiBlock

Display a single card with a list of checkboxes.

window.didomiConfig = {
...
entities: [...],
components: {
layout: {...},
activeComponents: [
{
id: "ID_OF_THE_COMPONENT",
type: "card",
options: {
...,
propKey: "PROP_VALUE" // Remember to use camelCase for the key
}
}
]
}
};

Inline configuration

<didomi-card container-id="CONTAINER_ID" prop-key="PROP_VALUE" .../>

Setup

For this component to work properly, you will need to have entities (purposes, preferences and channels) available.

A card is linked to an entity and its parents, if any. The current entity will be displayed in the card (name, description) and its children as checkboxes. If you want to display a preference in the card information, and its channels as checkboxes, your current entity is the preference. You will have to populate the purposeId and the preferenceId .

window.didomiConfig = {
...
entities: {
layout: {
"purposes": [
{
"id": "purpose-id",
"preferences": [
{
"id": "preference-id",
"channels": [
{
"id": "email"
},
{
"id": "print"
}
]
}
]
}
]
},
activeEntities: [
{
"id": "email",
"name": "Emails"
},
{
"id": "print",
"name": {
"fr": "Courrier",
"en": "Mail"
}
},
{
"id": "purpose-id",
"name": "...",
"description": "..."
},
{
"id": "preference-id",
"name": "Preference 1",
"description": "Description..."
}
]
},
components: {
layout: {...},
activeComponents: [
{
id: "ID_OF_THE_COMPONENT",
type: "card",
options: {
...,
purposeId: "purpose-id",
preferenceId: "preference-id"
}
}
]
}
};

If you want to display a list of channels created at root level in the tree of the entities, the only attribute necessary is childrenType which will have to be set to channels . In that case, you will have to manually add the name and description of the card as no parents are available.

Props Options

Name

Type

Description

channelId

String

ID of the channel linked to the card.

childrenType

String

Type of the children you want to display (purposes, preferences, channels)

color

String

Color of the checkboxes

contentContainer

DidomiBlock

Container of the content of the card (except title)

description

DidomiText

Description of the card.

display

String

CSS display property. Example: 'flex', 'inline' ...

enabledPath

String

If you want to save the consent status in a different path in the metadata object of the entity, you can set a different path as a string. (the entities will be the ones linked to the checkboxes (children of the current entity). If a preference is linked to the card, the enabled-path will be used for its channels) For example if you want to save the consent in a brands object located in the entity metadata, for the brand didomi, in an attribut called enabled,you would add brands.didomi.enabled

exclude

Array

List of checkboxes IDs you want to exclude from the list

hasBorder

Boolean

Does the card have a border

headerContainer

DidomiBlock

Container of the title of the card

headerText

DidomiText

Title of the card

hideImageOnMobile

Boolean

Is the image hidden on mobile ?

image

DidomiImage

Image displayed at the right of the card

isShown

Boolean

display/hide the element (default true)

items

DidomiCheckboxes

Sent as an option object to didomi-checkboxes

name

DidomiText

Name of the card

ownConsent

Object

If enabled, it will display 2 radio buttons instead of checkboxes

preferenceId

String

ID of the preference linked to the card.

purposeId

String

ID of the purpose linked to the card.

saveOnClick

Boolean

Should the consent be saved on each click on the checkboxes or set as pending consent. This attribute gives you the choice to either save the consent immediately or wait and save all the pending consents together with a didomi-save component for example. Default value: false.

topContentContainer

DidomiBlock

Container of the top content of the card (except title)

For inline configuration, make sure to use kebab-case syntax. For example purposeId will become purpose-id.

Display the consent of the selected entity

If, instead of displaying the list of children as checkboxes, you want to display the consent of the selected entity, you can use the property ownConsent. It is an object with 2 properties: enabled and texts. Please see the example below:

ownConsent: {
enabled: true,
texts: {
enable: {
content: {
en: 'Yes'
}
},
disable: {
content: {
en: 'No'
}
}
}
}

Examples

If you want to see the image, please click on the Open preview in new window button to see the example on full screen.

Object configuration

window.didomiConfig = {
...
entities: [...],
components: {
layout: {...},
activeComponents: [
{
id: "section-card-1",
type: "card",
options: {
purposeId: "purpose-id",
preferenceId: "preference-id",
color: "#F07D5A"
}
},
{
id: "section-card-2",
type: "card",
options: {
purposeId: "purpose-id",
preferenceId: "preference-id",
color: "#003790",
hasBorder: true,
name: {
content: {
en: "Your subscriptions"
}
},
description: {
content: {
en: "We will be able to contact you on the following channels to allow you to benefit from commercial offers that may interest you."
}
},
headerText: {
content: {
en: "Didomi"
}
},
exclude: ["channel-id-text"],
image: {
src: "https://www.didomi.io/static/assets/[email protected]"
}
}
}
]
}
};