@iamproperty/components 1.0.13 → 2.2.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/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/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 +238 -0
- package/assets/sass/_functions/variables.scss +411 -0
- package/assets/sass/components/accordion.scss +195 -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 +222 -0
- package/assets/sass/elements/forms.scss +128 -0
- package/assets/sass/elements/links.scss +95 -0
- package/assets/sass/elements/lists.scss +26 -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 +114 -0
- package/assets/sass/foundations/brand.scss +74 -0
- package/assets/sass/foundations/circles.scss +63 -0
- package/assets/sass/foundations/fonts.scss +17 -0
- package/assets/sass/foundations/icons.scss +46 -0
- package/assets/sass/foundations/reboot.scss +120 -0
- package/assets/sass/foundations/root.scss +45 -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 +8218 -390
- 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 +8218 -390
- 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 +88 -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 -6
- 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/KeyInformation/KeyInformation.vue +0 -23
- package/src/components/KeyInformation/README.md +0 -32
- 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
- package/src/components/VendorTable/README.md +0 -63
- package/src/components/VendorTable/VendorTable.vue +0 -49
package/README.md
CHANGED
|
@@ -1,29 +1,137 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Getting started
|
|
2
|
+
|
|
3
|
+
## Using the component library or assets
|
|
4
|
+
|
|
5
|
+
### Install
|
|
6
|
+
```
|
|
7
|
+
npm install @iamproperty/components --save
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
### Usage
|
|
11
|
+
|
|
12
|
+
#### Static assets
|
|
13
|
+
|
|
14
|
+
The assets folder can be used independently from the Vue components so that they can be used with other frameworks. With the compiled files available to use out of the box alongside the source files that can be configured.
|
|
2
15
|
|
|
3
|
-
## Project setup
|
|
4
16
|
```
|
|
5
|
-
|
|
17
|
+
<link href="./node_modules/@iamproperty/components/assets/css/style.min.css" as="style" />
|
|
18
|
+
<script src="./node_modules/@iamproperty/components/assets/js/scripts.bundle.min.js"></script>
|
|
6
19
|
```
|
|
7
20
|
|
|
8
|
-
|
|
21
|
+
##### Sass files
|
|
22
|
+
```
|
|
23
|
+
@import './node_modules/@iamproperty/components/assets/sass/_func.scss';
|
|
24
|
+
@import './node_modules/@iamproperty/components/assets/sass/_corefiles_.scss';
|
|
25
|
+
```
|
|
26
|
+
##### JS modules
|
|
27
|
+
```
|
|
28
|
+
import navbar from @iamproperty/components/assets/js/modules/navbar.js
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
#### Vue application
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
import '@iamproperty/components/assets/css/core.min.css'
|
|
36
|
+
import '@iamproperty/components/dist/components.css'
|
|
37
|
+
|
|
38
|
+
import * as iamkey from '@iamproperty/components'
|
|
39
|
+
for (const [key, value] of Object.entries(iamkey)) {
|
|
40
|
+
Vue.component(key, value)
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Components then can be used as described in the design system documentation.
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
<Header title="Page title" image="../../assets/image.jpeg"><p>Page description</p></Header>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
#### NUXT
|
|
51
|
+
|
|
52
|
+
To use the components in NUXT you firstly need to add create a plugin file called plugins/iamkey.js and add the below code.
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
import Vue from 'vue'
|
|
56
|
+
|
|
57
|
+
import '@iamproperty/components/assets/css/core.min.css'
|
|
58
|
+
import '@iamproperty/components/dist/components.css'
|
|
59
|
+
|
|
60
|
+
import * as iamkey from '@iamproperty/components'
|
|
61
|
+
for (const [key, value] of Object.entries(iamkey)) {
|
|
62
|
+
Vue.component(key, value)
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Then add the plugin to the nuxt.config.js file.
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
export default {
|
|
70
|
+
plugins: [
|
|
71
|
+
'plugins/iamkey.js'
|
|
72
|
+
],
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
## Contributing to iam key
|
|
78
|
+
|
|
79
|
+
### Create code branch
|
|
80
|
+
|
|
81
|
+
Firstly the clone the [repo](https://github.com/iamproperty/iamproperty-vue-component-library) from GitHub and create a new branch using the agreed naming conventention.
|
|
82
|
+
|
|
83
|
+
### Commands
|
|
84
|
+
|
|
85
|
+
#### Install node packages
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
npm install
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
#### Development local web server
|
|
92
|
+
|
|
93
|
+
Setup a local web server to run the documentation site this will allow you to modify the code and check it.
|
|
94
|
+
|
|
9
95
|
```
|
|
10
96
|
npm run serve
|
|
11
97
|
```
|
|
12
98
|
|
|
13
|
-
|
|
99
|
+
#### Run your unit tests
|
|
100
|
+
|
|
101
|
+
**This command should be ran while the local web server is still running.**
|
|
102
|
+
|
|
103
|
+
Unit tests should be ran after changing any code to make sure it has no unwanted side effects.
|
|
104
|
+
|
|
105
|
+
The visual regression tests may differ greatly if the tests are running on a windows when the the snapshots where created on Mac.
|
|
106
|
+
|
|
14
107
|
```
|
|
15
|
-
npm run
|
|
108
|
+
npm run test
|
|
16
109
|
```
|
|
17
110
|
|
|
18
|
-
|
|
111
|
+
#### Prepare for pull request
|
|
112
|
+
|
|
113
|
+
**This command should be ran while the local web server is still running.**
|
|
114
|
+
|
|
115
|
+
Before creating a pull request we want to make sure assets get re-compiled and audited so that we can keep an eye on file sizes. We also want to recreate visual regression snapshots. This will create a number of files that will be added to the pull request to help the reviewers make judgement on the changes.
|
|
116
|
+
|
|
19
117
|
```
|
|
20
|
-
npm run
|
|
118
|
+
npm run pull-request
|
|
21
119
|
```
|
|
22
120
|
|
|
23
|
-
###
|
|
121
|
+
### Pull request
|
|
122
|
+
|
|
123
|
+
You will not have the ability to commit changes directly to the main branch and a pull request will have to be created. This pull request should follow the format dictated in the .github/pull_request_template.md file.
|
|
124
|
+
|
|
125
|
+
## Create release
|
|
126
|
+
|
|
127
|
+
Before creating a release you will need to make sure you are logged into the npm registry by running the below command. You will also need to make sure you have access to create releases to the <a href="https://www.npmjs.com/package/@iamproperty/components" target="_blank">npm registry package</a>.
|
|
128
|
+
|
|
24
129
|
```
|
|
25
|
-
npm
|
|
130
|
+
npm login
|
|
26
131
|
```
|
|
27
132
|
|
|
28
|
-
|
|
29
|
-
|
|
133
|
+
After you are logged in then can publish but remember to increase the package version if the package.json file.
|
|
134
|
+
|
|
135
|
+
```
|
|
136
|
+
npm publish
|
|
137
|
+
```
|
package/assets/.DS_Store
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// Bootstrap modules
|
|
2
|
+
//import Alert from '../../node_modules/bootstrap/js/src/alert'
|
|
3
|
+
//import Button from '../../node_modules/bootstrap/js/src/button'
|
|
4
|
+
//import Carousel from '../../node_modules/bootstrap/js/src/carousel'
|
|
5
|
+
//import Collapse from '../../node_modules/bootstrap/js/src/collapse'
|
|
6
|
+
//import Dropdown from '../../node_modules/bootstrap/js/src/dropdown'
|
|
7
|
+
//import Modal from '../../node_modules/bootstrap/js/src/modal'
|
|
8
|
+
//import Offcanvas from '../../node_modules/bootstrap/js/src/offcanvas'
|
|
9
|
+
//import Popover from '../../node_modules/bootstrap/js/src/popover'
|
|
10
|
+
//import ScrollSpy from '../../node_modules/bootstrap/js/src/scrollspy'
|
|
11
|
+
//import Tab from '../../node_modules/bootstrap/js/src/tab'
|
|
12
|
+
//import Toast from '../../node_modules/bootstrap/js/src/toast'
|
|
13
|
+
//import Tooltip from '../../node_modules/bootstrap/js/src/tooltip'
|
|
14
|
+
|
|
15
|
+
// Modules
|
|
16
|
+
import * as helpers from './modules/helpers'
|
|
17
|
+
import nav from './modules/nav'
|
|
18
|
+
import table from './modules/table'
|
|
19
|
+
import accordion from './modules/accordion'
|
|
20
|
+
import testimonial from './modules/testimonial'
|
|
21
|
+
import carousel from './modules/carousel'
|
|
22
|
+
import form from './modules/form'
|
|
23
|
+
|
|
24
|
+
// Attach classes to dom elements
|
|
25
|
+
document.addEventListener("DOMContentLoaded", function() {
|
|
26
|
+
|
|
27
|
+
helpers.addBodyClasses(document.body);
|
|
28
|
+
helpers.checkElements(document.body);
|
|
29
|
+
console.log('test.js');
|
|
30
|
+
|
|
31
|
+
// ANav
|
|
32
|
+
Array.from(document.querySelectorAll('.nav')).forEach((arrayElement, index) => {
|
|
33
|
+
nav(arrayElement);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// Advanced tables
|
|
37
|
+
Array.from(document.querySelectorAll('.table__wrapper')).forEach((arrayElement, index) => {
|
|
38
|
+
table(arrayElement);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// Accordions
|
|
42
|
+
Array.from(document.querySelectorAll('.accordion')).forEach((arrayElement, index) => {
|
|
43
|
+
accordion(arrayElement);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Testimonial
|
|
47
|
+
Array.from(document.querySelectorAll('.testimonial')).forEach((arrayElement, index) => {
|
|
48
|
+
testimonial(arrayElement);
|
|
49
|
+
});
|
|
50
|
+
// Carousel
|
|
51
|
+
Array.from(document.querySelectorAll('.carousel')).forEach((arrayElement, index) => {
|
|
52
|
+
carousel(arrayElement);
|
|
53
|
+
});
|
|
54
|
+
// Form
|
|
55
|
+
Array.from(document.querySelectorAll('form')).forEach((arrayElement, index) => {
|
|
56
|
+
form(arrayElement);
|
|
57
|
+
});
|
|
58
|
+
// Modal
|
|
59
|
+
Array.from(document.querySelectorAll('.modal')).forEach((arrayElement, index) => {
|
|
60
|
+
modal(arrayElement);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
function accordion(accordionElement) {
|
|
2
|
+
|
|
3
|
+
// Fetch all the details element.
|
|
4
|
+
if(!accordionElement.classList.contains('accordion--keep-open')){
|
|
5
|
+
|
|
6
|
+
const details = accordionElement.querySelectorAll(":scope > details");
|
|
7
|
+
|
|
8
|
+
// Add the onclick listeners.
|
|
9
|
+
details.forEach((targetDetail) => {
|
|
10
|
+
targetDetail.addEventListener("click", () => {
|
|
11
|
+
// Close all the details that are not targetDetail.
|
|
12
|
+
details.forEach((detail) => {
|
|
13
|
+
if (detail !== targetDetail) {
|
|
14
|
+
detail.removeAttribute("open");
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if(window.location.hash && document.querySelector(window.location.hash+':not([open]) summary')) {
|
|
22
|
+
|
|
23
|
+
const detail = document.querySelector(window.location.hash+' summary');
|
|
24
|
+
detail.click();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
window.addEventListener('hashchange', function(){
|
|
28
|
+
if(window.location.hash && document.querySelector(window.location.hash+' summary')) {
|
|
29
|
+
|
|
30
|
+
const detail = document.querySelector(window.location.hash+' summary');
|
|
31
|
+
detail.click();
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default accordion
|
|
@@ -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
|