-
-
Notifications
You must be signed in to change notification settings - Fork 372
feature: Floating Panel
#4113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Copilot
wants to merge
43
commits into
main
Choose a base branch
from
copilot/featurefloating-panel
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,262
−23
Open
feature: Floating Panel
#4113
Changes from 28 commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
4557cfb
Initial plan
Copilot 578234a
Add FloatingPanel component for Svelte and React with skeleton-common…
Copilot ca08cf1
Rewrite React FloatingPanel components to follow skeleton-react conve…
Copilot 27b320d
Add tests for FloatingPanel component and remove Portal dependency fr…
Copilot 7517e73
Add documentation and examples for FloatingPanel component
Copilot aaa4163
Fix TypeScript errors and formatting issues, add stability beta to docs
Copilot 56ca820
Use ApiReference component, remove defaultOpen from examples, add age…
Copilot 6e8cd3f
Remove agent instructions file
Copilot 03bffaa
Remove provider pattern examples from documentation
Copilot 9f07942
Add restore button, default styles, and fix overflow issues
Copilot 604e0fc
reset styles
Hugos68 ea6e74f
changeset
Hugos68 b0dd519
styling and example stuff
Hugos68 87dea56
fixed anatomy
Hugos68 8f8c247
remove unused styles
Hugos68 73cb4da
Style improvements
endigo9740 5988f9c
add examples
Hugos68 ce16470
Merge branch 'main' into copilot/featurefloating-panel
Hugos68 b9d3c5c
Add controlled, anchor position, disable dragging, and direction exam…
Copilot 8b7a16f
Use English text instead of Arabic in direction example
Copilot f85f502
Use getAnchorPosition instead of defaultPosition with refs in anchor …
Copilot 3ef7147
Remove trigger from controlled example and add disable resizing example
Copilot fd13633
resize triggers, getAnchorPoint fix
Hugos68 8b417c4
remove hardcoded size
Hugos68 ab79bad
label text
Hugos68 e8f72b6
Adjust header padding
endigo9740 83b006f
Merge branch 'main' into copilot/featurefloating-panel
Hugos68 ab8c3da
fix conflict
Hugos68 c0f9379
Merge branch 'main' into copilot/featurefloating-panel
Hugos68 174f176
fix order
Hugos68 91c5892
fix controlled styles
Hugos68 0cf8ced
cleanup
Hugos68 fc86d3c
Update size constraints message and improve controlled example layout
Copilot 977769e
format
Hugos68 b0adac4
fix
Hugos68 bc5bae1
fix
Hugos68 604eef4
add styles for data axis
Hugos68 0823939
simplify
Hugos68 f8381b3
simplify
Hugos68 d6f72b3
fix
Hugos68 efe5da9
order changes
Hugos68 9d96207
added axis visualizers
Hugos68 378cdfc
add todo
Hugos68 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| "@skeletonlabs/skeleton-common": minor | ||
| "@skeletonlabs/skeleton-svelte": minor | ||
| "@skeletonlabs/skeleton-react": minor | ||
| --- | ||
|
|
||
| feature: `Floating Panel` component | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import { defineSkeletonClasses } from '../internal/define-skeleton-classes.js' with { type: 'macro' }; | ||
|
|
||
| export const classesFloatingPanel = defineSkeletonClasses({ | ||
| trigger: '', | ||
| positioner: '', | ||
| content: 'card overflow-hidden shadow-lg border border-surface-300-700', | ||
| dragTrigger: '', | ||
| header: 'px-4 py-2 grid grid-cols-[1fr_auto] gap-2 items-center bg-surface-200-800 overflow-y-hidden', | ||
| title: 'flex justify-start items-center gap-2 whitespace-nowrap', | ||
| control: 'flex gap-1', | ||
| stageTrigger: 'btn-icon hover:preset-tonal', | ||
| closeTrigger: 'btn-icon hover:preset-tonal', | ||
| resizeTrigger: '', | ||
| body: 'h-full bg-surface-100-900 p-4 overflow-y-auto', | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
packages/skeleton-react/src/components/floating-panel/anatomy/body.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { RootContext } from '../modules/root-context.js'; | ||
| import type { HTMLAttributes } from '@/internal/html-attributes.js'; | ||
| import type { PropsWithElement } from '@/internal/props-with-element.js'; | ||
| import { classesFloatingPanel } from '@skeletonlabs/skeleton-common'; | ||
| import { mergeProps } from '@zag-js/react'; | ||
| import { use } from 'react'; | ||
|
|
||
| export interface FloatingPanelBodyProps extends PropsWithElement<'div'>, HTMLAttributes<'div'> {} | ||
|
|
||
| export default function Body(props: FloatingPanelBodyProps) { | ||
| const floatingPanel = use(RootContext); | ||
|
|
||
| const { element, children, ...rest } = props; | ||
|
|
||
| const attributes = mergeProps( | ||
| floatingPanel.getBodyProps(), | ||
| { | ||
| className: classesFloatingPanel.body, | ||
| }, | ||
| rest, | ||
| ); | ||
|
|
||
| return element ? element(attributes) : <div {...attributes}>{children}</div>; | ||
| } |
24 changes: 24 additions & 0 deletions
24
packages/skeleton-react/src/components/floating-panel/anatomy/close-trigger.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { RootContext } from '../modules/root-context.js'; | ||
| import type { HTMLAttributes } from '@/internal/html-attributes.js'; | ||
| import type { PropsWithElement } from '@/internal/props-with-element.js'; | ||
| import { classesFloatingPanel } from '@skeletonlabs/skeleton-common'; | ||
| import { mergeProps } from '@zag-js/react'; | ||
| import { use } from 'react'; | ||
|
|
||
| export interface FloatingPanelCloseTriggerProps extends PropsWithElement<'button'>, HTMLAttributes<'button'> {} | ||
|
|
||
| export default function CloseTrigger(props: FloatingPanelCloseTriggerProps) { | ||
| const floatingPanel = use(RootContext); | ||
|
|
||
| const { element, children, ...rest } = props; | ||
|
|
||
| const attributes = mergeProps( | ||
| floatingPanel.getCloseTriggerProps(), | ||
| { | ||
| className: classesFloatingPanel.closeTrigger, | ||
| }, | ||
| rest, | ||
| ); | ||
|
|
||
| return element ? element(attributes) : <button {...attributes}>{children}</button>; | ||
| } |
24 changes: 24 additions & 0 deletions
24
packages/skeleton-react/src/components/floating-panel/anatomy/content.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { RootContext } from '../modules/root-context.js'; | ||
| import type { HTMLAttributes } from '@/internal/html-attributes.js'; | ||
| import type { PropsWithElement } from '@/internal/props-with-element.js'; | ||
| import { classesFloatingPanel } from '@skeletonlabs/skeleton-common'; | ||
| import { mergeProps } from '@zag-js/react'; | ||
| import { use } from 'react'; | ||
|
|
||
| export interface FloatingPanelContentProps extends PropsWithElement<'div'>, HTMLAttributes<'div'> {} | ||
|
|
||
| export default function Content(props: FloatingPanelContentProps) { | ||
| const floatingPanel = use(RootContext); | ||
|
|
||
| const { element, children, ...rest } = props; | ||
|
|
||
| const attributes = mergeProps( | ||
| floatingPanel.getContentProps(), | ||
| { | ||
| className: classesFloatingPanel.content, | ||
| }, | ||
| rest, | ||
| ); | ||
|
|
||
| return element ? element(attributes) : <div {...attributes}>{children}</div>; | ||
| } |
24 changes: 24 additions & 0 deletions
24
packages/skeleton-react/src/components/floating-panel/anatomy/control.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { RootContext } from '../modules/root-context.js'; | ||
| import type { HTMLAttributes } from '@/internal/html-attributes.js'; | ||
| import type { PropsWithElement } from '@/internal/props-with-element.js'; | ||
| import { classesFloatingPanel } from '@skeletonlabs/skeleton-common'; | ||
| import { mergeProps } from '@zag-js/react'; | ||
| import { use } from 'react'; | ||
|
|
||
| export interface FloatingPanelControlProps extends PropsWithElement<'div'>, HTMLAttributes<'div'> {} | ||
|
|
||
| export default function Control(props: FloatingPanelControlProps) { | ||
| const floatingPanel = use(RootContext); | ||
|
|
||
| const { element, children, ...rest } = props; | ||
|
|
||
| const attributes = mergeProps( | ||
| floatingPanel.getControlProps(), | ||
| { | ||
| className: classesFloatingPanel.control, | ||
| }, | ||
| rest, | ||
| ); | ||
|
|
||
| return element ? element(attributes) : <div {...attributes}>{children}</div>; | ||
| } |
24 changes: 24 additions & 0 deletions
24
packages/skeleton-react/src/components/floating-panel/anatomy/drag-trigger.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { RootContext } from '../modules/root-context.js'; | ||
| import type { HTMLAttributes } from '@/internal/html-attributes.js'; | ||
| import type { PropsWithElement } from '@/internal/props-with-element.js'; | ||
| import { classesFloatingPanel } from '@skeletonlabs/skeleton-common'; | ||
| import { mergeProps } from '@zag-js/react'; | ||
| import { use } from 'react'; | ||
|
|
||
| export interface FloatingPanelDragTriggerProps extends PropsWithElement<'div'>, HTMLAttributes<'div'> {} | ||
|
|
||
| export default function DragTrigger(props: FloatingPanelDragTriggerProps) { | ||
| const floatingPanel = use(RootContext); | ||
|
|
||
| const { element, children, ...rest } = props; | ||
|
|
||
| const attributes = mergeProps( | ||
| floatingPanel.getDragTriggerProps(), | ||
| { | ||
| className: classesFloatingPanel.dragTrigger, | ||
| }, | ||
| rest, | ||
| ); | ||
|
|
||
| return element ? element(attributes) : <div {...attributes}>{children}</div>; | ||
| } |
24 changes: 24 additions & 0 deletions
24
packages/skeleton-react/src/components/floating-panel/anatomy/header.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { RootContext } from '../modules/root-context.js'; | ||
| import type { HTMLAttributes } from '@/internal/html-attributes.js'; | ||
| import type { PropsWithElement } from '@/internal/props-with-element.js'; | ||
| import { classesFloatingPanel } from '@skeletonlabs/skeleton-common'; | ||
| import { mergeProps } from '@zag-js/react'; | ||
| import { use } from 'react'; | ||
|
|
||
| export interface FloatingPanelHeaderProps extends PropsWithElement<'div'>, HTMLAttributes<'div'> {} | ||
|
|
||
| export default function Header(props: FloatingPanelHeaderProps) { | ||
| const floatingPanel = use(RootContext); | ||
|
|
||
| const { element, children, ...rest } = props; | ||
|
|
||
| const attributes = mergeProps( | ||
| floatingPanel.getHeaderProps(), | ||
| { | ||
| className: classesFloatingPanel.header, | ||
| }, | ||
| rest, | ||
| ); | ||
|
|
||
| return element ? element(attributes) : <div {...attributes}>{children}</div>; | ||
| } |
24 changes: 24 additions & 0 deletions
24
packages/skeleton-react/src/components/floating-panel/anatomy/positioner.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { RootContext } from '../modules/root-context.js'; | ||
| import type { HTMLAttributes } from '@/internal/html-attributes.js'; | ||
| import type { PropsWithElement } from '@/internal/props-with-element.js'; | ||
| import { classesFloatingPanel } from '@skeletonlabs/skeleton-common'; | ||
| import { mergeProps } from '@zag-js/react'; | ||
| import { use } from 'react'; | ||
|
|
||
| export interface FloatingPanelPositionerProps extends PropsWithElement<'div'>, HTMLAttributes<'div'> {} | ||
|
|
||
| export default function Positioner(props: FloatingPanelPositionerProps) { | ||
| const floatingPanel = use(RootContext); | ||
|
|
||
| const { element, children, ...rest } = props; | ||
|
|
||
| const attributes = mergeProps( | ||
| floatingPanel.getPositionerProps(), | ||
| { | ||
| className: classesFloatingPanel.positioner, | ||
| }, | ||
| rest, | ||
| ); | ||
|
|
||
| return element ? element(attributes) : <div {...attributes}>{children}</div>; | ||
| } |
26 changes: 26 additions & 0 deletions
26
packages/skeleton-react/src/components/floating-panel/anatomy/resize-trigger.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import { RootContext } from '../modules/root-context.js'; | ||
| import type { HTMLAttributes } from '@/internal/html-attributes.js'; | ||
| import type { PropsWithElement } from '@/internal/props-with-element.js'; | ||
| import { classesFloatingPanel } from '@skeletonlabs/skeleton-common'; | ||
| import { splitResizeTriggerProps, type ResizeTriggerProps } from '@zag-js/floating-panel'; | ||
| import { mergeProps } from '@zag-js/react'; | ||
| import { use } from 'react'; | ||
|
|
||
| export interface FloatingPanelResizeTriggerProps extends ResizeTriggerProps, PropsWithElement<'div'>, HTMLAttributes<'div'> {} | ||
|
|
||
| export default function ResizeTrigger(props: FloatingPanelResizeTriggerProps) { | ||
| const floatingPanel = use(RootContext); | ||
|
|
||
| const [resizeTriggerProps, componentProps] = splitResizeTriggerProps(props); | ||
| const { element, children, ...rest } = componentProps; | ||
|
|
||
| const attributes = mergeProps( | ||
| floatingPanel.getResizeTriggerProps(resizeTriggerProps as ResizeTriggerProps), | ||
| { | ||
| className: classesFloatingPanel.resizeTrigger, | ||
| }, | ||
| rest, | ||
| ); | ||
|
|
||
| return element ? element(attributes) : <div {...attributes}>{children}</div>; | ||
| } |
15 changes: 15 additions & 0 deletions
15
packages/skeleton-react/src/components/floating-panel/anatomy/root-context.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import type { useFloatingPanel } from '../modules/provider.js'; | ||
| import { RootContext as RootContext_ } from '../modules/root-context.js'; | ||
| import { type ReactNode, use } from 'react'; | ||
|
|
||
| export interface FloatingPanelRootContextProps { | ||
| children: (floatingPanel: ReturnType<typeof useFloatingPanel>) => ReactNode; | ||
| } | ||
|
|
||
| export default function RootContext(props: FloatingPanelRootContextProps) { | ||
| const floatingPanel = use(RootContext_); | ||
|
|
||
| const { children } = props; | ||
|
|
||
| return children(floatingPanel); | ||
| } |
13 changes: 13 additions & 0 deletions
13
packages/skeleton-react/src/components/floating-panel/anatomy/root-provider.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import type { useFloatingPanel } from '../modules/provider.js'; | ||
| import { RootContext } from '../modules/root-context.js'; | ||
| import { type PropsWithChildren } from 'react'; | ||
|
|
||
| export interface FloatingPanelRootProviderProps extends PropsWithChildren { | ||
| value: ReturnType<typeof useFloatingPanel>; | ||
| } | ||
|
|
||
| export default function RootProvider(props: FloatingPanelRootProviderProps) { | ||
| const { children, value: floatingPanel } = props; | ||
|
|
||
| return <RootContext.Provider value={floatingPanel}>{children}</RootContext.Provider>; | ||
| } |
15 changes: 15 additions & 0 deletions
15
packages/skeleton-react/src/components/floating-panel/anatomy/root.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import { useFloatingPanel } from '../modules/provider.js'; | ||
| import { RootContext } from '../modules/root-context.js'; | ||
| import { type Props, splitProps } from '@zag-js/floating-panel'; | ||
| import { type PropsWithChildren } from 'react'; | ||
|
|
||
| export interface FloatingPanelRootProps extends PropsWithChildren, Omit<Props, 'id'> {} | ||
|
|
||
| export default function Root(props: FloatingPanelRootProps) { | ||
| const [floatingPanelProps, componentProps] = splitProps(props); | ||
| const { children } = componentProps; | ||
|
|
||
| const floatingPanel = useFloatingPanel(floatingPanelProps); | ||
|
|
||
| return <RootContext.Provider value={floatingPanel}>{children}</RootContext.Provider>; | ||
| } |
25 changes: 25 additions & 0 deletions
25
packages/skeleton-react/src/components/floating-panel/anatomy/stage-trigger.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { RootContext } from '../modules/root-context.js'; | ||
| import type { HTMLAttributes } from '@/internal/html-attributes.js'; | ||
| import type { PropsWithElement } from '@/internal/props-with-element.js'; | ||
| import { classesFloatingPanel } from '@skeletonlabs/skeleton-common'; | ||
| import { type StageTriggerProps } from '@zag-js/floating-panel'; | ||
| import { mergeProps } from '@zag-js/react'; | ||
| import { use } from 'react'; | ||
|
|
||
| export interface FloatingPanelStageTriggerProps extends StageTriggerProps, PropsWithElement<'button'>, HTMLAttributes<'button'> {} | ||
|
|
||
| export default function StageTrigger(props: FloatingPanelStageTriggerProps) { | ||
| const floatingPanel = use(RootContext); | ||
|
|
||
| const { element, children, stage, ...rest } = props; | ||
|
|
||
| const attributes = mergeProps( | ||
| floatingPanel.getStageTriggerProps({ stage }), | ||
| { | ||
| className: classesFloatingPanel.stageTrigger, | ||
| }, | ||
| rest, | ||
| ); | ||
|
|
||
| return element ? element(attributes) : <button {...attributes}>{children}</button>; | ||
| } |
24 changes: 24 additions & 0 deletions
24
packages/skeleton-react/src/components/floating-panel/anatomy/title.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { RootContext } from '../modules/root-context.js'; | ||
| import type { HTMLAttributes } from '@/internal/html-attributes.js'; | ||
| import type { PropsWithElement } from '@/internal/props-with-element.js'; | ||
| import { classesFloatingPanel } from '@skeletonlabs/skeleton-common'; | ||
| import { mergeProps } from '@zag-js/react'; | ||
| import { use } from 'react'; | ||
|
|
||
| export interface FloatingPanelTitleProps extends PropsWithElement<'div'>, HTMLAttributes<'div'> {} | ||
|
|
||
| export default function Title(props: FloatingPanelTitleProps) { | ||
| const floatingPanel = use(RootContext); | ||
|
|
||
| const { element, children, ...rest } = props; | ||
|
|
||
| const attributes = mergeProps( | ||
| floatingPanel.getTitleProps(), | ||
| { | ||
| className: classesFloatingPanel.title, | ||
| }, | ||
| rest, | ||
| ); | ||
|
|
||
| return element ? element(attributes) : <div {...attributes}>{children}</div>; | ||
| } |
24 changes: 24 additions & 0 deletions
24
packages/skeleton-react/src/components/floating-panel/anatomy/trigger.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { RootContext } from '../modules/root-context.js'; | ||
| import type { HTMLAttributes } from '@/internal/html-attributes.js'; | ||
| import type { PropsWithElement } from '@/internal/props-with-element.js'; | ||
| import { classesFloatingPanel } from '@skeletonlabs/skeleton-common'; | ||
| import { mergeProps } from '@zag-js/react'; | ||
| import { use } from 'react'; | ||
|
|
||
| export interface FloatingPanelTriggerProps extends PropsWithElement<'button'>, HTMLAttributes<'button'> {} | ||
|
|
||
| export default function Trigger(props: FloatingPanelTriggerProps) { | ||
| const floatingPanel = use(RootContext); | ||
|
|
||
| const { element, children, ...rest } = props; | ||
|
|
||
| const attributes = mergeProps( | ||
| floatingPanel.getTriggerProps(), | ||
| { | ||
| className: classesFloatingPanel.trigger, | ||
| }, | ||
| rest, | ||
| ); | ||
|
|
||
| return element ? element(attributes) : <button {...attributes}>{children}</button>; | ||
| } |
16 changes: 16 additions & 0 deletions
16
packages/skeleton-react/src/components/floating-panel/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| export type { FloatingPanelBodyProps } from './anatomy/body.jsx'; | ||
| export type { FloatingPanelCloseTriggerProps } from './anatomy/close-trigger.jsx'; | ||
| export type { FloatingPanelContentProps } from './anatomy/content.jsx'; | ||
| export type { FloatingPanelControlProps } from './anatomy/control.jsx'; | ||
| export type { FloatingPanelDragTriggerProps } from './anatomy/drag-trigger.jsx'; | ||
| export type { FloatingPanelHeaderProps } from './anatomy/header.jsx'; | ||
| export type { FloatingPanelPositionerProps } from './anatomy/positioner.jsx'; | ||
| export type { FloatingPanelResizeTriggerProps } from './anatomy/resize-trigger.jsx'; | ||
| export type { FloatingPanelRootProps } from './anatomy/root.jsx'; | ||
| export type { FloatingPanelRootContextProps } from './anatomy/root-context.jsx'; | ||
| export type { FloatingPanelRootProviderProps } from './anatomy/root-provider.jsx'; | ||
| export type { FloatingPanelStageTriggerProps } from './anatomy/stage-trigger.jsx'; | ||
| export type { FloatingPanelTitleProps } from './anatomy/title.jsx'; | ||
| export type { FloatingPanelTriggerProps } from './anatomy/trigger.jsx'; | ||
| export { FloatingPanel } from './modules/anatomy.js'; | ||
| export { useFloatingPanel } from './modules/provider.js'; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.