@iamproperty/components 1.0.12 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +120 -12
- package/assets/.DS_Store +0 -0
- package/assets/css/core.min.css +1 -0
- package/assets/css/core.min.css.map +1 -0
- package/assets/css/style.min.css +1 -0
- package/assets/css/style.min.css.map +1 -0
- package/assets/favicons/android-chrome-192x192.png +0 -0
- package/assets/favicons/android-chrome-512x512.png +0 -0
- package/assets/favicons/apple-touch-icon.png +0 -0
- package/assets/favicons/favicon-16x16.png +0 -0
- package/assets/favicons/favicon-32x32.png +0 -0
- package/assets/favicons/favicon.ico +0 -0
- package/assets/fonts/qanelas-medium-webfont.woff +0 -0
- package/assets/fonts/qanelas-medium-webfont.woff2 +0 -0
- package/assets/fonts/qanelassoft-extrabold-webfont.woff +0 -0
- package/assets/fonts/qanelassoft-extrabold-webfont.woff2 +0 -0
- package/assets/img/.DS_Store +0 -0
- package/{src/assets → assets}/img/logo.png +0 -0
- package/assets/js/main.js +62 -0
- package/assets/js/modules/accordion.js +36 -0
- package/assets/js/modules/carousel.js +102 -0
- package/assets/js/modules/drawer.js +16 -0
- package/assets/js/modules/form.js +49 -0
- package/assets/js/modules/helpers.js +93 -0
- package/assets/js/modules/modal.js +72 -0
- package/assets/js/modules/nav.js +27 -0
- package/assets/js/modules/table.js +573 -0
- package/assets/js/modules/testimonial.js +83 -0
- package/assets/js/scripts.bundle.js +1313 -0
- package/assets/js/scripts.bundle.js.map +1 -0
- package/assets/js/scripts.bundle.min.js +7 -0
- package/assets/js/scripts.bundle.min.js.map +1 -0
- package/assets/sass/.DS_Store +0 -0
- package/assets/sass/_components.scss +35 -0
- package/assets/sass/_corefiles.scss +58 -0
- package/assets/sass/_func.scss +9 -0
- package/assets/sass/_functions/functions.scss +95 -0
- package/assets/sass/_functions/mixins.scss +109 -0
- package/assets/sass/_functions/utilities.scss +198 -0
- package/assets/sass/_functions/variables.scss +365 -0
- package/assets/sass/components/accordion.scss +194 -0
- package/assets/sass/components/card.scss +168 -0
- package/assets/sass/components/cardDeck.scss +107 -0
- package/assets/sass/components/carousel.scss +265 -0
- package/assets/sass/components/charts.scss +562 -0
- package/assets/sass/components/drawer.scss +45 -0
- package/assets/sass/components/header.scss +57 -0
- package/assets/sass/components/modal.scss +133 -0
- package/assets/sass/components/nav.scss +619 -0
- package/assets/sass/components/property-searchbar.scss +138 -0
- package/assets/sass/components/snapshot.scss +69 -0
- package/assets/sass/components/tabs.scss +46 -0
- package/assets/sass/components/testimonial.scss +131 -0
- package/assets/sass/components/timeline.scss +93 -0
- package/assets/sass/core.scss +4 -0
- package/assets/sass/elements/buttons.scss +263 -0
- package/assets/sass/elements/container.scss +134 -0
- package/assets/sass/elements/forms.scss +128 -0
- package/assets/sass/elements/links.scss +95 -0
- package/assets/sass/elements/lists.scss +21 -0
- package/assets/sass/elements/media.scss +3 -0
- package/assets/sass/elements/tables.scss +247 -0
- package/assets/sass/elements/tooltips.scss +71 -0
- package/assets/sass/elements/type.scss +99 -0
- package/assets/sass/foundations/brand.scss +64 -0
- package/assets/sass/foundations/circles.scss +66 -0
- package/assets/sass/foundations/fonts.scss +17 -0
- package/assets/sass/foundations/icons.scss +46 -0
- package/assets/sass/foundations/reboot.scss +110 -0
- package/assets/sass/foundations/root.scss +42 -0
- package/assets/sass/main.scss +5 -0
- package/assets/svg/.DS_Store +0 -0
- package/assets/svg/flat/.DS_Store +0 -0
- package/assets/svg/flat/agreed.svg +1 -0
- package/assets/svg/flat/alert.svg +1 -0
- package/assets/svg/flat/asset-37.svg +1 -0
- package/assets/svg/flat/asset-73.svg +1 -0
- package/assets/svg/flat/asset-82.svg +1 -0
- package/assets/svg/flat/award.svg +1 -0
- package/assets/svg/flat/bath.svg +1 -0
- package/assets/svg/flat/bed.svg +1 -0
- package/assets/svg/flat/calculate.svg +1 -0
- package/assets/svg/flat/calendar.svg +1 -0
- package/assets/svg/flat/celebrate.svg +1 -0
- package/assets/svg/flat/chat-house.svg +1 -0
- package/assets/svg/flat/chat.svg +1 -0
- package/assets/svg/flat/circle.svg +1 -0
- package/assets/svg/flat/clean.svg +1 -0
- package/assets/svg/flat/clock.svg +1 -0
- package/assets/svg/flat/computer.svg +1 -0
- package/assets/svg/flat/down.svg +1 -0
- package/assets/svg/flat/edit.svg +1 -0
- package/assets/svg/flat/email.svg +1 -0
- package/assets/svg/flat/event.svg +1 -0
- package/assets/svg/flat/family.svg +1 -0
- package/assets/svg/flat/file.svg +1 -0
- package/assets/svg/flat/find.svg +1 -0
- package/assets/svg/flat/fireworks.svg +1 -0
- package/assets/svg/flat/fist-left.svg +1 -0
- package/assets/svg/flat/fist.svg +1 -0
- package/assets/svg/flat/folder.svg +1 -0
- package/assets/svg/flat/footprints.svg +1 -0
- package/assets/svg/flat/hand.svg +1 -0
- package/assets/svg/flat/hands.svg +1 -0
- package/assets/svg/flat/house-2.svg +1 -0
- package/assets/svg/flat/house.svg +1 -0
- package/assets/svg/flat/idea.svg +1 -0
- package/assets/svg/flat/judge-house.svg +1 -0
- package/assets/svg/flat/judge.svg +1 -0
- package/assets/svg/flat/keys-house.svg +1 -0
- package/assets/svg/flat/lock.svg +1 -0
- package/assets/svg/flat/mobile.svg +1 -0
- package/assets/svg/flat/money.svg +1 -0
- package/assets/svg/flat/monument.svg +1 -0
- package/assets/svg/flat/online-judgement.svg +1 -0
- package/assets/svg/flat/paint.svg +1 -0
- package/assets/svg/flat/person-2.svg +1 -0
- package/assets/svg/flat/person.svg +1 -0
- package/assets/svg/flat/phone.svg +1 -0
- package/assets/svg/flat/pin.svg +1 -0
- package/assets/svg/flat/pound.svg +1 -0
- package/assets/svg/flat/present.svg +1 -0
- package/assets/svg/flat/qualification.svg +1 -0
- package/assets/svg/flat/rocket.svg +1 -0
- package/assets/svg/flat/sale.svg +1 -0
- package/assets/svg/flat/save.svg +1 -0
- package/assets/svg/flat/scale.svg +1 -0
- package/assets/svg/flat/send.svg +1 -0
- package/assets/svg/flat/share.svg +1 -0
- package/assets/svg/flat/sofa.svg +1 -0
- package/assets/svg/flat/sold.svg +1 -0
- package/assets/svg/flat/star.svg +1 -0
- package/assets/svg/flat/stopwatch.svg +1 -0
- package/assets/svg/flat/task.svg +1 -0
- package/assets/svg/flat/telescope.svg +1 -0
- package/assets/svg/flat/thumb.svg +1 -0
- package/assets/svg/flat/time.svg +1 -0
- package/assets/svg/flat/up.svg +1 -0
- package/assets/svg/flat/valuation.svg +1 -0
- package/assets/svg/flat/value-house.svg +1 -0
- package/assets/svg/flat/warning.svg +1 -0
- package/assets/svg/flat/water.svg +1 -0
- package/assets/svg/icons.svg +51 -0
- package/assets/svg/illustrations/commuter1.svg +1 -0
- package/assets/svg/illustrations/commuter2.svg +1 -0
- package/assets/svg/illustrations/commuter3.svg +1 -0
- package/assets/svg/logo.svg +43 -0
- package/dist/components.common.js +8253 -328
- package/dist/components.common.js.map +1 -1
- package/dist/components.css +2 -1
- package/dist/components.css.map +1 -0
- package/dist/components.umd.js +8253 -328
- package/dist/components.umd.js.map +1 -1
- package/dist/components.umd.min.js +1 -1
- package/dist/components.umd.min.js.map +1 -1
- package/package.json +91 -57
- package/src/.DS_Store +0 -0
- package/src/components/Accordion/Accordion.vue +24 -0
- package/src/components/Accordion/AccordionItem.vue +43 -0
- package/src/components/Accordion/README.md +34 -0
- package/src/components/Banner/Banner.vue +38 -0
- package/src/components/Banner/README.md +24 -0
- package/src/components/Card/Card.vue +115 -0
- package/src/components/Card/README.md +24 -0
- package/src/components/CardDeck/CardDeck.vue +78 -0
- package/src/components/CardDeck/README.md +25 -0
- package/src/components/Carousel/Carousel.vue +86 -0
- package/src/components/Carousel/README.md +20 -0
- package/src/components/Chart/Chart.vue +246 -0
- package/src/components/Chart/README.md +18 -0
- package/src/components/Drawer/Drawer.vue +54 -0
- package/src/components/Drawer/README.md +23 -0
- package/src/components/Header/Header.vue +39 -0
- package/src/components/Header/README.md +28 -0
- package/src/components/Modal/Modal.vue +44 -0
- package/src/components/Modal/README.md +20 -0
- package/src/components/Nav/Nav.vue +129 -0
- package/src/components/Nav/README.md +23 -0
- package/src/components/PropertySearchbar/PropertySearchbar.vue +206 -0
- package/src/components/PropertySearchbar/README.md +26 -0
- package/src/components/Snapshot/README.md +21 -0
- package/src/components/Snapshot/Snapshot.vue +33 -0
- package/src/components/Tabs/README.md +27 -0
- package/src/components/Tabs/Tab.vue +17 -0
- package/src/components/Tabs/Tabs.vue +55 -0
- package/src/components/Testimonial/README.md +26 -0
- package/src/components/Testimonial/Testimonial.vue +61 -0
- package/src/components/Timeline/README.md +18 -0
- package/src/components/Timeline/Timeline.vue +25 -0
- package/src/elements/Input/Input.vue +236 -0
- package/src/elements/Input/README.md +18 -0
- package/src/elements/Table/README.md +55 -0
- package/src/elements/Table/Table.vue +112 -0
- package/src/foundations/Icon/Icon.vue +21 -0
- package/src/foundations/Icon/README.md +11 -0
- package/src/foundations/Logo/Logo.vue +39 -0
- package/src/foundations/Logo/README.md +20 -0
- package/src/helpers/strings.js +12 -0
- package/src/index.js +21 -4
- package/src/assets/css/default.css +0 -99
- package/src/assets/logo.png +0 -0
- package/src/assets/scss/_variables.scss +0 -13
- package/src/components/KeyFacts/KeyFact.vue +0 -45
- package/src/components/KeyFacts/KeyFactGroup.vue +0 -44
- package/src/components/KeyFacts/README.md +0 -23
- package/src/components/PropertyTaskIntro/PropertyTaskIntro.vue +0 -74
- package/src/components/PropertyTaskIntro/README.md +0 -27
- package/src/components/TaskTitle/README.md +0 -24
- package/src/components/TaskTitle/TaskTitle.vue +0 -68
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
function carousel(carouselElement) {
|
|
2
|
+
|
|
3
|
+
var scrollTimeout;
|
|
4
|
+
|
|
5
|
+
let carouselInner = carouselElement.querySelector('.carousel__inner');
|
|
6
|
+
let itemCount = carouselElement.querySelectorAll('.carousel__item').length;
|
|
7
|
+
let cols = carouselElement.getAttribute('data-cols');
|
|
8
|
+
let smCols = carouselElement.getAttribute('data-sm-cols');
|
|
9
|
+
let mdCols = carouselElement.getAttribute('data-md-cols');
|
|
10
|
+
|
|
11
|
+
carouselElement.querySelector('.carousel__controls a').classList.add('active');
|
|
12
|
+
|
|
13
|
+
// On scroll we need to make sure the buttons get corrected and the next testimonial is shown
|
|
14
|
+
carouselInner.addEventListener('scroll', function(e){
|
|
15
|
+
clearTimeout(scrollTimeout);
|
|
16
|
+
scrollTimeout = setTimeout(function(){
|
|
17
|
+
|
|
18
|
+
let scrollArea = carouselInner.clientWidth;
|
|
19
|
+
let scrollWidth = carouselInner.scrollWidth;
|
|
20
|
+
let scrollLeft = carouselInner.scrollLeft;
|
|
21
|
+
let targetSlide = Math.round((scrollLeft / scrollWidth) * itemCount) + 1;
|
|
22
|
+
let lastItemOffset = carouselElement.querySelector('.carousel__item:last-child').offsetLeft;
|
|
23
|
+
|
|
24
|
+
Array.from(carouselElement.querySelectorAll('.carousel__controls a')).forEach((link, index) => {
|
|
25
|
+
link.classList.remove('active');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
carouselElement.querySelector('.control-'+targetSlide).classList.add('active');
|
|
29
|
+
|
|
30
|
+
// Disable the previous button
|
|
31
|
+
if(targetSlide == 1)
|
|
32
|
+
carouselElement.querySelector('.btn-prev').setAttribute('disabled','disabled');
|
|
33
|
+
else
|
|
34
|
+
carouselElement.querySelector('.btn-prev').removeAttribute('disabled');
|
|
35
|
+
|
|
36
|
+
// Disable the next button if the last item is in view
|
|
37
|
+
if(carouselInner.scrollLeft + scrollArea > lastItemOffset)
|
|
38
|
+
carouselElement.querySelector('.btn-next').setAttribute('disabled','disabled');
|
|
39
|
+
else
|
|
40
|
+
carouselElement.querySelector('.btn-next').removeAttribute('disabled');
|
|
41
|
+
|
|
42
|
+
}, 100);
|
|
43
|
+
|
|
44
|
+
}, false);
|
|
45
|
+
|
|
46
|
+
// when the buttons are used we need to make sure the carousel scrolls to the correct place
|
|
47
|
+
carouselElement.addEventListener('click', function(e){
|
|
48
|
+
|
|
49
|
+
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
50
|
+
if (target.matches('.carousel__controls a')) {
|
|
51
|
+
|
|
52
|
+
e.preventDefault();
|
|
53
|
+
|
|
54
|
+
Array.from(carouselElement.querySelectorAll('.carousel__controls a')).forEach((link, index) => {
|
|
55
|
+
link.classList.remove('active');
|
|
56
|
+
});
|
|
57
|
+
target.classList.add('active');
|
|
58
|
+
|
|
59
|
+
const el = document.querySelector(target.getAttribute('href'));
|
|
60
|
+
|
|
61
|
+
carouselInner.scroll({
|
|
62
|
+
top: 0,
|
|
63
|
+
left: el.offsetLeft,
|
|
64
|
+
behavior: 'smooth'
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}, false);
|
|
71
|
+
|
|
72
|
+
carouselElement.addEventListener('click', function(e){
|
|
73
|
+
|
|
74
|
+
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
75
|
+
if (target.matches('.btn-next, .btn-prev')) {
|
|
76
|
+
|
|
77
|
+
e.preventDefault();
|
|
78
|
+
let scrollTo = target.classList.contains('btn-prev') ? carouselInner.scrollLeft - carouselInner.clientWidth : carouselInner.scrollLeft + carouselInner.clientWidth;
|
|
79
|
+
|
|
80
|
+
carouselInner.scroll({
|
|
81
|
+
top: 0,
|
|
82
|
+
left: scrollTo,
|
|
83
|
+
behavior: 'smooth'
|
|
84
|
+
});
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}, false);
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
// Add responsive hide button classes
|
|
92
|
+
if(itemCount == 1)
|
|
93
|
+
carouselElement.classList.add('hide-btns');
|
|
94
|
+
|
|
95
|
+
if(smCols >= itemCount)
|
|
96
|
+
carouselElement.classList.add('hide-sm-btns');
|
|
97
|
+
|
|
98
|
+
if(mdCols >= itemCount)
|
|
99
|
+
carouselElement.classList.add('hide-md-btns');
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export default carousel
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const drawer = (element) => {
|
|
2
|
+
|
|
3
|
+
const observer = new IntersectionObserver(
|
|
4
|
+
|
|
5
|
+
function([e]){
|
|
6
|
+
e.target.classList.toggle("in-view", e.intersectionRatio > 0)
|
|
7
|
+
document.getElementById('showDrawer').checked = false
|
|
8
|
+
},
|
|
9
|
+
{ threshold: [1] }
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
const el = document.getElementById('drawer-end')
|
|
13
|
+
observer.observe(el);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default drawer
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Create a link between two input/selects with one acting as setting a minimum value and the second a maximum
|
|
2
|
+
// The link between the two will prevent the max input field form setting a lower value than the min and vice versa
|
|
3
|
+
function inputRange(inputWrapper){
|
|
4
|
+
|
|
5
|
+
inputWrapper.addEventListener('change', function(e){
|
|
6
|
+
|
|
7
|
+
var min = parseInt(inputWrapper.querySelector('[data-min] select,[data-min] input').value);
|
|
8
|
+
var max = parseInt(inputWrapper.querySelector('[data-max] select,[data-max] input').value);
|
|
9
|
+
|
|
10
|
+
// Set attributes for input fields
|
|
11
|
+
Array.from(inputWrapper.querySelectorAll('[data-min] input')).forEach((input, index) => {
|
|
12
|
+
|
|
13
|
+
input.setAttribute('max',max);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
Array.from(inputWrapper.querySelectorAll('[data-max] input')).forEach((input, index) => {
|
|
17
|
+
|
|
18
|
+
input.setAttribute('min',min);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// Hide select options if they are higher or lower than the min and max values
|
|
22
|
+
Array.from(inputWrapper.querySelectorAll('[data-min] select option')).forEach((option, index) => {
|
|
23
|
+
|
|
24
|
+
if(parseInt(option.getAttribute('value')) > max)
|
|
25
|
+
option.classList.add('d-none');
|
|
26
|
+
else
|
|
27
|
+
option.classList.remove('d-none');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
Array.from(inputWrapper.querySelectorAll('[data-max] select option')).forEach((option, index) => {
|
|
31
|
+
|
|
32
|
+
if(parseInt(option.getAttribute('value')) < min)
|
|
33
|
+
option.classList.add('d-none');
|
|
34
|
+
else
|
|
35
|
+
option.classList.remove('d-none');
|
|
36
|
+
});
|
|
37
|
+
}, false);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Acts as an overall initialise function to trigger other functions.
|
|
41
|
+
function form(formElement) {
|
|
42
|
+
|
|
43
|
+
// Check for input range groups
|
|
44
|
+
Array.from(formElement.querySelectorAll('[data-input-range]')).forEach((arrayElement, index) => {
|
|
45
|
+
inputRange(arrayElement);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default form
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Global helper functions to help maintain and enhance framework elements.
|
|
3
|
+
* @module Helpers
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Add global classes used by the CSS and later JavaScript.
|
|
8
|
+
* @param {HTMLElement} body Dom element, this doesn't have to be the body but it is recommended.
|
|
9
|
+
*/
|
|
10
|
+
const addBodyClasses = (body) => {
|
|
11
|
+
|
|
12
|
+
body.classList.add("js-enabled");
|
|
13
|
+
|
|
14
|
+
if(navigator.userAgent.indexOf('MSIE')!==-1 || navigator.appVersion.indexOf('Trident/') > 0){
|
|
15
|
+
|
|
16
|
+
body.classList.add("ie");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return null
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Check if an element contains certain elements that needs enhancing with the JavaScript helpers, it is recommended to do this on the page body after the dom is loaded. Elements that are loaded via ajax should also run this function.
|
|
24
|
+
* @param {HTMLElement} element Dom element, this doesn't have to be the body but it is recommended.
|
|
25
|
+
*/
|
|
26
|
+
const checkElements = (element) => {
|
|
27
|
+
|
|
28
|
+
// Tables
|
|
29
|
+
Array.from(element.querySelectorAll('table')).forEach((table, index) => {
|
|
30
|
+
|
|
31
|
+
tableStacked(table);
|
|
32
|
+
tableWrap(table);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Wrap tables with a table wrapper div to help maintain its responsive design.
|
|
38
|
+
* @param {HTMLElement} table Dom table element
|
|
39
|
+
*/
|
|
40
|
+
const tableWrap = (table) => {
|
|
41
|
+
|
|
42
|
+
if(!table.parentNode.classList.contains('table__wrapper')){
|
|
43
|
+
|
|
44
|
+
const tableHTML = table.outerHTML;
|
|
45
|
+
|
|
46
|
+
table.outerHTML = `<div class="table__wrapper">${tableHTML}</div>`;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Creates data attributes to be used by the CSS for mobile views.
|
|
52
|
+
* @param {HTMLElement} table Dom table element
|
|
53
|
+
*/
|
|
54
|
+
const tableStacked = (table) => {
|
|
55
|
+
|
|
56
|
+
const colHeadings = Array.from(table.querySelectorAll('thead th'));
|
|
57
|
+
const colRows = Array.from(table.querySelectorAll('tbody tr'));
|
|
58
|
+
|
|
59
|
+
colRows.forEach((row, index) => {
|
|
60
|
+
|
|
61
|
+
const cells = Array.from(row.querySelectorAll('th, td'));
|
|
62
|
+
|
|
63
|
+
cells.forEach((cell, cellIndex) => {
|
|
64
|
+
|
|
65
|
+
const heading = colHeadings[cellIndex];
|
|
66
|
+
if(typeof heading != "undefined"){
|
|
67
|
+
|
|
68
|
+
let tempDiv = document.createElement("div");
|
|
69
|
+
tempDiv.innerHTML = heading.innerHTML;
|
|
70
|
+
let headingText = tempDiv.textContent || tempDiv.innerText || "";
|
|
71
|
+
cell.setAttribute('data-label',headingText);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
const isNumeric = function(str) {
|
|
79
|
+
if (typeof str != "string") return false // we only process strings!
|
|
80
|
+
return !isNaN(str) && // use type coercion to parse the _entirety_ of the string (`parseFloat` alone does not do this)...
|
|
81
|
+
!isNaN(parseFloat(str)) // ...and ensure strings of whitespace fail
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const zeroPad = (num, places) => String(num).padStart(places, '0')
|
|
85
|
+
|
|
86
|
+
export {
|
|
87
|
+
addBodyClasses,
|
|
88
|
+
checkElements,
|
|
89
|
+
tableWrap,
|
|
90
|
+
tableStacked,
|
|
91
|
+
isNumeric,
|
|
92
|
+
zeroPad
|
|
93
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
const modal = (element) => {
|
|
2
|
+
|
|
3
|
+
const links = element.querySelectorAll('.modal__outer a, .modal__outer button');
|
|
4
|
+
const firstLink = links[0]
|
|
5
|
+
const lastLink = links[links.length - 1]
|
|
6
|
+
|
|
7
|
+
const closeModal = function(){
|
|
8
|
+
const button = document.querySelector('[href="'+window.location.hash+'"]');
|
|
9
|
+
button.focus();
|
|
10
|
+
window.location.hash = "close";
|
|
11
|
+
history.replaceState("", document.title, window.location.pathname + window.location.search);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Trap the tab focus inside
|
|
15
|
+
element.addEventListener('keydown', function(e){
|
|
16
|
+
|
|
17
|
+
if(e.key === "Tab" && e.shiftKey && document.activeElement == firstLink){
|
|
18
|
+
|
|
19
|
+
e.preventDefault();
|
|
20
|
+
lastLink.focus();
|
|
21
|
+
}
|
|
22
|
+
else if(e.key === "Tab" && !e.shiftKey && document.activeElement == lastLink) {
|
|
23
|
+
|
|
24
|
+
e.preventDefault();
|
|
25
|
+
firstLink.focus();
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// ESC will close the open modal
|
|
30
|
+
document.addEventListener("keydown", function(e){
|
|
31
|
+
if (e.key === "Escape" && document.querySelector('.modal:target'))
|
|
32
|
+
closeModal();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
element.addEventListener('click', function(e){
|
|
36
|
+
for (var target = e.target; target && target != this; target = target.parentNode) {
|
|
37
|
+
|
|
38
|
+
// Close links will close the model by default but we wont to remove the hash link
|
|
39
|
+
if (target.matches('[href="#close"]')) {
|
|
40
|
+
|
|
41
|
+
e.preventDefault();
|
|
42
|
+
closeModal();
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
// Dock the modal to the right or left to make the content behind readable
|
|
46
|
+
else if (target.matches('.modal__dock--right')) {
|
|
47
|
+
|
|
48
|
+
e.preventDefault();
|
|
49
|
+
if(!element.classList.contains('modal--left'))
|
|
50
|
+
element.classList.add('modal--right');
|
|
51
|
+
|
|
52
|
+
element.classList.remove('modal--left');
|
|
53
|
+
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
else if (target.matches('.modal__dock--left')) {
|
|
57
|
+
|
|
58
|
+
e.preventDefault();
|
|
59
|
+
|
|
60
|
+
if(!element.classList.contains('modal--right'))
|
|
61
|
+
element.classList.add('modal--left');
|
|
62
|
+
|
|
63
|
+
element.classList.remove('modal--right');
|
|
64
|
+
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export default modal
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const navbar = (element) => {
|
|
2
|
+
|
|
3
|
+
Array.from(element.querySelectorAll('details')).forEach((detail, index) => {
|
|
4
|
+
|
|
5
|
+
detail.addEventListener('mouseenter', function(e){
|
|
6
|
+
|
|
7
|
+
if(window.matchMedia('(min-width: 62em)').matches)
|
|
8
|
+
detail.setAttribute('open','true')
|
|
9
|
+
}, false);
|
|
10
|
+
|
|
11
|
+
detail.addEventListener('mouseleave', function(e){
|
|
12
|
+
|
|
13
|
+
if(window.matchMedia('(min-width: 62em)').matches)
|
|
14
|
+
detail.removeAttribute('open')
|
|
15
|
+
}, false);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
const observer = new IntersectionObserver(
|
|
20
|
+
([e]) => e.target.classList.toggle("is-stuck", e.intersectionRatio < 1),
|
|
21
|
+
{ threshold: [1] }
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
observer.observe(element);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default navbar
|