naive-ui/demo/utils/EditOnGithubHeader.vue

73 lines
1.2 KiB
Vue
Raw Normal View History

2020-03-19 13:26:06 +08:00
2020-03-19 18:26:48 +08:00
<i18n>
{
"zh-CN": {
2020-03-19 13:26:06 +08:00
"editOnGithub": "在 Github 上编辑"
},
2020-03-19 18:26:48 +08:00
"en-US": {
2020-03-19 13:26:06 +08:00
"editOnGithub": "Edit on Github"
2020-03-19 18:26:48 +08:00
}
}
</i18n>
2020-03-19 13:26:06 +08:00
<template>
2020-03-19 18:26:48 +08:00
<n-h1 :id="id" class="naive-doc-title">
2020-05-31 00:57:47 +08:00
<span>{{ text }}</span>
2020-03-19 18:26:48 +08:00
<span class="edit-button">
<n-tooltip
:delay="300"
2020-05-31 00:57:47 +08:00
placement="left"
2020-03-19 18:26:48 +08:00
:show-arrow="true"
>
<template v-slot:activator>
<edit-on-github-button
text
size="large"
class="edit-button"
:url="url"
/>
</template>
{{ $t('editOnGithub') }}
</n-tooltip>
</span>
2020-03-19 13:26:06 +08:00
</n-h1>
</template>
2020-03-19 18:26:48 +08:00
2020-03-19 13:26:06 +08:00
<script>
export default {
name: 'EditOnGithubHeader',
props: {
url: {
type: String,
required: true
},
text: {
type: String,
required: true
}
},
computed: {
id () {
return this.text.replace(/ /g, '-')
}
}
}
</script>
2020-03-19 18:26:48 +08:00
<style scoped>
2020-05-31 00:57:47 +08:00
.naive-doc-title {
display: flex;
justify-content: space-between;
}
2020-03-19 18:26:48 +08:00
.naive-doc-title .edit-button {
display: inline-flex;
align-items: center;
}
2020-05-30 21:11:46 +08:00
/*
2020-03-19 18:26:48 +08:00
.naive-doc-title:hover .edit-button {
opacity: 1;
transition: opacity .3s ease-out;
2020-05-30 21:11:46 +08:00
} */
2020-03-19 13:26:06 +08:00
</style>