-
-
Notifications
You must be signed in to change notification settings - Fork 384
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use validation rule in password form
- Loading branch information
Showing
4 changed files
with
103 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,28 @@ | ||
# See https://pre-commit.com for more information | ||
# See https://pre-commit.com/hooks.html for more hooks | ||
repos: | ||
- repo: local | ||
- repo: local | ||
hooks: | ||
- id: pylint | ||
- id: pylint | ||
name: pylint | ||
entry: pylint | ||
language: system | ||
types: [python] | ||
args: | ||
[ | ||
"-rn", | ||
"-sn", | ||
"--fail-under=5" | ||
] | ||
- repo: https://github.com/psf/black | ||
rev: '24.2.0' | ||
args: ["-rn", "-sn", "--fail-under=5"] | ||
- repo: https://github.com/psf/black | ||
rev: "24.2.0" | ||
hooks: | ||
- id: black | ||
- repo: https://github.com/pre-commit/mirrors-eslint | ||
rev: 'v9.0.0-beta.0' | ||
- id: black | ||
- repo: https://github.com/pre-commit/mirrors-eslint | ||
rev: "v9.0.0-beta.0" | ||
hooks: | ||
- id: eslint | ||
- id: eslint | ||
files: \.(js|vue)$ | ||
types: [file] | ||
additional_dependencies: | ||
- eslint | ||
- eslint-plugin-vue | ||
- eslint | ||
- eslint-plugin-vue | ||
- repo: https://github.com/pre-commit/mirrors-prettier | ||
rev: "v4.0.0-alpha.8" # Use the sha / tag you want to point at | ||
hooks: | ||
- id: prettier |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[*.{js,jsx,ts,tsx,vue}] | ||
indent_style = space | ||
indent_size = 2 | ||
indent_size = 4 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,101 +1,112 @@ | ||
<template> | ||
<div class="text-subtitle-1 text-grey-darken-1 mb-5" :class="{ 'label--disabled': disabled }"> | ||
<div | ||
class="text-subtitle-1 text-grey-darken-1 mb-5" | ||
:class="{ 'label--disabled': disabled }" | ||
> | ||
<label class="m-label">{{ label }}</label> | ||
</div> | ||
<div class="d-flex" v-for="(lineChoices, index1) in formatedChoices" :key="index1"> | ||
<div v-for="(choice, index2) in lineChoices" | ||
:key="index2" | ||
class="choice rounded pa-10 mr-4 text-center flex-grow-0 mb-4" | ||
:class="{ 'choice--disabled': disabled, 'choice--selected': !disabled && currentChoice === choice.value }" | ||
@click="selectChoice(choice.value)" | ||
> | ||
<div | ||
v-for="(lineChoices, index1) in formatedChoices" | ||
:key="index1" | ||
class="d-flex" | ||
> | ||
<div | ||
v-for="(choice, index2) in lineChoices" | ||
:key="index2" | ||
class="choice rounded pa-10 mr-4 text-center flex-grow-0 mb-4" | ||
:class="{ | ||
'choice--disabled': disabled, | ||
'choice--selected': !disabled && currentChoice === choice.value, | ||
}" | ||
@click="selectChoice(choice.value)" | ||
> | ||
<v-icon | ||
v-if="choice.icon" | ||
class="d-block mb-2 mx-auto" | ||
:color="iconColor(choice.value)" | ||
size="x-large" | ||
:icon="choice.icon" | ||
v-if="choice.icon" | ||
class="d-block mb-2 mx-auto" | ||
:color="iconColor(choice.value)" | ||
size="x-large" | ||
:icon="choice.icon" | ||
/> | ||
<span class="text-grey-darken-1">{{ choice.label }}</span> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="js"> | ||
import { ref, onMounted, computed } from 'vue' | ||
import { ref, onMounted, computed } from "vue"; | ||
const props = defineProps({ | ||
modelValue: { type: [Number, String], default: null }, | ||
label: { type: String, default: '' }, | ||
label: { type: String, default: "" }, | ||
choices: { type: Array, default: () => [] }, | ||
disabled: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
choicesPerLine: { type: Number, default: undefined }, | ||
}) | ||
}); | ||
const emit = defineEmits(['update:modelValue']) | ||
const emit = defineEmits(["update:modelValue"]); | ||
const currentChoice = computed({ | ||
get() { | ||
return props.modelValue | ||
return props.modelValue; | ||
}, | ||
set(value) { | ||
emit('update:modelValue', value) | ||
emit("update:modelValue", value); | ||
}, | ||
}) | ||
}); | ||
const formatedChoices = ref([]) | ||
const formatedChoices = ref([]); | ||
function formatChoices() { | ||
if (props.choicesPerLine) { | ||
let sliceIndex = 0 | ||
let sliceIndex = 0; | ||
while (sliceIndex < props.choices.length) { | ||
const result = props.choices.slice( | ||
sliceIndex, | ||
sliceIndex + props.choicesPerLine | ||
) | ||
formatedChoices.value.push(result) | ||
sliceIndex += props.choicesPerLine | ||
sliceIndex + props.choicesPerLine, | ||
); | ||
formatedChoices.value.push(result); | ||
sliceIndex += props.choicesPerLine; | ||
} | ||
} else { | ||
formatedChoices.value.push(props.choices) | ||
formatedChoices.value.push(props.choices); | ||
} | ||
} | ||
function iconColor(value) { | ||
return !props.disabled && value === currentChoice.value ? 'primary' : '' | ||
return !props.disabled && value === currentChoice.value ? "primary" : ""; | ||
} | ||
function selectChoice(value) { | ||
if (props.disabled) { | ||
return | ||
return; | ||
} | ||
currentChoice.value = value | ||
currentChoice.value = value; | ||
} | ||
onMounted(() => { | ||
formatChoices() | ||
}) | ||
formatChoices(); | ||
}); | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
.choice { | ||
flex-basis: 200px; | ||
background-color: #f2f5f7; | ||
border: 1px solid #dbdddf; | ||
cursor: pointer; | ||
.choice { | ||
flex-basis: 200px; | ||
background-color: #f2f5f7; | ||
border: 1px solid #dbdddf; | ||
cursor: pointer; | ||
&--selected { | ||
border-color: #046bf8 !important; | ||
} | ||
&--selected { | ||
border-color: #046bf8 !important; | ||
} | ||
&--disabled { | ||
cursor: unset; | ||
opacity: 0.5; | ||
} | ||
} | ||
.label--disabled { | ||
opacity: 0.5; | ||
} | ||
&--disabled { | ||
cursor: unset; | ||
opacity: 0.5; | ||
} | ||
} | ||
.label--disabled { | ||
opacity: 0.5; | ||
} | ||
</style> |