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-icon name="one-demo-stackblitz"/>
</veui-button> </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 <veui-button
v-tooltip="t(codeExpanded ? 'hideCode' : 'showCode')" v-tooltip="t(codeExpanded ? 'hideCode' : 'showCode')"
class="toggle-source"
ui="icon" ui="icon"
@click="codeExpanded = !codeExpanded" @click="codeExpanded = !codeExpanded"
> >
@ -57,9 +45,18 @@
:name="codeExpanded ? 'one-demo-code-off' : 'one-demo-code'" :name="codeExpanded ? 'one-demo-code-off' : 'one-demo-code'"
/> />
</veui-button> </veui-button>
<veui-button
v-tooltip="t(editing ? 'closeEditor' : 'openEditor')"
class="toggle-editor"
ui="text"
@click="editing = !editing"
>
Live
</veui-button>
<one-edit-link <one-edit-link
class="edit" class="edit"
variant="quiet" variant="quiet"
type="demo"
:path="path" :path="path"
/> />
</section> </section>
@ -240,7 +237,7 @@ Icon.register({
.codeExpanded & .codeExpanded &
border-radius 0 border-radius 0
.veui-button .veui-button:not(.toggle-editor)
font-size 18px font-size 18px
.veui-button + .veui-button .veui-button + .veui-button
@ -277,13 +274,25 @@ Icon.register({
opacity 0 opacity 0
transform scale(0.99) translateY(3px) transform scale(0.99) translateY(3px)
.toggle-source .toggle-editor
display none 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) @media (max-width 480px)
.toggle-source
display inline-flex
.toggle-editor .toggle-editor
display none display none
</style> </style>

View File

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

View File

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