Skip to content

Commit

Permalink
Update options.js to include basic-circle - Update style immediately …
Browse files Browse the repository at this point in the history
…without Try it button
  • Loading branch information
Alessio committed May 6, 2024
1 parent d9a596d commit 6f3088d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
1 change: 0 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
<select class="form-control form-control-sm" v-model="selectedEffect">
<option v-for="effect in effectList" :value="effect">{{effect}}</option>
</select>
<button class="btn btn-mm-dark magic-hover magic-hover__square" @click="changeEffect()">Try it</button>
</div>

</div>
Expand Down
1 change: 1 addition & 0 deletions src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const app = createApp({
watch: {
selectedEffect() {
this.setSelectedEffect()
this.changeEffect()
},
},
})
Expand Down
24 changes: 12 additions & 12 deletions src/js/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const allowedTypes = [
type: 'enum',
required: false,
default: 'circle',
allowed: ['circle', 'square', 'diamond', 'disable']
allowed: ['circle', 'square', 'diamond', 'disable', 'circle-basic']
},
{
name: 'hoverEffect',
Expand Down Expand Up @@ -48,10 +48,10 @@ export default class Options {
this.defaultOptions = this.generateDefault()

// push user's options to default options one-by-one:
for(let key in options) {
for(let key in options) {
if(this.isValid(key, options[key])) {
this.defaultOptions[key] = options[key]
}
}
}

return this.defaultOptions
Expand All @@ -66,28 +66,28 @@ export default class Options {

let output = {}
for(let key of acceptedKey) {
output[key] = this.getOptionByKey(key)['default']
output[key] = this.getOptionByKey(key)['default']
}

return output
}

/**
* This function is to check if an option is valid or not
* @param {String} key
* @param {Any}} value
* @param {String} key
* @param {Any}} value
* @return {Boolean}
*/
isValid(key, value) {
isValid(key, value) {
// check if key is acceptable:
const acceptedKey = pluck('name', allowedTypes)

if(!acceptedKey.includes(key)) {
// throw new Error(`${key} is not a valid option`)
console.error(`${key} is not a valid option`)
return false
}
}

// check if the type of value is valid:
const allowedOption = this.getOptionByKey(key)
let isTypeValid = false
Expand All @@ -106,11 +106,11 @@ export default class Options {
isTypeValid = false
break;
}
if(!isTypeValid) {

if(!isTypeValid) {
console.error(`${value} is not a valid value for ${key}`)
}

return isTypeValid
}

Expand Down

0 comments on commit 6f3088d

Please sign in to comment.