feat: add reusable button and input components
This commit is contained in:
parent
db1ac0c64a
commit
c8d56fe0b2
71
frontend/src/components/Button.vue
Normal file
71
frontend/src/components/Button.vue
Normal file
@ -0,0 +1,71 @@
|
||||
<template>
|
||||
<button :class="classes" @click="$emit('click')">
|
||||
<slot></slot>
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "Button",
|
||||
|
||||
props: {
|
||||
type: {
|
||||
type: String,
|
||||
default: "primary",
|
||||
validator: (value) => ["primary", "secondary", "link"].includes(value),
|
||||
},
|
||||
|
||||
size: {
|
||||
type: String,
|
||||
default: "normal",
|
||||
validator: (value) => ["none", "normal", "large"].includes(value),
|
||||
},
|
||||
|
||||
fullWidth: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
|
||||
computed: {
|
||||
classes() {
|
||||
return [
|
||||
`app-button app-button--${this.type} app-button--${this.size}`,
|
||||
{ "app-button--full-width": this.fullWidth },
|
||||
{ "app-button--loading": this.loading },
|
||||
];
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.app-button {
|
||||
border: 0;
|
||||
outline: 0;
|
||||
cursor: pointer;
|
||||
padding: 0.5em 1em;
|
||||
border-radius: 0.1em;
|
||||
transition: background-color 0.3s ease;
|
||||
border: 1px solid rgba(0, 0, 0, 0.05);
|
||||
box-shadow: 0 0 5px rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.app-button:hover {
|
||||
background-color: var(--dark-blue);
|
||||
}
|
||||
|
||||
.app-button--primary {
|
||||
color: #ffffff;
|
||||
background-color: var(--blue);
|
||||
}
|
||||
|
||||
.app-button--normal {
|
||||
height: 3rem;
|
||||
border-radius: 0.5rem;
|
||||
}
|
||||
|
||||
.app-button--full-width {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
39
frontend/src/components/Input.vue
Normal file
39
frontend/src/components/Input.vue
Normal file
@ -0,0 +1,39 @@
|
||||
<template>
|
||||
<input :type="type" class="app-input" @input="handleInput" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "Input",
|
||||
|
||||
props: {
|
||||
type: {
|
||||
type: String,
|
||||
default: "text",
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
handleInput(e) {
|
||||
this.$emit("input", e.target.value);
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.app-input {
|
||||
margin: 0;
|
||||
height: 48px;
|
||||
outline: none;
|
||||
padding: 0 1rem;
|
||||
color: #333333;
|
||||
border-radius: 0.5rem;
|
||||
transition: border 0.3s ease;
|
||||
border: 1px solid rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.app-input:is(:hover, :focus) {
|
||||
border: 1px solid rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
</style>
|
||||
Loading…
Reference in New Issue
Block a user