Skip to content

Commit

Permalink
fix(svelteflow) wrong intial color of hero flow
Browse files Browse the repository at this point in the history
  • Loading branch information
peterkogo committed Jul 25, 2024
1 parent a1fa684 commit 14ca8de
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/xy-shared/widgets/hero-flow/flow.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import { useCallback, useEffect } from 'react';
import { useCallback, useEffect, useRef } from 'react';
import {
ReactFlow,
Background,
Expand All @@ -19,6 +19,7 @@ import ColorPickerNode from './color-picker-node';
import SliderNode from './slider-node';
import SwitcherNode from './switcher-node';
import SwoopyNode from './swoopy-node';
import { init } from 'next/dist/compiled/webpack/webpack';

const nodeTypes = {
hero: HeroNode,
Expand Down Expand Up @@ -119,11 +120,18 @@ type FlowProps = {

const viewportWidthSelector = (state: ReactFlowState) => state.width;

function Flow({ className }: FlowProps) {
function Flow({ className, initialColor }: FlowProps) {
const { getNodes, setNodes, setEdges, setViewport } = useReactFlow();
const viewportWidth = useStore(viewportWidthSelector);
const store = useStoreApi();

// fix for wrong color on svelte site
const initial = useRef(true);
if (initial.current) {
defaultNodes[1].data.value = initialColor;
initial.current = false;
}

const adjustViewport = useCallback(() => {
const nodes = getNodes();
const { width, height } = store.getState();
Expand Down

0 comments on commit 14ca8de

Please sign in to comment.