-
Notifications
You must be signed in to change notification settings - Fork 56
:sparkles feat(day-view): show preview for new events #1371
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
Merged
victor-enogwe
merged 5 commits into
main
from
feat-select-agenda-surface-create-event-1333
Dec 18, 2025
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ec465ed
:sparkles feat(day-view): show preview for new events
victor-enogwe 86ecb51
:sparkles feat: refactor event handling and improve test setups
victor-enogwe e2c9452
fix: update existing event check to return false instead of null
victor-enogwe ef70016
Update packages/web/src/components/DND/Resizable.tsx
victor-enogwe 8386e64
:bug fix: ensure element scrolls into view before focusing in focusEl…
victor-enogwe 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
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
This file was deleted.
Oops, something went wrong.
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,80 @@ | ||
| import { useCallback, useState } from "react"; | ||
| import { | ||
| OpenChangeReason, | ||
| Placement, | ||
| ReferenceType, | ||
| UseFloatingOptions, | ||
| autoUpdate, | ||
| flip, | ||
| offset, | ||
| useFloating, | ||
| } from "@floating-ui/react"; | ||
| import { | ||
| closeFloatingAtCursor, | ||
| useFloatingNodeIdAtCursor, | ||
| useFloatingPlacementAtCursor, | ||
| useFloatingReferenceAtCursor, | ||
| useFloatingStrategyAtCursor, | ||
| } from "@web/common/hooks/useOpenAtCursor"; | ||
| import { theme } from "@web/common/styles/theme"; | ||
|
|
||
| const themeSpacing = parseInt(theme.spacing.xs); | ||
|
|
||
| const placements: Placement[] = [ | ||
| "right-start", | ||
| "bottom-start", | ||
| "top-start", | ||
| "left-start", | ||
| ]; | ||
|
|
||
| export function useFloatingAtCursor( | ||
| onOpenChange?: UseFloatingOptions<ReferenceType>["onOpenChange"], | ||
| ): ReturnType<typeof useFloating> { | ||
| const [open, setOpen] = useState(false); | ||
| const nodeId = useFloatingNodeIdAtCursor() ?? undefined; | ||
| const placement = useFloatingPlacementAtCursor(); | ||
| const strategy = useFloatingStrategyAtCursor(); | ||
| const reference = useFloatingReferenceAtCursor(); | ||
|
|
||
| const handleOpenChange = useCallback( | ||
| (open: boolean, event?: Event, reason?: OpenChangeReason) => { | ||
| onOpenChange?.(open, event, reason); | ||
|
|
||
| if (!open) closeFloatingAtCursor(); | ||
|
|
||
| setOpen(open); | ||
| }, | ||
| [onOpenChange], | ||
| ); | ||
|
|
||
| const floating = useFloating({ | ||
| open, | ||
| nodeId, | ||
| placement, | ||
| strategy, | ||
| elements: { reference }, | ||
| middleware: [ | ||
| offset(({ rects, placement }) => { | ||
| switch (placement) { | ||
| case "bottom": | ||
| case "top": | ||
| return -rects.reference.height / 2 - rects.floating.height / 2; | ||
| default: | ||
| return themeSpacing; | ||
| } | ||
| }), | ||
| flip(({ placement }) => { | ||
| return { | ||
| fallbackPlacements: placements.filter((p) => p !== placement), | ||
| fallbackStrategy: "bestFit", | ||
| fallbackAxisSideDirection: "start", | ||
| crossAxis: placement.includes("-"), | ||
| }; | ||
| }), | ||
| ], | ||
| onOpenChange: handleOpenChange, | ||
| whileElementsMounted: autoUpdate, | ||
| }); | ||
|
|
||
| return floating; | ||
| } |
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,17 @@ | ||
| import { useEffect, useState } from "react"; | ||
| import { distinctUntilChanged, share } from "rxjs/operators"; | ||
| import { maxGridZIndex$ } from "@web/common/utils/dom/grid-organization.util"; | ||
|
|
||
| const maxZIndex$ = maxGridZIndex$.pipe(distinctUntilChanged(), share()); | ||
|
|
||
| export function useGridMaxZIndex() { | ||
| const [maxZIndex, setMaxZIndex] = useState(maxGridZIndex$.getValue()); | ||
|
|
||
| useEffect(() => { | ||
| const subscription = maxZIndex$.subscribe(setMaxZIndex); | ||
|
|
||
| return () => subscription.unsubscribe(); | ||
| }, []); | ||
|
|
||
| return maxZIndex; | ||
| } |
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 |
|---|---|---|
| @@ -1,25 +1,90 @@ | ||
| import { useEffect } from "react"; | ||
| import { UseFloatingOptions } from "@floating-ui/react"; | ||
| import { | ||
| OpenAtCursorContext, | ||
| openedAtCursorChange$, | ||
| } from "@web/common/context/open-at-cursor"; | ||
| import { useMetaContext } from "@web/common/hooks/useMetaContext"; | ||
|
|
||
| export function useOpenAtCursor({ | ||
| onOpenChange, | ||
| }: Pick<UseFloatingOptions, "onOpenChange"> = {}) { | ||
| const context = useMetaContext(OpenAtCursorContext, "useOpenAtCursor"); | ||
| import { useEffect, useState } from "react"; | ||
| import { BehaviorSubject, Observable, distinctUntilChanged, share } from "rxjs"; | ||
| import { Placement, Strategy } from "@floating-ui/react"; | ||
|
|
||
| export enum CursorItem { | ||
| EventForm = "EventForm", | ||
| EventPreview = "EventPreview", | ||
| EventContextMenu = "EventContextMenu", | ||
| } | ||
|
|
||
| const nodeId$ = new BehaviorSubject<CursorItem | null>(null); | ||
| const placement$ = new BehaviorSubject<Placement>("right-start"); | ||
| const strategy$ = new BehaviorSubject<Strategy>("absolute"); | ||
| const reference$ = new BehaviorSubject<Element | null>(null); | ||
| const $nodeId = nodeId$.pipe(distinctUntilChanged(), share()); | ||
| const $placement = placement$.pipe(distinctUntilChanged(), share()); | ||
| const $strategy = strategy$.pipe(distinctUntilChanged(), share()); | ||
| const $reference = reference$.pipe(distinctUntilChanged(), share()); | ||
|
|
||
| function useValue<T>( | ||
| subject: BehaviorSubject<T>, | ||
| sharedSubject: Observable<T>, | ||
| ): T { | ||
| const [value, setValue] = useState<T>(subject.getValue()); | ||
|
|
||
| useEffect(() => { | ||
| if (onOpenChange) { | ||
| const subscription = openedAtCursorChange$.subscribe((args) => | ||
| onOpenChange(...args), | ||
| ); | ||
| const subscription = sharedSubject.subscribe((v) => { | ||
| setValue(v); | ||
| }); | ||
|
|
||
| return () => subscription.unsubscribe(); | ||
| }); | ||
|
|
||
| return value; | ||
| } | ||
|
|
||
| export function useFloatingNodeIdAtCursor(): CursorItem | null { | ||
| return useValue<CursorItem | null>(nodeId$, $nodeId); | ||
| } | ||
|
|
||
| export function useFloatingPlacementAtCursor(): Placement { | ||
| return useValue<Placement>(placement$, $placement); | ||
| } | ||
|
|
||
| export function useFloatingStrategyAtCursor(): Strategy { | ||
| return useValue<Strategy>(strategy$, $strategy); | ||
| } | ||
|
|
||
| export function useFloatingReferenceAtCursor(): Element | null { | ||
| return useValue<Element | null>(reference$, $reference); | ||
| } | ||
|
|
||
| export function setFloatingNodeIdAtCursor(nodeId: CursorItem | null) { | ||
| nodeId$.next(nodeId); | ||
| } | ||
|
|
||
| export function setFloatingPlacementAtCursor(placement: Placement) { | ||
| placement$.next(placement); | ||
| } | ||
|
|
||
| export function setFloatingStrategyAtCursor(strategy: Strategy) { | ||
| strategy$.next(strategy); | ||
| } | ||
|
|
||
| return () => subscription.unsubscribe(); | ||
| } | ||
| }, [onOpenChange]); | ||
| export function setFloatingReferenceAtCursor(reference: Element | null) { | ||
| reference$.next(reference); | ||
| } | ||
|
|
||
| export function openFloatingAtCursor({ | ||
| nodeId, | ||
| reference, | ||
| placement = "right-start", | ||
| strategy = "absolute", | ||
| }: { | ||
| nodeId: CursorItem; | ||
| reference: Element; | ||
| placement?: Placement; | ||
| strategy?: Strategy; | ||
| }) { | ||
| setFloatingNodeIdAtCursor(nodeId); | ||
| setFloatingPlacementAtCursor(placement); | ||
| setFloatingStrategyAtCursor(strategy); | ||
| setFloatingReferenceAtCursor(reference); | ||
| } | ||
|
|
||
| return context; | ||
| export function closeFloatingAtCursor() { | ||
| setFloatingNodeIdAtCursor(null); | ||
| setFloatingPlacementAtCursor("right-start"); | ||
| setFloatingReferenceAtCursor(null); | ||
| } | ||
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.