forked from halo-dev/halo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pref: created ReactiveButton component. (halo-dev/console#216)
* pref: created ReactiveButton component. * refactor: ReactiveButton. * refactor: Profile page. * feat: add form validate for comment reply. * refactor: PostSettingsDrawer.
- Loading branch information
Showing
40 changed files
with
1,202 additions
and
576 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
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 |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<template> | ||
<a-button | ||
:type="computedType" | ||
@click="handleClick" | ||
:icon="computedIcon" | ||
:loading="loading" | ||
>{{ computedText }}</a-button> | ||
</template> | ||
<script> | ||
export default { | ||
name: 'ReactiveButton', | ||
props: { | ||
type: { | ||
type: String, | ||
default: 'primary' | ||
}, | ||
icon: { | ||
type: String, | ||
default: null | ||
}, | ||
loading: { | ||
type: Boolean, | ||
default: false | ||
}, | ||
errored: { | ||
type: Boolean, | ||
default: false | ||
}, | ||
text: { | ||
type: String, | ||
default: '' | ||
}, | ||
loadedText: { | ||
type: String, | ||
default: '' | ||
}, | ||
erroredText: { | ||
type: String, | ||
default: '' | ||
} | ||
}, | ||
data() { | ||
return { | ||
loaded: false, | ||
hasError: false | ||
} | ||
}, | ||
watch: { | ||
loading(value) { | ||
if (!value) { | ||
this.loaded = true | ||
if (this.errored) { | ||
this.hasError = true | ||
} | ||
setTimeout(() => { | ||
this.loaded = false | ||
this.hasError = false | ||
this.$emit('callback') | ||
}, 800) | ||
} | ||
} | ||
}, | ||
computed: { | ||
computedType() { | ||
if (this.loaded) { | ||
return this.hasError ? 'danger' : this.type | ||
} | ||
return this.type | ||
}, | ||
computedIcon() { | ||
if (this.loaded) { | ||
return this.hasError ? 'close-circle' : 'check-circle' | ||
} | ||
return this.icon | ||
}, | ||
computedText() { | ||
if (this.loaded) { | ||
return this.hasError ? this.erroredText : this.loadedText | ||
} | ||
return this.text | ||
} | ||
}, | ||
methods: { | ||
handleClick() { | ||
this.$emit('click') | ||
} | ||
} | ||
} | ||
</script> |
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
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
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
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
Oops, something went wrong.