Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<span v-if="options?.showDots" class="dot"></span>
<tiny-button class="toolbar-button">
<svg-icon v-if="icon" :name="icon"></svg-icon>
<span class="save-title">{{ content }}</span>
<span v-if="options?.showTitle !== false" class="save-title">{{ content }}</span>
<slot></slot>
</tiny-button>
</div>
Expand Down Expand Up @@ -36,7 +36,7 @@ export default {
.toolbar-button {
background-color: var(--te-component-toolbar-base-button-bg-color) !important;
border: none !important;
min-width: 70px;
min-width: 60px;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

❓ Verification inconclusive

🏁 Script executed:

find . -name "ToolbarBaseButton.vue" -type f

Repository: opentiny/tiny-engine

Length of output: 184


🌐 Web query:

Vue.js scoped CSS slotted content does not apply scope attribute

💡 Result:

Cause — scoped styles are only applied to elements owned by the component (Vue adds a data-v-xxx attribute to those elements). Content passed into a is owned by the parent, so Vue does not add the component’s scope attribute to slotted nodes and scoped rules don’t match them by default. [1][2]

Fixes

  • Use the :slotted() pseudo-class inside the child component’s <style scoped> to target slotted nodes: <style scoped> :slotted(.my-item) { color: red; } </style>
  • Or move the rule to the parent (where the slotted content lives) or use a non-scoped/global style.
  • For styling elements inside child components or deep descendants, use :deep(...) (not for slotted content owned by the parent). [1][2]

References
[1] Vue SFC CSS features (scoped, :slotted, :deep).
[2] vue-loader — Scoped CSS behavior and caveats.


Scoped .tiny-popover.no-arrow rule won't apply to slotted popovers

Since popovers are provided via slots, they're owned by parent components and won't carry this component's scope attribute. The scoped .tiny-popover.no-arrow rule won't target them.

Consider using the :slotted() pseudo-class if styling direct slot children, moving this rule to the parent component where the popover is rendered, or using a global/non-scoped style file instead. Avoid :deep() for slotted content, as it's for styling child components and descendants, not slot-provided elements.

🤖 Prompt for AI Agents
In packages/common/component/toolbar-built-in/ToolbarBaseButton.vue around line
39, the scoped CSS rule targeting .tiny-popover.no-arrow won't apply to popovers
rendered via slots because slotted content is owned by the parent and doesn't
get this component's scope attribute; update the styling by either (a) moving
the .tiny-popover.no-arrow rule into the parent component that renders the
popover, (b) place the rule in a global/non-scoped stylesheet so it applies to
slotted elements, or (c) if you only need to style direct slot children, use the
:slotted(.tiny-popover.no-arrow) selector in this component's <style scoped>
block; avoid using :deep() for slot-provided elements.

height: 26px;
line-height: 24px;
padding: 0 8px;
Expand All @@ -61,4 +61,8 @@ export default {
color: var(--te-component-common-icon-color-primary);
}
}

.tiny-popover.no-arrow {
margin-top: 12px;
}
</style>
4 changes: 2 additions & 2 deletions packages/design-core/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
Fullscreen,
Lang,
ViewSetting,
Logo,
// Logo,
Lock,
Media,
Redoundo,
Expand Down Expand Up @@ -138,7 +138,7 @@ export default {
layout: __TINY_ENGINE_REMOVED_REGISTRY['engine.layout'] === false ? null : Layout,
toolbars: [
__TINY_ENGINE_REMOVED_REGISTRY['engine.toolbars.themeSwitch'] === false ? null : ThemeSwitch,
__TINY_ENGINE_REMOVED_REGISTRY['engine.toolbars.logo'] === false ? null : Logo,
//__TINY_ENGINE_REMOVED_REGISTRY['engine.toolbars.logo'] === false ? null : Logo,
__TINY_ENGINE_REMOVED_REGISTRY['engine.toolbars.breadcrumb'] === false ? null : Breadcrumb,
__TINY_ENGINE_REMOVED_REGISTRY['engine.toolbars.lock'] === false ? null : Lock,
__TINY_ENGINE_REMOVED_REGISTRY['engine.toolbars.media'] === false ? null : Media,
Expand Down
3 changes: 2 additions & 1 deletion packages/toolbars/preview/meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ export default {
icon: {
default: 'preview'
},
renderType: 'icon',
renderType: 'button',
showTitle: false,
previewUrl: ''
}
}
35 changes: 28 additions & 7 deletions packages/toolbars/preview/src/Main.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
<template>
<div class="toolbar-save toolbar-helpGuid">
<toolbar-base content="预览页面" :icon="options.icon?.default || options?.icon" :options="options" trigger="hover">
<div class="toolbar-preview">
<toolbar-base
content="预览"
:icon="options.icon?.default || options?.icon"
:options="options"
trigger="hover"
@click-api="preview('page')"
>
<template #button>
<div class="toolbar-preview-item">
<span @click="preview('page')">页面预览</span>
<span @click="preview('app')">应用预览</span>
</div>
<tiny-popover width="85" trigger="hover" :open-delay="OPEN_DELAY.Default">
<template #reference>
<svg-icon :name="iconExpand"></svg-icon>
</template>
<div class="toolbar-preview-item">
<span @click="preview('page')">页面预览</span>
<span @click="preview('app')">应用预览</span>
</div>
</tiny-popover>
</template>
</toolbar-base>
</div>
Expand All @@ -15,14 +26,23 @@
/* metaService: engine.toolbars.preview.Main */
import { previewPage } from '@opentiny/tiny-engine-common/js/preview'
import { useLayout, useNotify, getOptions } from '@opentiny/tiny-engine-meta-register'
import { constants } from '@opentiny/tiny-engine-utils'
import type { Component } from 'vue'
import { Popover } from '@opentiny/vue'
import meta from '../meta'
import { ToolbarBase } from '@opentiny/tiny-engine-common'
const { OPEN_DELAY } = constants

export default {
components: {
TinyPopover: Popover as Component,
ToolbarBase
},
props: {
iconExpand: {
type: String,
default: 'down-arrow'
},
options: {
type: Object,
default: () => ({})
Expand Down Expand Up @@ -74,7 +94,8 @@ export default {
}

return {
preview
preview,
OPEN_DELAY
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/toolbars/save/src/Main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
@click-api="openApi"
>
<template #button>
<tiny-popover :visible-arrow="false" width="203" trigger="click" :open-delay="OPEN_DELAY.Default">
<tiny-popover width="203" trigger="click" :open-delay="OPEN_DELAY.Default">
<template #reference>
<svg-icon :name="iconExpand"></svg-icon>
</template>
Expand Down
Loading