Skip to content

Commit

Permalink
Fix node preview styles (#903)
Browse files Browse the repository at this point in the history
* Use colorPalette to style node previews

* Use widget text secondary color for description

* Remove unused css

* nit

---------

Co-authored-by: huchenlei <chenlei.hu@mail.utoronto.ca>
  • Loading branch information
christian-byrne and huchenlei authored Sep 22, 2024
1 parent 82d03b5 commit 4052fc5
Showing 1 changed file with 44 additions and 6 deletions.
50 changes: 44 additions & 6 deletions src/components/node/NodePreview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ https://github.com/Nuked88/ComfyUI-N-Sidebar/blob/7ae7da4a9761009fb6629bc04c6830
<template>
<div class="_sb_node_preview">
<div class="_sb_table">
<div class="node_header">
<div
class="node_header"
:style="{
backgroundColor: litegraphColors.NODE_DEFAULT_COLOR,
color: litegraphColors.NODE_TITLE_COLOR
}"
>
<div class="_sb_dot headdot"></div>
{{ nodeDef.display_name }}
</div>
Expand All @@ -22,7 +28,12 @@ https://github.com/Nuked88/ComfyUI-N-Sidebar/blob/7ae7da4a9761009fb6629bc04c6830
</div>
<div class="_sb_col">{{ slotInput ? slotInput.name : '' }}</div>
<div class="_sb_col middle-column"></div>
<div class="_sb_col _sb_inherit">
<div
class="_sb_col _sb_inherit"
:style="{
color: litegraphColors.NODE_TEXT_COLOR
}"
>
{{ slotOutput ? slotOutput.name : '' }}
</div>
<div class="_sb_col">
Expand All @@ -37,22 +48,43 @@ https://github.com/Nuked88/ComfyUI-N-Sidebar/blob/7ae7da4a9761009fb6629bc04c6830
:key="widgetInput.name"
>
<div class="_sb_col _sb_arrow">&#x25C0;</div>
<div class="_sb_col">{{ widgetInput.name }}</div>
<div
class="_sb_col"
:style="{
color: litegraphColors.WIDGET_SECONDARY_TEXT_COLOR
}"
>
{{ widgetInput.name }}
</div>
<div class="_sb_col middle-column"></div>
<div class="_sb_col _sb_inherit">
<div
class="_sb_col _sb_inherit"
:style="{ color: litegraphColors.WIDGET_TEXT_COLOR }"
>
{{ truncateDefaultValue(widgetInput.default) }}
</div>
<div class="_sb_col _sb_arrow">&#x25B6;</div>
</div>
</div>
<div class="_sb_description" v-if="nodeDef.description">
<div
class="_sb_description"
v-if="nodeDef.description"
:style="{
color: litegraphColors.WIDGET_SECONDARY_TEXT_COLOR,
backgroundColor: litegraphColors.WIDGET_BGCOLOR
}"
>
{{ nodeDef.description }}
</div>
</div>
</template>

<script setup lang="ts">
import { ComfyNodeDefImpl, useNodeDefStore } from '@/stores/nodeDefStore'
import {
getColorPalette,
defaultColorPalette
} from '@/extensions/core/colorPalette'
import _ from 'lodash'

const props = defineProps({
Expand All @@ -62,6 +94,13 @@ const props = defineProps({
}
})

// Node preview currently is recreated every time something is hovered.
// So not reactive to the color palette changes after setup is fine.
// If later we want NodePreview to be shown more persistently, then we should
// make the getColorPalette() call reactive.
const colors = getColorPalette()?.colors?.litegraph_base
const litegraphColors = colors ?? defaultColorPalette.colors.litegraph_base

const nodeDefStore = useNodeDefStore()

const nodeDef = props.nodeDef
Expand Down Expand Up @@ -106,7 +145,6 @@ const truncateDefaultValue = (value: any, charLimit: number = 32): string => {
.node_header {
line-height: 1;
padding: 8px 13px 7px;
background: var(--comfy-input-bg);
margin-bottom: 5px;
font-size: 15px;
text-wrap: nowrap;
Expand Down

0 comments on commit 4052fc5

Please sign in to comment.