From da25e1d224f890e67657f19f125d537bd74c601e Mon Sep 17 00:00:00 2001 From: Alexander Neumann <140883099+Molochem@users.noreply.github.com> Date: Wed, 27 Dec 2023 15:29:12 +0100 Subject: [PATCH] Add more options (#24) * Added Vimeo and Twitter Support * Added Towncrier News Fragment * added options * Main Commit * news fragment * Changes to index.js * Added Requested Changes * Fix Readme * Final Changes * Changes to Readme.md and Index.js --- README.md | 36 ++- news/23.feature | 1 + news/24.feature | 1 + src/components/Banner/Banner.jsx | 91 +++++-- src/components/Block/View.jsx | 88 +++++-- .../components/manage/Blocks/Video/View.jsx | 247 ++++++++++-------- src/index.js | 6 + src/theme/main.less | 4 +- 8 files changed, 323 insertions(+), 151 deletions(-) create mode 100644 news/23.feature create mode 100644 news/24.feature diff --git a/README.md b/README.md index 1d18429..b1960cc 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ Start Volto with: yarn start ``` -Go to http://localhost:3000, and the cooking confirmation screen will popup. +Go to http://localhost:3000, and the cookie confirmation screen will popup. ## Compatibility @@ -99,6 +99,40 @@ config.settings.DSGVOBanner = { privacy_url: '/privacy', }; ``` +You can customize the style of the modal buttons +``` +config.settings.DSGVOBanner.cssClasses = { + bannerAgreeButton: "branded olive", + bannerAdjustButton: "branded blue", +} +``` +Or something like +``` +config.settings.DSGVOBanner.cssClasses = { + bannerAgreeButton: "red", + bannerAdjustButton: "pink", +} +``` +Keep in mind though, that the 'Adjust privacy Setting' Button will always stay inverted + +By default, the banner to configure cookies will be shown in an overlay the first time a user visits the site. You can disable this by setting the `useBanner` setting to `false`. In this case, you must add the "DSGVO Banner" block to a page (such as a privacy settings page) to allow users to configure their cookies. +``` +config.settings.DSGVOBanner.showBanner = false ; +``` +You can also hide the greyed-out 'Technically required' option. +``` +config.settings.DSGVOBanner.showTechnicallyRequired = false ; +``` + +# Supported Modules +Per default only the 'tracking' , 'youtube' , 'facebook' and 'google' Modules are enabled. However, the following List contains all supported Modules : + +- 'tracking' +- 'youtube' +- 'facebook' +- 'google' +- 'twitter' +- 'vimeo' # License diff --git a/news/23.feature b/news/23.feature new file mode 100644 index 0000000..6defbe4 --- /dev/null +++ b/news/23.feature @@ -0,0 +1 @@ +Added Differentiation between Youtube and Vimeo Videos in the Video-View, and added Twitter Module and Cookie Option if someone uses volto-social-blocks with this Addon @Molochem \ No newline at end of file diff --git a/news/24.feature b/news/24.feature new file mode 100644 index 0000000..aa9262f --- /dev/null +++ b/news/24.feature @@ -0,0 +1 @@ +Added : Interchangeable Button Colors, The Option to Hide the Banner on First Connect and the Option to hide the "Technically Required" Checkbox @Molochem \ No newline at end of file diff --git a/src/components/Banner/Banner.jsx b/src/components/Banner/Banner.jsx index f2e8d4b..77f8875 100644 --- a/src/components/Banner/Banner.jsx +++ b/src/components/Banner/Banner.jsx @@ -28,7 +28,16 @@ const Banner = (props) => { const modules = config.settings.DSGVOBanner.modules; const [cookies, setCookie, removeCookie] = useCookies(); const [configureCookies, setConfigureCookies] = useState(false); - const showConfirmModal = !Number(cookies.confirm_cookies) || props.show; + const showTechnicallyRequired = + config.settings.DSGVOBanner.showTechnicallyRequired; + const bannerAgreeButton = + config.settings.DSGVOBanner.cssClasses.bannerAgreeButton; + const bannerAdjustButton = + config.settings.DSGVOBanner.cssClasses.bannerAdjustButton; + const showConfirmModal = config.settings.DSGVOBanner.showBanner + ? !Number(cookies.confirm_cookies) || props.show + : props.show; + const intl = useIntl(); if (isObject(privacy_url)) { @@ -37,6 +46,7 @@ const Banner = (props) => { const [confirmTracking, setConfirmTracking] = useState( !!Number(cookies.confirm_tracking), ); + const [confirmYoutube, setConfirmYoutube] = useState( !!Number(cookies.confirm_youtube), ); @@ -46,6 +56,12 @@ const Banner = (props) => { const [confirmGoogle, setConfirmGoogle] = useState( !!Number(cookies.confirm_google), ); + const [confirmVimeo, setConfirmVimeo] = useState( + !!Number(cookies.confirm_vimeo), + ); + const [confirmTwitter, setConfirmTwitter] = useState( + !!Number(cookies.confirm_twitter), + ); const expiryDate = new Date(); expiryDate.setMonth(expiryDate.getMonth() + 1); @@ -54,6 +70,7 @@ const Banner = (props) => { const confirmSelection = () => { let expiryDate = new Date(); expiryDate.setMonth(expiryDate.getMonth() + 1); + if (confirmTracking) { setCookie('confirm_tracking', 1, options); window[`ga-disable-${config.settings.DSGVOBanner.trackingId}`] = false; @@ -82,6 +99,17 @@ const Banner = (props) => { } else { removeCookie('confirm_google', options); } + if (confirmVimeo) { + setCookie('confirm_vimeo', 1, options); + } else { + removeCookie('confirm_vimeo', 1, options); + } + + if (confirmTwitter) { + setCookie('confirm_twitter', 1, options); + } else { + removeCookie('confirm_twitter', 1, options); + } setCookie('confirm_cookies', 1, options); props.hideDSGVOBanner(); @@ -90,12 +118,13 @@ const Banner = (props) => { const confirmAll = () => { setCookie('confirm_tracking', 1, options); window[`ga-disable-${config.settings.DSGVOBanner.trackingId}`] = false; - setCookie('confirm_facebook', 1, options); setCookie('confirm_youtube', 1, options); setCookie('confirm_google', 1, options); - setCookie('confirm_cookies', 1, options); + setCookie('confirm_twitter', 1, options); + setCookie('confirm_vimeo', 1, options); + setCookie('confirm_cookies', 1, options); props.hideDSGVOBanner(); }; @@ -169,7 +198,10 @@ const Banner = (props) => {