Add base input component
This commit is contained in:
parent
fd719a0235
commit
d47aaf66c1
|
@ -2,7 +2,7 @@
|
||||||
<div>
|
<div>
|
||||||
<div v-if="showInput">
|
<div v-if="showInput">
|
||||||
<form @submit.prevent="addTL">
|
<form @submit.prevent="addTL">
|
||||||
<input type="text" placeholder="e.g:mstdn.jp" v-model="instance">
|
<BaseInputText placeholder="e.g:mstdn.jp" v-model="instance"/>
|
||||||
<BaseButton
|
<BaseButton
|
||||||
type="submit"
|
type="submit"
|
||||||
class="primary fill"
|
class="primary fill"
|
||||||
|
@ -169,24 +169,6 @@ export default class AddColumn extends Vue {
|
||||||
</script>=
|
</script>=
|
||||||
|
|
||||||
<style scoped lang="postcss">
|
<style scoped lang="postcss">
|
||||||
input {
|
|
||||||
color: var(--color);
|
|
||||||
background-color: transparent;
|
|
||||||
font-size: var(--font-size);
|
|
||||||
border: none;
|
|
||||||
border-bottom: 1px solid #9e9e9e;
|
|
||||||
border-radius: 0;
|
|
||||||
line-height: 3em;
|
|
||||||
width: 80%;
|
|
||||||
outline: none;
|
|
||||||
margin: 1em;
|
|
||||||
|
|
||||||
transition-duration: 0.5s;
|
|
||||||
|
|
||||||
&:focus {
|
|
||||||
border-color: #26d69a;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#timelines {
|
#timelines {
|
||||||
display: flex;
|
display: flex;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
<template>
|
<template>
|
||||||
<form @submit.prevent="authCode" v-if="inputCode">
|
<form @submit.prevent="authCode" v-if="inputCode">
|
||||||
<input type="text" placeholder="input code" v-model="code">
|
<BaseInputText placeholder="input code" v-model="code"/>
|
||||||
<BaseButton
|
<BaseButton
|
||||||
type="submit"
|
type="submit"
|
||||||
class="primary fill"
|
class="primary fill"
|
||||||
style="--font-size:.8em;"
|
style="--font-size:.8em;"
|
||||||
:disabled="!hasDomain"
|
:disabled="this.code === ''"
|
||||||
>Auth</BaseButton>
|
>Auth</BaseButton>
|
||||||
</form>
|
</form>
|
||||||
<form @submit.prevent="addAccount" v-else>
|
<form @submit.prevent="addAccount" v-else>
|
||||||
<input type="text" placeholder="e.g:mstdn.jp" v-model="instance">
|
<BaseInputText placeholder="e.g:mstdn.jp" v-model="domain"/>
|
||||||
<BaseButton
|
<BaseButton
|
||||||
type="submit"
|
type="submit"
|
||||||
class="primary fill"
|
class="primary fill"
|
||||||
style="--font-size:.8em;"
|
style="--font-size:.8em;"
|
||||||
:disabled="!hasDomain"
|
:disabled="this.domain === ''"
|
||||||
>Login</BaseButton>
|
>Login</BaseButton>
|
||||||
</form>
|
</form>
|
||||||
</template>
|
</template>
|
||||||
|
@ -24,41 +24,26 @@ import { Component, Vue } from "vue-property-decorator"
|
||||||
type Instance = string
|
type Instance = string
|
||||||
@Component
|
@Component
|
||||||
export default class Auth extends Vue {
|
export default class Auth extends Vue {
|
||||||
public instance: Instance = ""
|
public instance: Instance = ''
|
||||||
public inputCode: boolean = false
|
public code: string = ''
|
||||||
public code: string
|
public domain: string = ''
|
||||||
public get hasDomain() {
|
|
||||||
return this.instance != ""
|
public get inputCode(): boolean {
|
||||||
|
return this.instance !== ''
|
||||||
}
|
}
|
||||||
|
|
||||||
public addAccount() {
|
public addAccount() {
|
||||||
let target = this.instance
|
this.instance = this.domain
|
||||||
this.inputCode = true
|
this.domain = ''
|
||||||
ipcRenderer.send(`new-account-setup`, target)
|
ipcRenderer.send(`new-account-setup`, this.instance)
|
||||||
}
|
}
|
||||||
public authCode() {
|
public authCode() {
|
||||||
let code = this.code
|
let code = this.code
|
||||||
this.inputCode = true
|
|
||||||
ipcRenderer.send(`new-account-auth`, code, this.instance)
|
ipcRenderer.send(`new-account-auth`, code, this.instance)
|
||||||
|
this.instance = ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="postcss">
|
<style scoped lang="postcss">
|
||||||
input {
|
|
||||||
color: var(--color);
|
|
||||||
background-color: transparent;
|
|
||||||
font-size: var(--font-size);
|
|
||||||
border: none;
|
|
||||||
border-bottom: 1px solid #9e9e9e;
|
|
||||||
border-radius: 0;
|
|
||||||
line-height: 3em;
|
|
||||||
width: 80%;
|
|
||||||
outline: none;
|
|
||||||
margin: 1em;
|
|
||||||
|
|
||||||
transition-duration: 0.5s;
|
|
||||||
|
|
||||||
&:focus {
|
|
||||||
border-color: #26d69a;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
43
src/components/globals/BaseInputText.vue
Normal file
43
src/components/globals/BaseInputText.vue
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
<template>
|
||||||
|
<input type="text" :placeholder="placeholder" v-model="input">
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import { Component, Prop, Vue } from 'vue-property-decorator'
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
inheritAttrs: false,
|
||||||
|
})
|
||||||
|
export default class BaseInputText extends Vue {
|
||||||
|
@Prop() public placeholder!: string
|
||||||
|
@Prop() public value!: string
|
||||||
|
|
||||||
|
public get input(): string {
|
||||||
|
return this.value
|
||||||
|
}
|
||||||
|
public set input(newValue) {
|
||||||
|
this.$emit('input', newValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="postcss">
|
||||||
|
input {
|
||||||
|
color: var(--color);
|
||||||
|
background-color: transparent;
|
||||||
|
font-size: var(--font-size);
|
||||||
|
border: none;
|
||||||
|
border-bottom: 1px solid #9e9e9e;
|
||||||
|
border-radius: 0;
|
||||||
|
line-height: 3em;
|
||||||
|
width: 80%;
|
||||||
|
outline: none;
|
||||||
|
margin: 1em;
|
||||||
|
|
||||||
|
transition-duration: 0.5s;
|
||||||
|
|
||||||
|
&:focus {
|
||||||
|
border-color: #26d69a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -32,6 +32,7 @@ export default class Auth {
|
||||||
console.log(appData)
|
console.log(appData)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.catch((err: Error) => console.error(err))
|
||||||
})
|
})
|
||||||
ipcMain.on("new-account-auth", async (event: Event, code: string, instance: string) => {
|
ipcMain.on("new-account-auth", async (event: Event, code: string, instance: string) => {
|
||||||
Mastodon.fetchAccessToken(clientId, clientSecret, code, "https://" + instance)
|
Mastodon.fetchAccessToken(clientId, clientSecret, code, "https://" + instance)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user