Skip to content

Commit

Permalink
[v4] remove createComponentGroup utility in favour Object.assign (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaMachina authored Aug 13, 2024
1 parent cc2808f commit bf0c4e7
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 26 deletions.
5 changes: 5 additions & 0 deletions .changeset/thick-adults-leave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphiql/react': minor
---

remove `createComponentGroup` utility in favour `Object.assign`
10 changes: 5 additions & 5 deletions .changeset/weak-dancers-jog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ Remove `toolbar.additionalContent` and `toolbar.additionalComponent` props in fa

## Migration from `toolbar.additionalContent`

#### Before
### Before

```jsx
<GraphiQL toolbar={{ additionalContent: <button>My button</button> }} />
```

#### After
### After

```jsx
<GraphiQL>
Expand All @@ -29,9 +29,9 @@ Remove `toolbar.additionalContent` and `toolbar.additionalComponent` props in fa
</GraphiQL>
```

### Migration from `toolbar.additionalComponent`
## Migration from `toolbar.additionalComponent`

#### Before
### Before

```jsx
<GraphiQL
Expand All @@ -43,7 +43,7 @@ Remove `toolbar.additionalContent` and `toolbar.additionalComponent` props in fa
/>
```

#### After
### After

```jsx
<GraphiQL>
Expand Down
3 changes: 1 addition & 2 deletions packages/graphiql-react/src/toolbar/menu.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ReactNode } from 'react';
import { clsx } from 'clsx';
import { DropdownMenu, Tooltip } from '../ui';
import { createComponentGroup } from '../utility/component-group';

import './menu.css';
import { DropdownMenuProps } from '@radix-ui/react-dropdown-menu';
Expand Down Expand Up @@ -36,6 +35,6 @@ const ToolbarMenuRoot = ({
</DropdownMenu>
);

export const ToolbarMenu = createComponentGroup(ToolbarMenuRoot, {
export const ToolbarMenu = Object.assign(ToolbarMenuRoot, {
Item: DropdownMenu.Item,
});
3 changes: 1 addition & 2 deletions packages/graphiql-react/src/ui/dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { clsx } from 'clsx';
import { forwardRef, ReactElement } from 'react';
import { CloseIcon } from '../icons';
import { createComponentGroup } from '../utility/component-group';
import { UnStyledButton } from './button';
import * as D from '@radix-ui/react-dialog';
import { Root as VisuallyHidden } from '@radix-ui/react-visually-hidden';
Expand Down Expand Up @@ -40,7 +39,7 @@ export function DialogRoot({
);
}

export const Dialog = createComponentGroup(DialogRoot, {
export const Dialog = Object.assign(DialogRoot, {
Close: DialogClose,
Title: D.Title,
Trigger: D.Trigger,
Expand Down
3 changes: 1 addition & 2 deletions packages/graphiql-react/src/ui/dropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ComponentProps, forwardRef, ReactElement } from 'react';
import { clsx } from 'clsx';
import { createComponentGroup } from '../utility/component-group';
import {
Trigger,
Portal,
Expand Down Expand Up @@ -53,7 +52,7 @@ const Item = ({ className, children, ...props }: DropdownMenuItemProps) => (
</RadixItem>
);

export const DropdownMenu = createComponentGroup(Root, {
export const DropdownMenu = Object.assign(Root, {
Button,
Item,
Content,
Expand Down
3 changes: 1 addition & 2 deletions packages/graphiql-react/src/ui/tooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ReactElement, ReactNode } from 'react';
import * as T from '@radix-ui/react-tooltip';
import { createComponentGroup } from '../utility/component-group';
import './tooltip.css';

export function TooltipRoot({
Expand All @@ -27,6 +26,6 @@ export function TooltipRoot({
);
}

export const Tooltip = createComponentGroup(TooltipRoot, {
export const Tooltip = Object.assign(TooltipRoot, {
Provider: T.Provider,
});
13 changes: 0 additions & 13 deletions packages/graphiql-react/src/utility/component-group.ts

This file was deleted.

0 comments on commit bf0c4e7

Please sign in to comment.