Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add "isModalForced" to ModuleOptions #78

Merged
merged 14 commits into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ isCssPonyfillEnabled: false,
// Switch to toggle the separation of cookie name and description in the configuration modal by a dash.
isDashInDescriptionEnabled: true,

// if this value is given true, showing Only Modal to force to select for users.
isForcedModal: false,

// Switch to toggle the blocking of iframes.
// This can be used to prevent iframes from adding additional cookies.
isIframeBlocked: false,
Expand Down
7 changes: 6 additions & 1 deletion src/runtime/components/CookieControl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<section class="cookieControl">
<transition :name="`cookieControl__Bar--${moduleOptions.barPosition}`">
<div
v-if="!isConsentGiven"
v-if="!isConsentGiven && !moduleOptions.isForcedModal"
:class="`cookieControl__Bar cookieControl__Bar--${moduleOptions.barPosition}`"
>
<div class="cookieControl__BarContainer">
Expand Down Expand Up @@ -56,6 +56,7 @@
class="cookieControl__ModalClose"
@click="isModalActive = false"
v-text="localeStrings?.close"
v-if="!moduleOptions.isForcedModal"
/>
<template v-for="cookieType in CookieType" :key="cookieType">
<template v-if="moduleOptions.cookies[cookieType].length">
Expand Down Expand Up @@ -337,6 +338,10 @@ onBeforeMount(() => {
}
}
}

if (moduleOptions.isForcedModal) {
isModalActive.value = true;
}
})
watch(
() => cookiesEnabled.value,
Expand Down
2 changes: 2 additions & 0 deletions src/runtime/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export interface ModuleOptions {
isCssPonyfillEnabled: boolean
isDashInDescriptionEnabled: boolean
isIframeBlocked: boolean | { initialState: boolean }
isForcedModal: boolean
locales: Locale[]
localeTexts: PartialRecord<Locale, Partial<LocaleStrings>>
}
Expand Down Expand Up @@ -135,6 +136,7 @@ export const DEFAULTS: Required<ModuleOptions> = {
isCssPonyfillEnabled: false,
isDashInDescriptionEnabled: true,
isIframeBlocked: false,
isForcedModal: false,
domain: '',
locales: ['en'],
localeTexts: { en },
Expand Down