docs_vue2/components/OneEditLink.vue

111 lines
1.8 KiB
Vue
Raw Normal View History

2021-10-22 18:51:49 +08:00
<template>
<a
class="one-edit-link"
2021-10-25 20:18:05 +08:00
:class="
variant
? {
[`one-edit-link-${variant}`]: true,
}
: {}
"
2021-10-22 18:51:49 +08:00
:href="href"
target="_blank"
rel="noopener"
>
2021-10-25 20:18:05 +08:00
<slot :label="t('editOnGitHub')">
2022-02-23 20:19:58 +08:00
<span class="full">{{ t('editOnGitHub', { item: t(type) }) }}</span>
<span class="short">{{ t('edit') }}</span>
2021-10-25 20:18:05 +08:00
<veui-icon
class="icon"
name="external-link"
/>
</slot>
2021-10-22 18:51:49 +08:00
</a>
</template>
<script>
import { Icon } from 'veui'
import i18n from 'veui/mixins/i18n'
import 'veui-theme-dls-icons/external-link'
const BASE_URL = 'https://github.com/ecomfe/veui-docs/edit/master/one/docs/'
export default {
name: 'one-edit-link',
components: {
'veui-icon': Icon
},
mixins: [i18n],
props: {
2021-10-25 20:18:05 +08:00
variant: {
type: String,
default: 'default'
},
2022-02-23 20:19:58 +08:00
path: String,
type: {
type: String,
default: 'page'
}
2021-10-22 18:51:49 +08:00
},
computed: {
href () {
return `${BASE_URL}${this.path}`
}
}
}
</script>
<style lang="stylus" scoped>
.one-edit-link
display inline-flex
align-items center
2021-10-22 18:51:49 +08:00
text-decoration none
2021-10-25 20:18:05 +08:00
transition background 0.2s, color 0.2s, border-color 0.2s
.icon
margin-left 4px
2021-10-25 20:18:05 +08:00
&-default
display inline-flex
align-items center
padding 4px 6px
border-radius 4px
background-color #fff
color #848b99
border 1px solid #e2e6f0
&:hover
&[data-focus-visible-added]
background-color #f6f7fa
color #282c33
border-color #d3d9e6
&:active
background-color #e2e6f0
color #000
border-color #d3d9e6
&-quiet
2021-10-22 18:51:49 +08:00
color #282c33
2021-10-25 20:18:05 +08:00
&:hover
&[data-focus-visible-added]
color #545b66
2021-10-22 18:51:49 +08:00
2021-10-25 20:18:05 +08:00
&:active
color #000
.full
display inline
2021-11-22 15:57:07 +08:00
.short
display none
@media (max-width 480px)
.one-edit-link-quiet
.full
display none
.short
display inline
2021-10-22 18:51:49 +08:00
</style>