Skip to content

Commit 4b789d2

Browse files
tenphiCopilot
andauthored
feat(useAnchoredMenu): add hook (#725)
Co-authored-by: Copilot <[email protected]>
1 parent d59fe4e commit 4b789d2

31 files changed

+4004
-73
lines changed

.changeset/orange-hounds-beam.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cube-dev/ui-kit": minor
3+
---
4+
5+
Add useEventBus hook to emit global events and subscribe to them.

.changeset/silver-crabs-complain.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cube-dev/ui-kit": minor
3+
---
4+
5+
Add useContextMenu hook to invoke a context menu in the exact place of the click.

.changeset/thin-years-teach.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cube-dev/ui-kit": minor
3+
---
4+
5+
Add useAnchoredMenu hook to programmatically invoke a menu anchored to the specific element.

.size-limit.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module.exports = [
2020
}),
2121
);
2222
},
23-
limit: '268kB',
23+
limit: '270kB',
2424
},
2525
{
2626
name: 'Tree shaking (just a Button)',

jest.config.cjs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ const config = {
2020
'node_modules/(?!(.pnpm/)?react-hotkeys-hook)',
2121
],
2222
setupFilesAfterEnv: ['./src/test/setup.ts'],
23-
moduleNameMapper: {
24-
'^@/(.*)$': '<rootDir>/src/$1',
25-
},
2623
};
2724

2825
module.exports = config;

src/components/Root.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
} from '../tasty';
1515
import { TOKENS } from '../tokens';
1616
import { useViewportSize } from '../utils/react';
17+
import { EventBusProvider } from '../utils/react/useEventBus';
1718

1819
import { GlobalStyles } from './GlobalStyles';
1920
import { AlertDialogApiProvider } from './overlays/AlertDialog';
@@ -150,9 +151,11 @@ export function Root(allProps: CubeRootProps) {
150151
/>
151152
<ModalProvider>
152153
<PortalProvider value={ref}>
153-
<NotificationsProvider rootRef={ref}>
154-
<AlertDialogApiProvider>{children}</AlertDialogApiProvider>
155-
</NotificationsProvider>
154+
<EventBusProvider>
155+
<NotificationsProvider rootRef={ref}>
156+
<AlertDialogApiProvider>{children}</AlertDialogApiProvider>
157+
</NotificationsProvider>
158+
</EventBusProvider>
156159
</PortalProvider>
157160
</ModalProvider>
158161
</RootElement>

src/components/actions/Button/Button.docs.mdx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Meta, Canvas, Story, Controls } from '@storybook/blocks';
1+
import { Meta, Story, Controls } from '@storybook/blocks';
22
import { Button } from './Button';
33
import * as ButtonStories from './Button.stories';
44

@@ -17,9 +17,9 @@ A versatile action component that triggers commands and navigates users.
1717

1818
## Component
1919

20-
<Canvas>
21-
<Story of={ButtonStories.Default} />
22-
</Canvas>
20+
<Story of={ButtonStories.Default} />
21+
22+
---
2323

2424
## Properties
2525

@@ -59,7 +59,7 @@ The `mods` prop accepts the following modifiers you can override:
5959

6060
## Variants
6161

62-
### Types
62+
### Types. `type` prop
6363

6464
- `primary` – Emphasised call-to-action.
6565
- `secondary` – Less emphasised, alternative action.
@@ -68,14 +68,14 @@ The `mods` prop accepts the following modifiers you can override:
6868
- `clear` – Text-only variant without background and border.
6969
- `link` – Styled as a textual link.
7070

71-
### Themes
71+
### Themes. `theme` prop
7272

7373
- `default` – Brand purple colours.
7474
- `danger` – Red palette for destructive actions.
7575
- `success` – Green palette for positive actions.
7676
- `special` – White palette for dark backgrounds.
7777

78-
### Sizes
78+
### Sizes. `size` prop
7979

8080
- `small` – Compact height (4×).
8181
- `medium` – Default height (5×).
@@ -100,9 +100,14 @@ import { IconPlus } from '@tabler/icons-react';
100100
### Link Button
101101

102102
```jsx
103+
<!-- Navigate to a new page using the router -->
103104
<Button to="/pricing">Pricing</Button>
104105
<!-- Use `!` prefix to open in a new tab -->
105106
<Button to="!/pricing">Pricing</Button>
107+
<!-- Use `@` prefix to navigate to a new page without using the router -->
108+
<Button to="@/pricing">Pricing</Button>
109+
<!-- Use `@` to reload the page -->
110+
<Button to="@/pricing">Pricing</Button>
106111
```
107112

108113
### Loading State

0 commit comments

Comments
 (0)