Skip to content

Commit

Permalink
Added support in Split window header render a component (Button ideal…
Browse files Browse the repository at this point in the history
…ly) to load external component
  • Loading branch information
pramodcog committed Aug 26, 2024
1 parent 49bae99 commit 911114b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 3 additions & 0 deletions react-components/src/components/Widgets/WindowWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type WindowWidgetProps = {
subtitle?: string;
header?: string;
type?: string;
openInNewTab?: ReactNode;
children: ReactNode;
onClose?: () => void;
onResize?: (width: number, height: number) => void;
Expand All @@ -38,6 +39,7 @@ export const WindowWidget = ({
header,
type,
children,
openInNewTab,
onClose,
onResize
}: WindowWidgetProps): ReactElement => {
Expand Down Expand Up @@ -115,6 +117,7 @@ export const WindowWidget = ({
onResize={handleResize}>
<Widget>
<Widget.Header title={title} type={type} header={header} subtitle={subtitle}>
{openInNewTab !== undefined && <div>{openInNewTab}</div>}
<CogsTooltip
content={
isMinimized
Expand Down
12 changes: 10 additions & 2 deletions react-components/stories/SplitWindow.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import type { Meta, StoryObj } from '@storybook/react';
import { CadModelContainer, RevealCanvas, PointCloudContainer, RevealContext } from '../src';
import { CogniteClient } from '@cognite/sdk';
import { Color } from 'three';
import { useState, type ReactElement } from 'react';
import { ReactNode, useState, type ReactElement } from 'react';
import { WindowWidget } from '../src/components/Widgets/WindowWidget';
import { Button } from '@cognite/cogs.js';

const meta = {
title: 'Example/SplitWindow',
Expand Down Expand Up @@ -45,7 +46,10 @@ export const Main: Story = {
<RevealCanvas>
<PointCloudContainer addModelOptions={addModelOptions} />
{isWindowWidgetVisible && (
<WindowWidget header="Widget Header" onClose={handleClose}>
<WindowWidget
header="Widget Header"
onClose={handleClose}
openInNewTab={openExternalButton()}>
<SecondaryRevealContainer />
</WindowWidget>
)}
Expand All @@ -56,6 +60,10 @@ export const Main: Story = {
}
};

function openExternalButton(): ReactNode {
return <Button>Open in New Tab</Button>;
}

function SecondaryRevealContainer(): ReactElement {
return (
<RevealContext sdk={sdk} color={new Color(0x4a4a4a)} appLanguage={'en'}>
Expand Down

0 comments on commit 911114b

Please sign in to comment.