mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2026-01-14 20:11:17 +01:00
Chore/v2/hide banner in onboard (#5032)
# Description of Changes <!-- Please provide a summary of the changes, including: - What was changed - Why the change was made - Any challenges encountered Closes #(issue_number) --> --- ## Checklist ### General - [ ] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [ ] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md) (if applicable) - [ ] I have performed a self-review of my own code - [ ] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### Translations (if applicable) - [ ] I ran [`scripts/counter_translation.py`](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/docs/counter_translation.md) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing) for more details.
This commit is contained in:
parent
1e34038b1e
commit
a62c8b54cf
@ -76,4 +76,9 @@
|
|||||||
.cm__btns{
|
.cm__btns{
|
||||||
padding-top: 1rem !important;
|
padding-top: 1rem !important;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Lower z-index so cookie banner appears behind onboarding modals */
|
||||||
|
#cc-main {
|
||||||
|
z-index: 100 !important;
|
||||||
}
|
}
|
||||||
@ -175,4 +175,9 @@
|
|||||||
#cc-main .pm {
|
#cc-main .pm {
|
||||||
background: var(--cc-bg) !important;
|
background: var(--cc-bg) !important;
|
||||||
color: var(--cc-primary-color) !important;
|
color: var(--cc-primary-color) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Lower z-index so cookie banner appears behind onboarding modals */
|
||||||
|
#cc-main {
|
||||||
|
z-index: 100 !important;
|
||||||
}
|
}
|
||||||
@ -2,12 +2,15 @@ import { useEffect, useState, useCallback } from 'react';
|
|||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { BASE_PATH } from '@app/constants/app';
|
import { BASE_PATH } from '@app/constants/app';
|
||||||
import { useAppConfig } from '@app/contexts/AppConfigContext';
|
import { useAppConfig } from '@app/contexts/AppConfigContext';
|
||||||
|
import { useOnboarding } from '@app/contexts/OnboardingContext';
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
CookieConsent?: {
|
CookieConsent?: {
|
||||||
run: (config: any) => void;
|
run: (config: any) => void;
|
||||||
show: (show?: boolean) => void;
|
show: (show?: boolean) => void;
|
||||||
|
hide: () => void;
|
||||||
|
getCookie: (name?: string) => any;
|
||||||
acceptedCategory: (category: string) => boolean;
|
acceptedCategory: (category: string) => boolean;
|
||||||
acceptedService: (serviceName: string, category: string) => boolean;
|
acceptedService: (serviceName: string, category: string) => boolean;
|
||||||
};
|
};
|
||||||
@ -23,6 +26,7 @@ export const useCookieConsent = ({
|
|||||||
}: CookieConsentConfig = {}) => {
|
}: CookieConsentConfig = {}) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { config } = useAppConfig();
|
const { config } = useAppConfig();
|
||||||
|
const { isOpen: tourIsOpen } = useOnboarding();
|
||||||
const [isInitialized, setIsInitialized] = useState(false);
|
const [isInitialized, setIsInitialized] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -241,6 +245,24 @@ export const useCookieConsent = ({
|
|||||||
};
|
};
|
||||||
}, [analyticsEnabled, config?.enablePosthog, config?.enableScarf, t]);
|
}, [analyticsEnabled, config?.enablePosthog, config?.enableScarf, t]);
|
||||||
|
|
||||||
|
// Hide cookie banner when tour is active
|
||||||
|
useEffect(() => {
|
||||||
|
if (!isInitialized || !window.CookieConsent) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tourIsOpen) {
|
||||||
|
window.CookieConsent.hide();
|
||||||
|
} else {
|
||||||
|
// Only show if user hasn't made a choice yet
|
||||||
|
const consentCookie = window.CookieConsent.getCookie?.();
|
||||||
|
const hasConsented = consentCookie && Object.keys(consentCookie).length > 0;
|
||||||
|
if (!hasConsented) {
|
||||||
|
window.CookieConsent.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [tourIsOpen, isInitialized]);
|
||||||
|
|
||||||
const showCookieConsent = useCallback(() => {
|
const showCookieConsent = useCallback(() => {
|
||||||
if (isInitialized && window.CookieConsent) {
|
if (isInitialized && window.CookieConsent) {
|
||||||
window.CookieConsent?.show();
|
window.CookieConsent?.show();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user