feat: add size property to group-tabs component

This commit is contained in:
purocean
2024-11-22 20:07:11 +08:00
parent d75a0ebec6
commit f15ec20cc0
5 changed files with 30 additions and 41 deletions
+3 -11
View File
@@ -4,7 +4,7 @@
<div class="history">
<div class="versions-wrapper" v-if="versions && versions.length">
<div v-if="listType === 'all'" class="clear" @click="clearVersions">{{$t('doc-history.clear')}}({{sizeText}})</div>
<GroupTabs class="tabs" :tabs="getListTypes()" v-model="listType" />
<group-tabs class="x-tabs" size="small" :tabs="getListTypes()" v-model="listType" />
<div class="versions" v-if="xVersions && xVersions.length">
<div
v-for="(version, i) in xVersions"
@@ -31,7 +31,7 @@
</div>
</div>
<div class="content" v-if="content">
<GroupTabs class="tabs" :tabs="getDisplayTypes()" v-model="displayType" />
<group-tabs class="x-tabs" size="small" :tabs="getDisplayTypes()" v-model="displayType" />
<div class="diff-tips" v-if="displayType === 'diff'">
<div>{{$t('doc-history.history')}}</div>
<div>{{$t('doc-history.current')}}</div>
@@ -524,16 +524,8 @@ onUnmounted(() => {
pointer-events: none;
}
.tabs {
display: inline-flex;
.versions-wrapper .x-tabs {
margin-bottom: 8px;
z-index: 1;
flex: none;
::v-deep(.tab) {
line-height: 1.5;
font-size: 14px;
}
}
.content {
+3 -11
View File
@@ -3,7 +3,7 @@
<div class="wrapper">
<div class="body">
<div class="side" ref="refSide">
<group-tabs class="tabs" :tabs="listTypes" v-model="listType" />
<group-tabs class="x-tabs" size="small" :tabs="listTypes" v-model="listType" />
<div v-if="extensions.length > 0" class="list">
<div
v-for="item in extensions"
@@ -157,7 +157,7 @@
</div>
</div>
<div class="content-wrapper">
<group-tabs class="tabs" :tabs="contentTypes" v-model="contentType" />
<group-tabs class="x-tabs" size="small" :tabs="contentTypes" v-model="contentType" />
<template v-if="useNpmjsReadmePage">
<div v-show="iframeLoaded" class="content">
<iframe
@@ -806,16 +806,8 @@ onUnmounted(() => {
}
}
.tabs {
display: inline-flex;
.wrapper .body .x-tabs {
margin-bottom: 8px;
z-index: 1;
flex: none;
::v-deep(.tab) {
line-height: 1.5;
font-size: 14px;
}
}
.icon-extension {
+17 -4
View File
@@ -1,5 +1,5 @@
<template>
<div class="tabs">
<div :class="{ tabs: true, small: size === 'small' }">
<div
v-for="tab of tabs"
:key="tab.value"
@@ -12,15 +12,15 @@
<script lang="ts">
import { defineComponent } from 'vue'
type Tab = { label: string, value: string }
import type { LabelValueItem } from '@share/types'
export default defineComponent({
name: 'group-tabs',
props: {
modelValue: String,
size: String as () => 'small',
tabs: {
type: Array as () => Tab[],
type: Array as () => LabelValueItem<string>[],
required: true,
}
},
@@ -56,6 +56,19 @@ export default defineComponent({
background: var(--g-color-94);
}
}
&.small {
display: inline-flex;
margin-bottom: 0;
z-index: 1;
flex: none;
justify-self: center;
.tab {
line-height: 1.5;
font-size: 14px;
}
}
}
@include dark-theme {
+1 -14
View File
@@ -3,7 +3,7 @@
<div class="wrapper">
<div class="title-bar">
<h3>{{ $t('keyboard-shortcuts.keyboard-shortcuts') }}</h3>
<group-tabs :tabs="tabs" v-model="tab" />
<group-tabs :tabs="tabs" size="small" v-model="tab" />
<input v-model="filterStr" :placeholder="$t('keyboard-shortcuts.search')" />
</div>
<div class="list" ref="listRef">
@@ -413,19 +413,6 @@ onUnmounted(() => {
max-width: 200px;
font-size: 14px !important;
}
.tabs {
display: inline-flex;
margin-bottom: 0;
z-index: 1;
flex: none;
justify-self: center;
::v-deep(.tab) {
line-height: 1.5;
font-size: 14px;
}
}
}
.list {
+6 -1
View File
@@ -3,6 +3,11 @@ export interface PathItem {
path: string;
}
export interface LabelValueItem<T> {
label: string;
value: T;
}
export interface FileItem extends PathItem { name: string }
export interface FileStat {
@@ -35,5 +40,5 @@ export interface Doc extends PathItem {
export interface Repo {
name: string;
path: string;
enableIndexing: boolean
enableIndexing: boolean;
}