Skip to content

Commit 5acbcb2

Browse files
viva-jinyiclaude
andcommitted
[fix] Make sidebar CSS variables global for teleported components
- Move --sidebar-width CSS variable to :root to make it accessible globally - This allows teleported components like WhatsNewPopup to reference sidebar dimensions - Adjust arrow positioning calculations for better alignment with help center icon - Add explanatory comments about why these variables need to be global 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 2c85c44 commit 5acbcb2

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

src/components/helpcenter/WhatsNewPopup.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,10 @@ defineExpose({
159159
<style scoped>
160160
/* Popup container - positioning handled by parent */
161161
.whats-new-popup-container {
162+
--whats-new-popup-bottom: 1rem;
163+
162164
position: absolute;
163-
bottom: 1rem;
165+
bottom: var(--whats-new-popup-bottom);
164166
z-index: 1000;
165167
pointer-events: auto;
166168
}
@@ -169,7 +171,7 @@ defineExpose({
169171
.help-center-arrow {
170172
position: absolute;
171173
bottom: calc(
172-
var(--sidebar-width, 4rem) * 2 + var(--sidebar-width, 4rem) / 2
174+
var(--sidebar-width) * 2 + var(--sidebar-width) / 2
173175
); /* Position to center of help center icon (2 icons below + half icon height for center) */
174176
transform: none;
175177
z-index: 999;
@@ -184,8 +186,8 @@ defineExpose({
184186
.whats-new-popup-container.sidebar-left.small-sidebar .help-center-arrow {
185187
left: -14px; /* Overlap with popup outline */
186188
bottom: calc(
187-
var(--sidebar-width) * 2 + var(--sidebar-width) / 2
188-
); /* Position to center of help center icon (2 icons below + half icon height for center) */
189+
var(--sidebar-width) * 2 + 10px - var(--whats-new-popup-bottom)
190+
); /* Position to center of help center icon (2 icons below + half icon height for center - whats new popup bottom position ) */
189191
}
190192
191193
/* Sidebar positioning classes applied by parent */

src/components/sidebar/SideToolbar.vue

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,22 @@ const getTabTooltipSuffix = (tab: SidebarTabExtension) => {
7676
}
7777
</script>
7878

79+
<style>
80+
/* Global CSS variables for sidebar
81+
* These variables need to be global (not scoped) because they are used by
82+
* teleported components like WhatsNewPopup that render outside the sidebar
83+
* but need to reference sidebar dimensions for proper positioning.
84+
*/
85+
:root {
86+
--sidebar-width: 4rem;
87+
--sidebar-icon-size: 1rem;
88+
}
89+
90+
:root:has(.side-tool-bar-container.small-sidebar) {
91+
--sidebar-width: 2.5rem;
92+
}
93+
</style>
94+
7995
<style scoped>
8096
.side-tool-bar-container {
8197
display: flex;
@@ -88,9 +104,6 @@ const getTabTooltipSuffix = (tab: SidebarTabExtension) => {
88104
background-color: var(--comfy-menu-secondary-bg);
89105
color: var(--fg-color);
90106
box-shadow: var(--bar-shadow);
91-
92-
--sidebar-width: 4rem;
93-
--sidebar-icon-size: 1rem;
94107
}
95108
96109
.side-tool-bar-container.small-sidebar {

0 commit comments

Comments
 (0)