toggle-components-library 1.11.1 → 1.15.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toggle-components-library",
3
- "version": "1.11.1",
3
+ "version": "1.15.0",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -34,7 +34,8 @@
34
34
  "vue-moment": "^4.1.0",
35
35
  "vue-router": "^3.4.3",
36
36
  "vue2-dropzone": "^3.6.0",
37
- "vuedraggable": "^2.24.3"
37
+ "vuedraggable": "^2.24.3",
38
+ "webfontloader": "^1.6.28"
38
39
  },
39
40
  "devDependencies": {
40
41
  "@babel/core": "^7.11.1",
@@ -1,9 +1,27 @@
1
1
  <template>
2
- <hr class="toggle-line-break"/>
2
+ <hr :class="classes"/>
3
3
  </template>
4
4
 
5
5
  <script>
6
6
  export default {
7
- name: "LineBreak"
7
+ name: "LineBreak",
8
+ props: {
9
+ colour: {
10
+ type: String,
11
+ default: 'blue',
12
+ validator: (value) => [
13
+ 'blue',
14
+ 'grey'
15
+ ].includes(value.toLowerCase())
16
+ },
17
+ },
18
+ computed: {
19
+ classes() {
20
+ return {
21
+ 'toggle-line-break': this.colour == 'blue',
22
+ 'toggle-line-break-grey': this.colour == 'grey'
23
+ };
24
+ },
25
+ }
8
26
  }
9
27
  </script>
@@ -0,0 +1,113 @@
1
+ <template>
2
+ <ToggleInputSelect :options="fontOptions" :label="label" :name="name" :fontFamily="inputVal" v-model="inputVal" size="medium" :style="`font-family: ${inputVal};`"/>
3
+ </template>
4
+
5
+ <script>
6
+ import { mixins } from '../mixins/mixins';
7
+ import ToggleInputSelect from './ToggleInputSelect.vue';
8
+ var WebFont = require('webfontloader');
9
+
10
+ export default {
11
+ mixins:[mixins],
12
+ components:{ ToggleInputSelect },
13
+ name: 'FontPicker',
14
+ props: {
15
+ value: {
16
+ type: String
17
+ },
18
+ /**
19
+ * The name of the fontpicker component
20
+ */
21
+ name: {
22
+ type: String,
23
+ default: "ToggleFontPicker"
24
+ },
25
+ /**
26
+ * The label that will be displayed
27
+ */
28
+ label: {
29
+ type: String,
30
+ required: false,
31
+ default: "Font picker"
32
+ },
33
+ /**
34
+ * Whether this is a required field or not
35
+ */
36
+ required: {
37
+ type: Boolean,
38
+ default: false
39
+ },
40
+ },
41
+ data() {
42
+ return {
43
+ fonts: [
44
+ 'Abril Fatface',
45
+ 'Alpha Slab One',
46
+ 'Anton',
47
+ 'Arvo',
48
+ 'Bodoni Moda',
49
+ 'EB Garamond',
50
+ 'Fredoka One',
51
+ 'IBM Plex Mono',
52
+ 'Lato',
53
+ 'Libre Baskerville',
54
+ 'Lora',
55
+ 'Merriweather',
56
+ 'Montserrat',
57
+ 'Nunito',
58
+ 'Open Sans',
59
+ 'Open Sans Condensed',
60
+ 'Oswald',
61
+ 'Poppins',
62
+ 'Prata',
63
+ 'PT Serif',
64
+ 'Quicksand',
65
+ 'Roboto',
66
+ 'Roboto Mono',
67
+ 'Roboto Slab',
68
+ 'Rubik',
69
+ 'Sacramento',
70
+ 'Source Sans Pro',
71
+ 'Source Serif Pro',
72
+ 'Volkhov',
73
+ 'Work Sans Pro',
74
+ 'Space Mono'
75
+ ],
76
+ }
77
+ },
78
+ created() {
79
+ this.getFonts();
80
+ },
81
+
82
+ computed: {
83
+ fontOptions() {
84
+ // Format font list into value/label object for select input
85
+ return this.fonts.map(font => {
86
+ return {
87
+ value: font,
88
+ label: font
89
+ }
90
+ })
91
+ },
92
+ inputVal: {
93
+ get() {
94
+ return this.value;
95
+ },
96
+
97
+ set(value) {
98
+ this.$emit('input', value);
99
+ }
100
+ }
101
+ },
102
+
103
+ methods: {
104
+ getFonts() {
105
+ WebFont.load({
106
+ google: {
107
+ families: this.fonts
108
+ }
109
+ });
110
+ }
111
+ }
112
+ }
113
+ </script>
@@ -0,0 +1,158 @@
1
+ <template>
2
+ <div class="toggle-input-container" :class="{'toggle-input-is-invalid':isInvalid }" @click="focusClosestInput">
3
+ <label v-if="label" :for="name ? name : 'ToggleInputNumberUnit' " class="toggle-input-label" >
4
+ {{ label }}
5
+ </label>
6
+ <input
7
+ :name="name ? name : 'ToggleInputNumberUnit' "
8
+ :class="[ 'toggle-input', size]"
9
+ :placeholder="placeholder ? placeholder : '' "
10
+ :autocomplete="autocomplete ? 'on' : 'off' "
11
+ :required="required"
12
+ v-model="inputVal"
13
+ @blur="onBlur"
14
+ @focus="onFocus"
15
+ @keyup="onKeyup"
16
+ />
17
+ <label class="toggle-input-label-error" v-if="isInvalid" :for="name ? name : 'ToggleInputNumberUnit' ">
18
+ {{ errorMessage }}
19
+ </label>
20
+ </div>
21
+ </template>
22
+
23
+ <script>
24
+
25
+ import { mixins } from '../mixins/mixins'
26
+
27
+ export default {
28
+ mixins:[mixins],
29
+ props: {
30
+ value: {
31
+ type: [Number, String]
32
+ },
33
+ allowBlank:{
34
+ type:Boolean,
35
+ default:false
36
+ },
37
+ name: {
38
+ type: String,
39
+ default: "ToggleInputNumberUnit"
40
+ },
41
+ label: {
42
+ type: String,
43
+ required: false
44
+ },
45
+ placeholder: {
46
+ type: String,
47
+ required: false
48
+ },
49
+ autocomplete: {
50
+ type: Boolean,
51
+ default: true
52
+ },
53
+ size: {
54
+ type: String,
55
+ validator: function (value) {
56
+ return ['extra-small', 'small', 'medium', 'large', 'full'].indexOf(value) !== -1
57
+ }
58
+ },
59
+ required: {
60
+ type: Boolean,
61
+ default: false
62
+ },
63
+ isInvalid: {
64
+ type: Boolean,
65
+ default: false
66
+ },
67
+ errorMessage: {
68
+ type: String,
69
+ required: false
70
+ },
71
+ appendString: {
72
+ type: String,
73
+ required: false
74
+ },
75
+ prependString: {
76
+ type: String,
77
+ required: false
78
+ }
79
+ },
80
+
81
+ data() {
82
+ return {
83
+ inputActive: false
84
+ };
85
+ },
86
+ computed: {
87
+ inputVal: {
88
+ get() {
89
+ if (this.inputActive) {
90
+ if((this.value === '' || this.value === null) && this.allowBlank)
91
+ return '';
92
+
93
+ return this.value;
94
+ } else {
95
+ if(this.value === '' || this.value == null || this.value === 0)
96
+ return '';
97
+
98
+ return this.value;
99
+ }
100
+ },
101
+ set(modifiedValue) {
102
+ this.$emit('input', modifiedValue);
103
+ }
104
+ },
105
+ appendStringLength() {
106
+ return this.appendString.length ?? 0;
107
+ },
108
+ prependStringLength() {
109
+ return this.prependString.length ?? 0;
110
+ }
111
+ },
112
+ methods: {
113
+ onKeyup() {
114
+ // Remove any non-numbers from the input value
115
+ this.$emit('input', this.value.replace(/[^0-9]/g,''))
116
+ },
117
+
118
+ onFocus() {
119
+ this.inputActive = true;
120
+ // When the user clicks in the box, remove the append and/or prepend values
121
+ if ((this.value != 0) && (this.value != '')) {
122
+ let tempValue = this.value;
123
+ if (this.appendString) {
124
+ // First take off the appended string
125
+ tempValue = this.value.slice(0, -this.appendStringLength)
126
+ }
127
+ if (this.prependString) {
128
+ // Then take off the prepended string
129
+ tempValue = tempValue.slice(this.prependStringLength, this.value.length)
130
+ }
131
+ this.$emit('input', tempValue);
132
+ }
133
+ },
134
+
135
+ onBlur(){
136
+ this.inputActive = false;
137
+
138
+ // Don't add the unit if the value is left empty
139
+ if (this.value != '') {
140
+ // When the user clicks out of the box, add the prepend and/or append values
141
+ let tempValue = this.value;
142
+ if (this.appendString) {
143
+ // First add the append string
144
+ tempValue += this.appendString;
145
+ }
146
+ if (this.prependString) {
147
+ // Then add the prepend string
148
+ tempValue = this.prependString + tempValue;
149
+ }
150
+ this.$emit('input', tempValue)
151
+ }
152
+ },
153
+ }
154
+ }
155
+
156
+
157
+
158
+ </script>
@@ -15,6 +15,7 @@
15
15
  v-model="inputVal"
16
16
  :autocomplete="autocomplete ? 'on' : 'off' "
17
17
  :required="required"
18
+ :style="`${fontFamily ? 'font-family: ' + fontFamily : ''}`"
18
19
  >
19
20
  <option value="">Select an option</option>
20
21
  <option :value="option.value" v-for="(option, key) in options" v-bind:key="key">{{option.label}}</option>
@@ -72,6 +73,10 @@ export default {
72
73
  errorMessage: {
73
74
  type: String,
74
75
  required: false
76
+ },
77
+ fontFamily: {
78
+ type: String,
79
+ required: false
75
80
  }
76
81
  },
77
82
 
package/src/index.js CHANGED
@@ -49,6 +49,10 @@ import ToggleHeaderTextLarge from "./components/text/ToggleHeaderTextLarge.vue";
49
49
  import ToggleHelperTextSmall from "./components/text/ToggleHelperTextSmall.vue";
50
50
  import ToggleInfoText from "./components/text/ToggleInfoText.vue";
51
51
 
52
+ import ToggleFontPicker from "./components/forms/ToggleFontPicker.vue";
53
+
54
+ import ToggleInputNumberUnit from "./components/forms/ToggleInputNumberUnit.vue";
55
+
52
56
  import './sass/main.scss';
53
57
 
54
58
  const Components = {
@@ -92,7 +96,9 @@ const Components = {
92
96
  ToggleFeatureButton,
93
97
  ToggleHelperTextSmall,
94
98
  ToggleInfoText,
95
- ToggleInternationalPhoneInputSelect
99
+ ToggleInternationalPhoneInputSelect,
100
+ ToggleFontPicker,
101
+ ToggleInputNumberUnit
96
102
  }
97
103
 
98
104
  Object.keys(Components).forEach(name => {
@@ -1,6 +1,9 @@
1
1
  .toggle-line-break {
2
2
  border-bottom: 1px solid $toggle-blue;
3
3
  }
4
+ .toggle-line-break-grey {
5
+ border-bottom: 1px solid #D1D1D1;
6
+ }
4
7
  .toggle-section-collapse {
5
8
  .toggle-section-collapse-header {
6
9
  width: 100%;
@@ -642,7 +642,7 @@ $iconWidth:20px;
642
642
  float: left;
643
643
  outline: 1px solid ;
644
644
  outline-offset: -1px;
645
- padding: 0 0 0 1rem;
645
+ padding: 0 0 0 1rem !important;
646
646
  }
647
647
 
648
648