Skip to content

Commit

Permalink
export component with cytoscape provider included
Browse files Browse the repository at this point in the history
  • Loading branch information
jonesmac committed Sep 29, 2023
1 parent c9ed2e1 commit 62a3bee
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import { useWallet, WalletProvider } from '@xyo-network/react-wallet'
import { MemorySentinel, SentinelConfigSchema } from '@xyo-network/sentinel'
import { useState } from 'react'

import { CytoscapeInstanceProvider } from '../../../contexts'
import { ModuleGraphFlexBox } from './GraphFlexBox'
import { ModuleGraphFlexBoxWithProvider } from './GraphFlexBox'

const nodeUrl = 'http://localhost:8080/node'

Expand Down Expand Up @@ -58,25 +57,23 @@ const MemoryNodeDecorator: Decorator = (Story, args) => {
return (
<WalletProvider rootWallet={wallet}>
<NodeProvider node={node}>
<CytoscapeInstanceProvider>
<Story {...args} />
</CytoscapeInstanceProvider>
<Story {...args} />
</NodeProvider>
</WalletProvider>
)
}

// eslint-disable-next-line import/no-default-export
export default {
component: ModuleGraphFlexBox,
title: 'node/renderer/ModuleGraphFlexBox',
component: ModuleGraphFlexBoxWithProvider,
title: 'node/renderer/ModuleGraphFlexBoxWithProvider',
} as Meta

const Template: StoryFn<typeof ModuleGraphFlexBox> = (props) => <ModuleGraphFlexBox {...props} />
const Template: StoryFn<typeof ModuleGraphFlexBoxWithProvider> = (props) => <ModuleGraphFlexBoxWithProvider {...props} />

const TemplateWithProvidedModule: StoryFn<typeof ModuleGraphFlexBox> = (props) => {
const TemplateWithProvidedModule: StoryFn<typeof ModuleGraphFlexBoxWithProvider> = (props) => {
const [node] = useProvidedNode()
return <ModuleGraphFlexBox rootModule={node} {...props} />
return <ModuleGraphFlexBoxWithProvider rootModule={node} {...props} />
}

const defaultProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Button } from '@mui/material'
import { FlexBoxProps } from '@xylabs/react-flexbox'
import { ModuleInstance } from '@xyo-network/module'

import { CytoscapeInstanceProvider } from '../../../contexts'
import { useHoveredNode, useNewElements, useRelationalGraphOptions, useRenderNewElements, useSelectedElement } from '../../../hooks'
import { WithExtensions } from '../../cytoscape-extensions'
import { NodeRelationalGraphFlexBox } from '../../RelationalGraph'
Expand Down Expand Up @@ -34,3 +35,11 @@ export const ModuleGraphFlexBox: React.FC<ModuleGraphFlexBoxProps> = ({ rootModu
</WithExtensions>
)
}

export const ModuleGraphFlexBoxWithProvider: React.FC<ModuleGraphFlexBoxProps> = (props) => {
return (
<CytoscapeInstanceProvider>
<ModuleGraphFlexBox {...props} />
</CytoscapeInstanceProvider>
)
}

0 comments on commit 62a3bee

Please sign in to comment.