style(editor): 统一左边栏搜索样式

This commit is contained in:
roymondchen 2023-03-30 16:30:04 +08:00
parent aa12779598
commit ffb99645d6
9 changed files with 65 additions and 68 deletions

View File

@ -0,0 +1,26 @@
<template>
<TMagicInput
v-model="filterText"
class="search-input"
size="small"
placeholder="输入关键字进行过滤"
clearable
:prefix-icon="Search"
@input="filterTextChangeHandler"
></TMagicInput>
</template>
<script setup lang="ts">
import { ref } from 'vue';
import { Search } from '@element-plus/icons-vue';
import { TMagicInput } from '@tmagic/design';
const emit = defineEmits(['search']);
const filterText = ref('');
const filterTextChangeHandler = () => {
emit('search', filterText.value);
};
</script>

View File

@ -3,14 +3,7 @@
<slot name="component-list-panel-header"></slot> <slot name="component-list-panel-header"></slot>
<TMagicCollapse class="ui-component-panel" :model-value="collapseValue"> <TMagicCollapse class="ui-component-panel" :model-value="collapseValue">
<TMagicInput <SearchInput @search="filterTextChangeHandler"></SearchInput>
placeholder="输入关键字进行过滤"
class="search-input"
size="small"
clearable
:prefix-icon="Search"
v-model="searchText"
/>
<template v-for="(group, index) in list"> <template v-for="(group, index) in list">
<TMagicCollapseItem v-if="group.items && group.items.length" :key="index" :name="`${index}`"> <TMagicCollapseItem v-if="group.items && group.items.length" :key="index" :name="`${index}`">
<template #title><MIcon :icon="Grid"></MIcon>{{ group.title }}</template> <template #title><MIcon :icon="Grid"></MIcon>{{ group.title }}</template>
@ -40,16 +33,22 @@
<script lang="ts" setup name="MEditorComponentListPanel"> <script lang="ts" setup name="MEditorComponentListPanel">
import { computed, inject, ref } from 'vue'; import { computed, inject, ref } from 'vue';
import { Grid, Search } from '@element-plus/icons-vue'; import { Grid } from '@element-plus/icons-vue';
import serialize from 'serialize-javascript'; import serialize from 'serialize-javascript';
import { TMagicCollapse, TMagicCollapseItem, TMagicInput, TMagicScrollbar, TMagicTooltip } from '@tmagic/design'; import { TMagicCollapse, TMagicCollapseItem, TMagicScrollbar, TMagicTooltip } from '@tmagic/design';
import { removeClassNameByClassName } from '@tmagic/utils'; import { removeClassNameByClassName } from '@tmagic/utils';
import MIcon from '../../components/Icon.vue'; import MIcon from '../../components/Icon.vue';
import SearchInput from '../../components/SearchInput.vue';
import type { ComponentGroup, ComponentItem, Services, StageOptions } from '../../type'; import type { ComponentGroup, ComponentItem, Services, StageOptions } from '../../type';
const searchText = ref(''); const searchText = ref('');
const filterTextChangeHandler = (v: string) => {
searchText.value = v;
};
const services = inject<Services>('services'); const services = inject<Services>('services');
const stageOptions = inject<StageOptions>('stageOptions'); const stageOptions = inject<StageOptions>('stageOptions');

View File

@ -2,15 +2,7 @@
<TMagicScrollbar class="magic-editor-layer-panel"> <TMagicScrollbar class="magic-editor-layer-panel">
<slot name="layer-panel-header"></slot> <slot name="layer-panel-header"></slot>
<TMagicInput <SearchInput @search="filterTextChangeHandler"></SearchInput>
v-model="filterText"
class="search-input"
size="small"
placeholder="输入关键字进行过滤"
clearable
:prefix-icon="Search"
@change="filterTextChangeHandler"
></TMagicInput>
<TMagicTree <TMagicTree
v-if="values.length" v-if="values.length"
@ -58,15 +50,15 @@
<script lang="ts" setup name="MEditorLayerPanel"> <script lang="ts" setup name="MEditorLayerPanel">
import { computed, inject, onMounted, onUnmounted, ref, watch } from 'vue'; import { computed, inject, onMounted, onUnmounted, ref, watch } from 'vue';
import { Search } from '@element-plus/icons-vue';
import KeyController from 'keycon'; import KeyController from 'keycon';
import { difference, throttle, union } from 'lodash-es'; import { difference, throttle, union } from 'lodash-es';
import { TMagicInput, TMagicScrollbar, TMagicTree } from '@tmagic/design'; import { TMagicScrollbar, TMagicTree } from '@tmagic/design';
import type { Id, MNode, MPage } from '@tmagic/schema'; import type { Id, MNode, MPage } from '@tmagic/schema';
import { MContainer, NodeType } from '@tmagic/schema'; import { MContainer, NodeType } from '@tmagic/schema';
import { getNodePath, isPage } from '@tmagic/utils'; import { getNodePath, isPage } from '@tmagic/utils';
import SearchInput from '../../components/SearchInput.vue';
import type { MenuButton, MenuComponent, Services } from '../../type'; import type { MenuButton, MenuComponent, Services } from '../../type';
import { Layout } from '../../type'; import { Layout } from '../../type';
@ -87,7 +79,6 @@ const menu = ref<InstanceType<typeof LayerMenu>>();
const checkedKeys = ref<Id[]>([]); const checkedKeys = ref<Id[]>([]);
// //
const isCtrlKeyDown = ref(false); const isCtrlKeyDown = ref(false);
const filterText = ref('');
// //
const expandedKeys = ref<Id[]>([]); const expandedKeys = ref<Id[]>([]);
const currentNodeKey = ref<Id>(); const currentNodeKey = ref<Id>();

View File

@ -2,14 +2,7 @@
<div class="m-editor-code-block-list"> <div class="m-editor-code-block-list">
<slot name="code-block-panel-header"> <slot name="code-block-panel-header">
<div class="code-header-wrapper"> <div class="code-header-wrapper">
<TMagicInput <SearchInput @search="filterTextChangeHandler"></SearchInput>
:class="[editable ? 'code-filter-input' : 'code-filter-input-no-btn']"
size="small"
placeholder="输入关键字进行过滤"
clearable
v-model="filterText"
@input="filterTextChangeHandler"
></TMagicInput>
<TMagicButton class="create-code-button" type="primary" size="small" @click="createCodeBlock" v-if="editable" <TMagicButton class="create-code-button" type="primary" size="small" @click="createCodeBlock" v-if="editable"
>新增</TMagicButton >新增</TMagicButton
> >
@ -63,11 +56,12 @@
import { computed, inject, ref } from 'vue'; import { computed, inject, ref } from 'vue';
import { Close, Edit, View } from '@element-plus/icons-vue'; import { Close, Edit, View } from '@element-plus/icons-vue';
import { TMagicButton, TMagicInput, tMagicMessage, TMagicScrollbar, TMagicTooltip, TMagicTree } from '@tmagic/design'; import { TMagicButton, tMagicMessage, TMagicScrollbar, TMagicTooltip, TMagicTree } from '@tmagic/design';
import { ColumnConfig } from '@tmagic/form'; import { ColumnConfig } from '@tmagic/form';
import { CodeBlockContent, Id } from '@tmagic/schema'; import { CodeBlockContent, Id } from '@tmagic/schema';
import Icon from '../../../components/Icon.vue'; import Icon from '../../../components/Icon.vue';
import SearchInput from '../../../components/SearchInput.vue';
import { CodeDeleteErrorType, CodeDslItem, Services } from '../../../type'; import { CodeDeleteErrorType, CodeDslItem, Services } from '../../../type';
import CodeBlockEditor from './CodeBlockEditor.vue'; import CodeBlockEditor from './CodeBlockEditor.vue';
@ -141,7 +135,6 @@ const deleteCode = (key: Id) => {
} }
}; };
const filterText = ref('');
const tree = ref<InstanceType<typeof TMagicTree>>(); const tree = ref<InstanceType<typeof TMagicTree>>();
const filterNode = (value: string, data: CodeDslItem): boolean => { const filterNode = (value: string, data: CodeDslItem): boolean => {

View File

@ -1,17 +1,19 @@
.m-editor-code-block-list { .m-editor-code-block-list {
height: 100%; height: 100%;
margin-top: 5px; margin-top: 48px;
.code-header-wrapper { .code-header-wrapper {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
.code-filter-input { position: absolute;
margin: 0 5px; top: 0;
} width: 100%;
.code-filter-input-no-btn {
margin-left: 5px; .search-input {
margin-right: 10px; flex: 1;
position: relative;
} }
.create-code-button { .create-code-button {
margin-left: 2px; margin-left: 2px;
margin-right: 10px; margin-right: 10px;

View File

@ -4,21 +4,6 @@
margin-top: 48px; margin-top: 48px;
background-color: $--sidebar-content-background-color; background-color: $--sidebar-content-background-color;
.search-input {
background: #fff;
color: #bbbbbb;
padding: 10px;
position: absolute;
top: 0;
left: 0;
box-sizing: border-box;
z-index: 1;
.el-input__prefix {
padding: 7px;
}
}
.tmagic-design-collapse-item { .tmagic-design-collapse-item {
> div:first-of-type { > div:first-of-type {
border-bottom: 1px solid $--border-color; border-bottom: 1px solid $--border-color;

View File

@ -1,20 +1,6 @@
.magic-editor-layer-panel { .magic-editor-layer-panel {
background: $--sidebar-content-background-color; background: $--sidebar-content-background-color;
.search-input {
background: $--sidebar-content-background-color;
color: #bbbbbb;
padding: 10px;
position: absolute;
top: 0;
left: 0;
z-index: 1;
.el-input__prefix {
padding: 7px;
}
}
.magic-editor-layer-tree { .magic-editor-layer-tree {
padding-top: 48px; padding-top: 48px;
} }

View File

@ -0,0 +1,14 @@
.tmagic-design-input.search-input {
background: #fff;
color: #bbbbbb;
padding: 10px;
position: absolute;
top: 0;
left: 0;
box-sizing: border-box;
z-index: 1;
.el-input__prefix {
padding: 7px;
}
}

View File

@ -1,3 +1,4 @@
@import "./search-input.scss";
@import "./nav-menu.scss"; @import "./nav-menu.scss";
@import "./framework.scss"; @import "./framework.scss";
@import "./sidebar.scss"; @import "./sidebar.scss";