Skip to content

Commit

Permalink
refactor(components): dimi-input, dimi-textarea
Browse files Browse the repository at this point in the history
  • Loading branch information
junhoyeo committed Oct 13, 2019
1 parent db06013 commit 95d8bbc
Show file tree
Hide file tree
Showing 4 changed files with 155 additions and 31 deletions.
61 changes: 61 additions & 0 deletions src/components/DimiInput.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<script>
export default {
name: 'DimiInput',
props: {
value: {
type: [String, Number],
default: ''
},
type: {
type: String,
default: 'text'
},
placeholder: {
type: String,
default: ''
}
},
data () {
return {
innerValue: this.value
}
},
watch: {
value (v) {
this.innerValue = v
},
innerValue (v) {
this.$emit('input', v)
}
},
methods: {
emitEnter () {
this.$emit('enter')
}
}
}
</script>

<template>
<input
v-model="innerValue"
:type="type"
:placeholder="placeholder"
@keyup.enter="emitEnter"
>
</template>

<style lang="scss" scoped>
input {
background-color: #fae7f1;
border: none;
border-radius: 24px;
font-size: 1.1rem;
padding: 1rem 1.2rem;
&:active,
&:focus {
outline: none;
}
}
</style>
50 changes: 50 additions & 0 deletions src/components/DimiTextarea.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<script>
export default {
name: 'DimiTextarea',
props: {
value: {
type: [String, Number],
default: ''
},
placeholder: {
type: String,
default: ''
}
},
data () {
return {
innerValue: this.value
}
},
watch: {
value (v) {
this.innerValue = v
},
innerValue (v) {
this.$emit('input', v)
}
}
}
</script>

<template>
<textarea
v-model="innerValue"
:placeholder="placeholder"
/>
</template>

<style lang="scss" scoped>
textarea {
background-color: #fae7f1;
border: none;
border-radius: 24px;
font-size: 1.1rem;
padding: 1rem 1.2rem;
&:active,
&:focus {
outline: none;
}
}
</style>
42 changes: 18 additions & 24 deletions src/pages/Login.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<script>
import DimiButton from '../components/DimiButton'
import DimiCard from '../components/DimiCard'
import DimiInput from '../components/DimiInput'
export default {
name: 'Login',
components: {
DimiButton,
DimiCard
DimiCard,
DimiInput
},
props: {
redirect: {
Expand Down Expand Up @@ -70,15 +72,17 @@ export default {
class="login__form"
>
<div class="login__form-content">
<input
<dimi-input
class="login__input"
v-model="form.email"
placeholder="디미고 아이디"
>
<input
/>
<dimi-input
class="login__input"
v-model="form.password"
placeholder="패스워드"
type="password"
>
/>
</div>
<dimi-button
:onClick="onClickLogin"
Expand Down Expand Up @@ -256,31 +260,21 @@ export default {
}
}
&__input {
margin-top: 0.8rem;
width: 80%;
@media (max-width: 400px) {
width: unset;
}
}
&__form {
&-content {
display: flex;
flex-direction: column;
}
input {
width: 80%;
background-color: #fae7f1;
border: none;
border-radius: 24px;
font-size: 1.1rem;
padding: 1rem 1.2rem;
margin-top: 0.8rem;
@media (max-width: 400px) {
width: unset;
}
&:active,
&:focus {
outline: none;
}
}
}
}
</style>
33 changes: 26 additions & 7 deletions src/pages/Write.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
<script>
import DimiButton from '../components/DimiButton'
import DimiHeader from '@/components/DimiHeader'
import DimiInput from '../components/DimiInput'
import DimiTextarea from '../components/DimiTextarea'
export default {
name: 'Write',
components: {
DimiHeader
DimiButton,
DimiHeader,
DimiInput,
DimiTextarea
},
data () {
return {
Expand Down Expand Up @@ -38,13 +44,15 @@ export default {
<h1 class="write__title">
청원하기
</h1>
<div class="form">
<input v-model="post.name" placeholder="제목" />
<textarea v-model="post.content" placeholder="내용" />
<input v-model="post.image" placeholder="이미지 URL" />
<input v-model="post.topic" placeholder="분류" />
<div class="write__form">
<dimi-input v-model="post.name" placeholder="제목" />
<dimi-textarea v-model="post.content" placeholder="내용" />
<dimi-input v-model="post.image" placeholder="이미지 URL" />
<dimi-input v-model="post.topic" placeholder="분류" />
</div>
<button @click="onClickSubmit">청원하기</button>
<dimi-button :onClick="onClickSubmit">
WRITE
</dimi-button>
</div>
</div>
</div>
Expand All @@ -71,5 +79,16 @@ export default {
padding-bottom: 1rem;
border-bottom: 1px solid #868e96;
}
&__form {
width: 80%;
display: flex;
flex-direction: column;
input,
textarea {
margin-top: 0.8rem;
}
}
}
</style>

0 comments on commit 95d8bbc

Please sign in to comment.