feat: bring back simple code toggle

This commit is contained in:
Justineo 2022-02-23 20:19:58 +08:00
parent ace60c8339
commit ec151a405a
No known key found for this signature in database
GPG Key ID: B73F0979CF18A0EA
3 changed files with 39 additions and 22 deletions

View File

@ -35,20 +35,8 @@
>
<veui-icon name="one-demo-stackblitz"/>
</veui-button>
<veui-button
v-tooltip="t(editing ? 'closeEditor' : 'openEditor')"
class="toggle-editor"
ui="icon"
@click="editing = !editing"
>
<veui-icon
scale="1.2"
:name="editing ? 'one-demo-code-off' : 'one-demo-code'"
/>
</veui-button>
<veui-button
v-tooltip="t(codeExpanded ? 'hideCode' : 'showCode')"
class="toggle-source"
ui="icon"
@click="codeExpanded = !codeExpanded"
>
@ -57,9 +45,18 @@
:name="codeExpanded ? 'one-demo-code-off' : 'one-demo-code'"
/>
</veui-button>
<veui-button
v-tooltip="t(editing ? 'closeEditor' : 'openEditor')"
class="toggle-editor"
ui="text"
@click="editing = !editing"
>
Live
</veui-button>
<one-edit-link
class="edit"
variant="quiet"
type="demo"
:path="path"
/>
</section>
@ -240,7 +237,7 @@ Icon.register({
.codeExpanded &
border-radius 0
.veui-button
.veui-button:not(.toggle-editor)
font-size 18px
.veui-button + .veui-button
@ -277,13 +274,25 @@ Icon.register({
opacity 0
transform scale(0.99) translateY(3px)
.toggle-source
display none
.toggle-editor
height 20px
padding 0 3px
font-weight 600
&::after
content none !important
&
&:hover
&[data-focus-visible-added]
&:active
border 1.5px solid currentColor !important
&[data-focus-visible-added]
border-color #0052cc !important
box-shadow 0 0 0 2px rgba(0, 102, 255, 0.2) !important
@media (max-width 480px)
.toggle-source
display inline-flex
.toggle-editor
display none
</style>

View File

@ -13,7 +13,7 @@
rel="noopener"
>
<slot :label="t('editOnGitHub')">
<span class="full">{{ t('editOnGitHub') }}</span>
<span class="full">{{ t('editOnGitHub', { item: t(type) }) }}</span>
<span class="short">{{ t('edit') }}</span>
<veui-icon
class="icon"
@ -41,7 +41,11 @@ export default {
type: String,
default: 'default'
},
path: String
path: String,
type: {
type: String,
default: 'page'
}
},
computed: {
href () {

View File

@ -113,7 +113,9 @@ i18n.register(
i18n.register(
'zh-Hans',
{
editOnGitHub: '在 GitHub 上编辑此页',
editOnGitHub: '在 GitHub 上编辑此{item}',
page: '页面',
demo: '示例',
edit: '编辑'
},
{
@ -124,7 +126,9 @@ i18n.register(
i18n.register(
'en-US',
{
editOnGitHub: 'Edit this page on GitHub',
editOnGitHub: 'Edit this {item} on GitHub',
page: 'page',
demo: 'demo',
edit: 'Edit'
},
{