diff --git a/components/slider/js/slider.js b/components/slider/js/slider.js index e253a0b..2bbcd3a 100644 --- a/components/slider/js/slider.js +++ b/components/slider/js/slider.js @@ -147,22 +147,26 @@ const allowedExtensions = [ ]; /** * Load type of image, can be used to load images for different platforms (i.e. mobile optimization) - * @param name - The name appended to the image filename + * @param postfix - What is appended to each image after a dash. Example: /path/to/image becomes /path/to/image-platform.jpg + * for postfix = platform */ -var loadImageType = (name) => { +var loadImageType = (postfix) => { sliderElements.forEach(el => { - const baseURL = el.dataset.imageBaseURL; + const baseURL = el.dataset.imageBaseUrl; const filetype = el.dataset.filetype; - // TODO: Verification (i.e. baseURL cannot contain .something in the end, filetype may only be jpg, jpeg, webp, svg or png) if (allowedExtensions.indexOf(filetype) === -1) { console.warn('[ SLIDER ] Invalid filetype ' + filetype + ' for image element with id ' + el.id); return; } - if (baseURL.lastIndexOf('.') > baseURL.lastIndexOf('/')) { - console.warn('[ SLIDER ] ImageBaseURL incorrect for image element with id ' + el.id); + if (!baseURL) { + console.error('[ SLIDER ] ImageBaseURL undefined for element with id ' + el.id); return; } - el.style.setProperty('background-image', baseURL + name + filetype); + if (baseURL.lastIndexOf('.') > baseURL.lastIndexOf('/')) { + console.warn('[ SLIDER ] ImageBaseURL incorrect for element with id ' + el.id); + return; + } + el.style.backgroundImage = `url( ${baseURL}-${postfix + filetype} )`; }); }; for (const el in fetchedElements) { diff --git a/components/slider/ts/resize.ts b/components/slider/ts/resize.ts new file mode 100644 index 0000000..ab1e742 --- /dev/null +++ b/components/slider/ts/resize.ts @@ -0,0 +1,66 @@ +/* eslint-disable no-var */ +interface SizeConfig { + [name: string]: { + 'min-width': number; + 'max-width': number; + } +} +let sizeConfig: SizeConfig = {}; + + +var resizeConfigure = ( config: SizeConfig ) => { + sizeConfig = config; +}; + + +const handleResize = () => { + const sizes = Object.keys( sizeConfig ); + + for ( let i = 0; i < sizes.length; i++ ) { + const size = sizes[i]; + + if ( + window.innerWidth < sizeConfig[ size ][ 'max-width' ] + && window.innerWidth > sizeConfig[ size ][ 'min-width' ] ) {} + } +}; + +const allowedExtensions = [ + 'webp', + 'jpg', + 'jpeg', + 'svg', + 'png' +]; + +/** + * Load type of image, can be used to load images for different platforms (i.e. mobile optimization) + * @param postfix - What is appended to each image after a dash. Example: /path/to/image becomes /path/to/image-platform.jpg + * for postfix = platform + */ +const loadImageType = ( postfix: string ) => { + sliderElements.forEach( el => { + const baseURL = el.dataset.imageBaseUrl; + const filetype = el.dataset.filetype; + + if ( allowedExtensions.indexOf( filetype ) === -1 ) { + console.warn( '[ SLIDER ] Invalid filetype ' + filetype + ' for image element with id ' + el.id ); + + return; + } + + if ( !baseURL ) { + console.error( '[ SLIDER ] ImageBaseURL undefined for element with id ' + el.id ); + + return; + } + + if ( baseURL.lastIndexOf( '.' ) > baseURL.lastIndexOf( '/' ) ) { + console.warn( '[ SLIDER ] ImageBaseURL incorrect for element with id ' + el.id ); + + return; + } + + el.style.backgroundImage = `url( ${ baseURL }-${ postfix + filetype } )`; + } ); +}; diff --git a/components/slider/ts/slider.ts b/components/slider/ts/slider.ts index 4b48595..d3cee84 100644 --- a/components/slider/ts/slider.ts +++ b/components/slider/ts/slider.ts @@ -163,42 +163,6 @@ const stopSliderAutoAdvance = () => { }; -const allowedExtensions = [ - 'webp', - 'jpg', - 'jpeg', - 'svg', - 'png' -]; - - -/** - * Load type of image, can be used to load images for different platforms (i.e. mobile optimization) - * @param name - The name appended to the image filename - */ - -var loadImageType = ( name: string ) => { - sliderElements.forEach( el => { - const baseURL = el.dataset.imageBaseURL; - const filetype = el.dataset.filetype; - - // TODO: Verification (i.e. baseURL cannot contain .something in the end, filetype may only be jpg, jpeg, webp, svg or png) - if ( allowedExtensions.indexOf( filetype ) === -1 ) { - console.warn( '[ SLIDER ] Invalid filetype ' + filetype + ' for image element with id ' + el.id ); - - return; - } - - if ( baseURL.lastIndexOf( '.' ) > baseURL.lastIndexOf( '/' ) ) { - console.warn( '[ SLIDER ] ImageBaseURL incorrect for image element with id ' + el.id ); - - return; - } - - el.style.setProperty( 'background-image', baseURL + name + filetype ); - } ); -}; - for ( const el in fetchedElements ) { if ( fetchedElements[ el ].className ) { sliderElements.push( ( fetchedElements[ el ] as HTMLDivElement ) ); diff --git a/site/src/css/nav.css b/site/src/css/nav.css index 05426fa..aa594ac 100644 --- a/site/src/css/nav.css +++ b/site/src/css/nav.css @@ -61,6 +61,7 @@ nav a:hover { z-index: 100; background-color: var(--color-background-accent); transition: left 0.5s, top 0.5s; + overflow-y: scroll; } .nav-top-bar { diff --git a/site/src/css/style.css b/site/src/css/style.css index 632b5b6..788e2ca 100644 --- a/site/src/css/style.css +++ b/site/src/css/style.css @@ -119,7 +119,7 @@ a { .slider { width: 100vw; - height: calc(100vw / 16 * 11); + height: 80vh; } .slider-element { @@ -262,11 +262,6 @@ a { } @media only screen and (min-width: 800px) { - .slider { - width: 100vw; - height: 80vh; - } - .slider-controls { font-size: 3rem; } diff --git a/site/src/index.html b/site/src/index.html index 711a6c5..7585257 100644 --- a/site/src/index.html +++ b/site/src/index.html @@ -13,9 +13,11 @@ - + - + @@ -29,32 +31,33 @@