Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(toolbars): use toolbar base component in toolbar plugins #798

Merged
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
1e2b563
fix(toolbars): 对于工具栏的定制化的改动,图标可替换,且可以替换展示方式(图标或按钮),同事按钮可以传入属性和样式
betterdancing Aug 12, 2024
7995809
fix(toolbars): 对于工具栏的定制化的改动,图标可替换,且可以替换展示方式(图标或按钮),同事按钮可以传入属性和样式
betterdancing Aug 12, 2024
21abd59
Merge branch 'refactor/develop' of https://github.com/betterdancing/t…
betterdancing Aug 12, 2024
e626722
fix(toolbars): 对于工具栏的定制化的改动,图标可替换,且可以替换展示方式(图标或按钮),同事按钮可以传入属性和样式
betterdancing Aug 16, 2024
49ffee5
feat: 工具栏定制化改造
betterdancing Sep 5, 2024
cc49279
feat(toolbars): 头部工具栏改造,新增公共可引入组件
betterdancing Sep 13, 2024
fe89b71
feat(toolbars): 头部工具栏改造,新增公共可引入组件
betterdancing Sep 13, 2024
612adc0
feat(toolbars): package.json添加layout依赖
betterdancing Sep 14, 2024
bedd71c
feat(toolbars): 头部工具栏改造,导出toolbar公共组件
betterdancing Sep 18, 2024
0a92bf7
feat(toolbar): 修复review意见,将配置项移动到options中
betterdancing Sep 20, 2024
4329155
feat(toolbar): 删除工具栏组件冗余属性,采用了import原组件并定制的方式扩展其余属性
betterdancing Sep 25, 2024
4e70edb
feat(toolbar): 处理工具栏代码冲突
betterdancing Sep 27, 2024
eb54ea5
feat(toolbar): 处理工具栏代码冲突
betterdancing Sep 27, 2024
c9d46de
Merge branch 'refactor/develop' of https://github.com/betterdancing/t…
betterdancing Sep 29, 2024
acd0934
feat(toolbar): 修改公共toolbar组件名称,并移到common目录下
betterdancing Sep 29, 2024
3a638cc
feat(toolbar): 修改部分review意见
betterdancing Sep 29, 2024
4393877
feat(toolbar): 默认工具栏按钮移除边框
betterdancing Sep 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/design-core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export { default as Robot } from '@opentiny/tiny-engine-plugin-robot'
export { default as Props, PropertiesService, PropertyService } from '@opentiny/tiny-engine-setting-props'
export { default as Events } from '@opentiny/tiny-engine-setting-events'
export { default as Styles } from '@opentiny/tiny-engine-setting-styles'
export { default as Layout, LayoutService } from '@opentiny/tiny-engine-layout'
export { default as Layout, ToolbarBaseComponent, LayoutService } from '@opentiny/tiny-engine-layout'
betterdancing marked this conversation as resolved.
Show resolved Hide resolved
export { default as Canvas } from '@opentiny/tiny-engine-canvas'
export { initPreview } from './src/preview/src/main'
export { GenerateCodeService, PluginPanel } from '@opentiny/tiny-engine-common'
Expand Down
3 changes: 2 additions & 1 deletion packages/layout/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import component from './src/Main.vue'
import metaData from './meta'
import ToolbarBaseComponent from './src/ToolbarBaseComponent.vue'
import { LayoutService } from './src/composable'
import designSmbConfig from '@opentiny/vue-design-smb'
import { ConfigProvider as TinyConfigProvider } from '@opentiny/vue'
Expand All @@ -17,4 +18,4 @@ export default {
metas: [LayoutService]
}

export { LayoutService }
export { ToolbarBaseComponent, LayoutService }
betterdancing marked this conversation as resolved.
Show resolved Hide resolved
15 changes: 8 additions & 7 deletions packages/layout/src/DesignToolbars.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<template>
<div class="tiny-engine-toolbar">
<div class="toolbar-left">
<component :is="item.entry" v-for="item in leftBar" :key="item.id"></component>
<component v-for="item in leftBar" :is="item.entry" :options="item.options" :key="item.id"></component>
</div>
<div class="toolbar-center">
<component :is="item.entry" v-for="item in centerBar" :key="item.id"></component>
<component v-for="item in centerBar" :is="item.entry" :options="item.options" :key="item.id"></component>
</div>
<div class="toolbar-right">
<component :is="item.entry" v-for="item in rightBar" :key="item.id"></component>
<toolbar-collapse :collapseBar="collapseBar"></toolbar-collapse>
<component v-for="item in rightBar" :is="item.entry" :options="item.options" :key="item.id"></component>
<toolbar-collapse v-if="collapseBar.length" :collapseBar="collapseBar"></toolbar-collapse>
</div>
</div>
<div class="progress">
Expand Down Expand Up @@ -42,9 +42,9 @@ export default {
})

props.toolbars.forEach((item) => {
if (item.align === 'right') {
item?.collapsed ? collapseBar.push(item) : rightBar.push(item)
} else if (item.align === 'center') {
if (item.options.align === 'right') {
item?.options?.collapsed ? collapseBar.push(item) : rightBar.push(item)
} else if (item.options.align === 'center') {
centerBar.push(item)
} else {
leftBar.push(item)
Expand Down Expand Up @@ -90,6 +90,7 @@ export default {
}

.toolbar-left,
.toolbar-center,
.toolbar-right {
:deep(.icon) {
display: inline-flex;
Expand Down
82 changes: 82 additions & 0 deletions packages/layout/src/ToolbarBaseComponent.vue
betterdancing marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<template>
<span class="toolbar-item-wrap" @click="click">
<component :is="getRender()" v-bind="state">
<template #default>
<slot name="button"></slot>
</template>
</component>
<slot></slot>
<span v-if="state.options?.collapsed" class="operate-title">{{ state.content }}</span>
</span>
<span class="split-line" v-if="state.options?.separate">|</span>
</template>

<script>
import { reactive, computed } from 'vue'
import ToolbarIcon from './toolbar-built-in/ToolbarIcon.vue'
import ToolbarButton from './toolbar-built-in/ToolbarButton.vue'

export default {
components: {
ToolbarIcon,
ToolbarButton
},
props: {
icon: {
type: String,
default: ''
},
content: {
type: String,
default: ''
},
options: {
type: Object,
default: () => {}
}
},
emits: ['click-api'],
setup(props, { emit }) {
const state = reactive({
icon: computed(() => props.icon),
content: computed(() => props.content),
options: computed(() => props.options)
})

const click = () => {
emit('click-api')
betterdancing marked this conversation as resolved.
Show resolved Hide resolved
}

const getRender = () => {
switch (props.options.renderType) {
case 'button':
return ToolbarButton
case 'icon':
return ToolbarIcon
default:
return false
}
}

return {
state,
click,
getRender
}
}
}
</script>
<style scoped>
.split-line {
color: var(--ti-lowcode-toolbar-border-color);
margin: 0 4px;
font-size: 14px;
}
.toolbar-item-wrap div {
display: inline-block;
}
.operate-title {
vertical-align: middle;
padding-left: 8px;
}
</style>
8 changes: 2 additions & 6 deletions packages/layout/src/ToolbarCollapse.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
</span>
</template>
<div class="empty-bar" v-for="item in collapseBar" :key="item.id">
<div v-if="item.splitLine" class="empty-line"></div>
<div v-if="item.options.splitLine" class="empty-line"></div>
<div class="toolbar-list-button">
<component :is="item.entry"></component>
<component :is="item.entry" :options="item.options"></component>
</div>
</div>
</tiny-popover>
Expand Down Expand Up @@ -60,10 +60,6 @@ export default {
cursor: pointer;
}

.operate-title {
vertical-align: middle;
}

.reference-wrapper {
padding-left: 8px;
}
Expand Down
71 changes: 71 additions & 0 deletions packages/layout/src/toolbar-built-in/ToolbarButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<template>
<tiny-button v-bind="extendAttrs" class="toolbar-button">
<span class="svg-wrap">
<svg-icon :name="icon"></svg-icon>
<span v-if="options?.showDots" class="dots"></span>
</span>
<span class="save-title">{{ content }}</span>
<slot></slot>
</tiny-button>
</template>
<script>
import { inject } from 'vue'
import { Button } from '@opentiny/vue'

export default {
components: {
TinyButton: Button
},
props: {
icon: {
type: String,
default: ''
},
content: {
type: String,
default: ''
},
options: {
type: Object,
default: () => ({})
}
},
setup() {
const extendAttrs = inject('extend-attributes') || {}
return {
extendAttrs
}
}
}
</script>
<style lang="less" scoped>
.toolbar-button {
background-color: var(--ti-lowcode-toolbar-button-bg) !important;
border: none;
min-width: 70px;
height: 26px;
line-height: 24px;
padding: 0 8px;
border-radius: 4px;
margin-right: 4px;
}

.svg-wrap {
position: relative;
.dots {
width: 6px;
height: 6px;
background: var(--ti-lowcode-toolbar-dot-color);
border-radius: 50%;
display: inline-block;
position: absolute;
top: -2px;
right: -2px;
z-index: 100;
}
}

.save-title {
margin: 0 6px;
}
</style>
62 changes: 62 additions & 0 deletions packages/layout/src/toolbar-built-in/ToolbarIcon.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<template>
<tiny-popover
trigger="hover"
:open-delay="1000"
popper-class="toolbar-right-popover"
append-to-body
:content="content"
>
<template #reference>
<span class="icon">
<span class="icon-hides" v-bind="extendAttrs">
<svg-icon :name="icon"></svg-icon>
<span v-if="options?.showDots" class="dots"></span>
</span>
</span>
</template>
</tiny-popover>
</template>
<script>
import { inject } from 'vue'
import { Popover } from '@opentiny/vue'

export default {
components: {
TinyPopover: Popover
},
props: {
icon: {
type: String,
default: ''
},
content: {
type: String,
default: ''
},
options: {
type: Object,
default: () => {}
}
},
setup() {
const extendAttrs = inject('extend-attributes') || {}
return {
extendAttrs
}
}
}
</script>

<style lang="less" scoped>
.dots {
width: 6px;
height: 6px;
background: var(--ti-lowcode-toolbar-dot-color);
border-radius: 50%;
display: inline-block;
position: absolute;
top: 4px;
right: 3px;
z-index: 100;
}
</style>
9 changes: 7 additions & 2 deletions packages/toolbars/breadcrumb/meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ export default {
id: 'engine.toolbars.breadcrumb',
type: 'toolbars',
title: 'breadcrumb',
icon: '',
align: 'left'
options: {
icon: {
default: ''
},
align: 'left',
renderType: 'slot'
}
}
3 changes: 2 additions & 1 deletion packages/toolbars/breadcrumb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"@opentiny/tiny-engine-common": "workspace:*",
"@opentiny/tiny-engine-http": "workspace:*",
"@opentiny/tiny-engine-meta-register": "workspace:*",
"@opentiny/tiny-engine-utils": "workspace:*"
"@opentiny/tiny-engine-utils": "workspace:*",
"@opentiny/tiny-engine-layout": "workspace:*"
betterdancing marked this conversation as resolved.
Show resolved Hide resolved
},
"devDependencies": {
"@opentiny/tiny-engine-vite-plugin-meta-comments": "workspace:*",
Expand Down
49 changes: 32 additions & 17 deletions packages/toolbars/breadcrumb/src/Main.vue
Original file line number Diff line number Diff line change
@@ -1,34 +1,49 @@
<template>
<div class="top-panel-breadcrumb">
<div class="top-panel-breadcrumb-title">
<tiny-breadcrumb separator=":" @select="open">
<tiny-breadcrumb-item v-for="item in breadcrumbData.slice(0, 2)" :key="item">{{ item }} </tiny-breadcrumb-item>
</tiny-breadcrumb>
</div>
<tiny-button
class="publish"
v-if="breadcrumbData[0] === CONSTANTS.BLOCKTEXT"
@click="publishBlock()"
type="primary"
size="small"
>区块</tiny-button
>
</div>
<block-deploy-dialog v-model:visible="state.showDeployBlock" :nextVersion="nextVersion"></block-deploy-dialog>
<toolbar-base-component :options="options">
<template #default>
<div class="top-panel-breadcrumb">
<div class="top-panel-breadcrumb-title">
<tiny-breadcrumb separator=":" @select="open">
<tiny-breadcrumb-item v-for="item in breadcrumbData.slice(0, 2)" :key="item"
>{{ item }}
</tiny-breadcrumb-item>
</tiny-breadcrumb>
</div>

<tiny-button
class="publish"
v-if="breadcrumbData[0] === CONSTANTS.BLOCKTEXT"
@click="publishBlock()"
type="primary"
size="small"
>发布区块</tiny-button
betterdancing marked this conversation as resolved.
Show resolved Hide resolved
>
</div>
<block-deploy-dialog v-model:visible="state.showDeployBlock" :nextVersion="nextVersion"></block-deploy-dialog>
</template>
</toolbar-base-component>
</template>

<script>
import { reactive, computed } from 'vue'
import { Breadcrumb, BreadcrumbItem, Button } from '@opentiny/vue'
import { useBreadcrumb, useLayout } from '@opentiny/tiny-engine-meta-register'
import { ToolbarBaseComponent } from '@opentiny/tiny-engine-layout'
import { BlockDeployDialog } from '@opentiny/tiny-engine-common'

export default {
components: {
TinyBreadcrumb: Breadcrumb,
TinyBreadcrumbItem: BreadcrumbItem,
BlockDeployDialog,
TinyButton: Button
TinyButton: Button,
ToolbarBaseComponent
},
props: {
options: {
type: Object,
default: () => {}
betterdancing marked this conversation as resolved.
Show resolved Hide resolved
}
},
setup() {
const PLUGINS_ID = {
Expand Down
Loading