Skip to content

Commit

Permalink
fix: errors due to improperly passing custom props to native elements (
Browse files Browse the repository at this point in the history
…#3684)

Co-authored-by: cognite-bulldozer[bot] <51074376+cognite-bulldozer[bot]@users.noreply.github.com>
  • Loading branch information
christjt and cognite-bulldozer[bot] authored Sep 7, 2023
1 parent 143f24f commit 6c0e4a3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
30 changes: 22 additions & 8 deletions react-components/src/components/RevealToolbar/RevealToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ const defaultStyle: ToolBarProps = {
}
};

type RevealToolbarProps = ToolBarProps & {
type RevealToolbarProps = ToolBarProps & CustomContent;

type CustomContent = {
customSettingsContent?: JSX.Element;
lowFidelitySettings?: Partial<QualitySettings>;
highFidelitySettings?: Partial<QualitySettings>;
};

const DefaultContentWrapper = (props: RevealToolbarProps): ReactElement => {
const DefaultContentWrapper = (props: CustomContent): ReactElement => {
return (
<>
<LayersButton />
Expand All @@ -52,15 +54,27 @@ const DefaultContentWrapper = (props: RevealToolbarProps): ReactElement => {
);
};

const RevealToolbarContainer = (
props: RevealToolbarProps & { toolBarContent?: JSX.Element }
): ReactElement => {
if (props.className === undefined && props.style === undefined) {
props = { ...props, ...defaultStyle };
const RevealToolbarContainer = ({
customSettingsContent,
lowFidelitySettings,
highFidelitySettings,
toolBarContent,
...restProps
}: RevealToolbarProps & { toolBarContent?: JSX.Element }): ReactElement => {
if (restProps.className === undefined && restProps.style === undefined) {
restProps = { ...restProps, ...defaultStyle };
}
return (
<I18nWrapper translations={translations} addNamespace="reveal-react-components">
<ToolBar {...props}>{props.toolBarContent ?? <DefaultContentWrapper {...props} />}</ToolBar>
<ToolBar {...restProps}>
{toolBarContent ?? (
<DefaultContentWrapper
customSettingsContent={customSettingsContent}
highFidelitySettings={highFidelitySettings}
lowFidelitySettings={lowFidelitySettings}
/>
)}
</ToolBar>
</I18nWrapper>
);
};
Expand Down
4 changes: 2 additions & 2 deletions react-components/stories/Toolbar.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ const exampleHighQualitySettings: QualitySettings = {

const exampleLowQualitySettings: QualitySettings = {
cadBudget: {
maximumRenderCost: 95000000,
maximumRenderCost: 10_000_000,
highDetailProximityThreshold: 100
},
pointCloudBudget: {
numberOfPoints: 12000000
numberOfPoints: 2_000_000
},
resolutionOptions: {
maxRenderResolution: 1e5,
Expand Down

0 comments on commit 6c0e4a3

Please sign in to comment.