diff --git a/assets/css/_shared.scss b/assets/css/_shared.scss index 4a20ec6..779c020 100644 --- a/assets/css/_shared.scss +++ b/assets/css/_shared.scss @@ -52,3 +52,16 @@ h5, h6 { font-weight: 500; } + +.btn { + padding: 10px; + border: 1px solid $text; + color: $text_invert; + cursor: pointer; + + &.btn-light { + color: $text_invert; + background: $background_invert; + border-color: $text_invert; + } +} diff --git a/assets/css/app.scss b/assets/css/app.scss index 817e637..dac1ebf 100644 --- a/assets/css/app.scss +++ b/assets/css/app.scss @@ -3,4 +3,5 @@ // PAGES @import "/pages/landing"; +@import "pages/responsive-video"; diff --git a/assets/css/pages/responsive-video.scss b/assets/css/pages/responsive-video.scss new file mode 100644 index 0000000..2d7aadf --- /dev/null +++ b/assets/css/pages/responsive-video.scss @@ -0,0 +1,33 @@ +.responsive-video { + position: relative; + padding-bottom: 56.25%; /* Default for 1600x900 videos 16:9 ratio*/ + padding-top: 0px; + height: 0; + overflow: hidden; + + iframe, .consent { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + + &.hidden { + visibility: hidden; + } + } + + .consent { + display: flex; + align-items: center; + justify-content: center; + background: $background_invert; + color: $background; + + .item { + width: 85%; + max-width: 800px; + min-width: 250px; + } + } +} \ No newline at end of file diff --git a/assets/js/app.js b/assets/js/app.js index abd76b5..d569b2b 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -1 +1,6 @@ import 'bootstrap'; +import ResponsiveVideo from './components/responsive-video'; + +(function($) { + new ResponsiveVideo('.responsive-video').activate(); +})(jQuery); diff --git a/assets/js/components/Cookie.js b/assets/js/components/Cookie.js new file mode 100644 index 0000000..ed35c30 --- /dev/null +++ b/assets/js/components/Cookie.js @@ -0,0 +1,39 @@ +class Cookie { + constructor(name) { + this.cname = name; + } + + read() { + let name = this.cname + "="; + let decodedCookie = decodeURIComponent(document.cookie); + let ca = decodedCookie.split(';'); + for(let i = 0; i { + element = jQuery(element); + element.find('.consent') + .removeClass('hidden'); + element.find('.consent-btn') + .on('click', event => { + event.preventDefault(); + event.stopImmediatePropagation(); + + this.giveConsent(); + }); + }); + } + + hasGivenConsent() { + let item = null; + + if(window.sessionStorage) { + item = window.sessionStorage.getItem(this.cacheName); + } else { + item = new Cookie(this.cacheName).read(); + } + + return item === null + ? false + : item; + } + + giveConsent() { + if(window.sessionStorage) { + window.sessionStorage.setItem(this.cacheName, true); + } else { + new Cookie(this.cacheName).write('true', false); + } + + this.switchToVideo(); + } + + switchToVideo() { + jQuery(this.selector) + .each((index, element) => { + element = jQuery(element); + element.find('iframe') + .attr('src', element.data('video-src')) + .removeClass('hidden'); + element.find('.consent') + .remove(); + }); + } +} + +export default ResponsiveVideo; \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 2493775..c67b68c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,6 +23,8 @@ services: volumes: - .:/var/www/html working_dir: /var/www/html + environment: + - DOCKER=true networks: - savetheinternet networks: diff --git a/templates/components/vimeo_video.html.twig b/templates/components/vimeo_video.html.twig new file mode 100644 index 0000000..f3f15ca --- /dev/null +++ b/templates/components/vimeo_video.html.twig @@ -0,0 +1,14 @@ +
+
+ + +
+
\ No newline at end of file diff --git a/templates/index/index.html.twig b/templates/index/index.html.twig index 46212fb..4d05003 100644 --- a/templates/index/index.html.twig +++ b/templates/index/index.html.twig @@ -104,4 +104,13 @@ + +
+
+
+ {% embed "components/vimeo_video.html.twig" with {'id': '70184320'} %}{% endembed %} +
+
+
+ {% endblock %} diff --git a/webpack.config.js b/webpack.config.js index 86b318e..f9dfe8a 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -29,4 +29,13 @@ Encore .autoProvidejQuery() ; -module.exports = Encore.getWebpackConfig(); +let config = Encore.getWebpackConfig(); + +if(process.env.DOCKER) { + config.watchOptions = { + aggregateTimeout: 300, + poll: 1000 + }; +} + +module.exports = config;