-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Factor out a
ViewAsUserMenuItem
component
- Loading branch information
1 parent
0126cbe
commit ff4c407
Showing
2 changed files
with
52 additions
and
29 deletions.
There are no files selected for viewing
This file contains 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
45 changes: 44 additions & 1 deletion
45
web-admin/src/features/view-as-user/ViewAsUserMenuItem.svelte
This file contains 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 +1,44 @@ | ||
<!-- TODO: move code from `UserButton.svelte` --> | ||
<script lang="ts"> | ||
import { page } from "$app/stores"; | ||
import type { Modifier } from "@popperjs/core"; | ||
import { | ||
Popover, | ||
PopoverButton, | ||
PopoverPanel, | ||
} from "@rgossiaux/svelte-headlessui"; | ||
import CaretDownIcon from "@rilldata/web-common/components/icons/CaretDownIcon.svelte"; | ||
import { MenuItem } from "@rilldata/web-common/components/menu"; | ||
import { createEventDispatcher } from "svelte"; | ||
import type { ContentAction } from "svelte-popperjs"; | ||
import ViewAsUserPopover from "../../features/view-as-user/ViewAsUserPopover.svelte"; | ||
export let popperContent: ContentAction<Partial<Modifier<any, any>>>; | ||
const popperOptions = { | ||
placement: "left-start", | ||
strategy: "fixed", | ||
modifiers: [{ name: "offset", options: { offset: [0, 4] } }], | ||
}; | ||
const dispatch = createEventDispatcher(); | ||
</script> | ||
|
||
<Popover> | ||
<PopoverButton class="w-full text-left"> | ||
<MenuItem animateSelect={false}> | ||
View as | ||
<CaretDownIcon | ||
className="transform -rotate-90" | ||
slot="right" | ||
size="14px" | ||
/> | ||
</MenuItem> | ||
</PopoverButton> | ||
<PopoverPanel use={[[popperContent, popperOptions]]}> | ||
<ViewAsUserPopover | ||
organization={$page.params.organization} | ||
project={$page.params.project} | ||
on:select={() => dispatch("select-user")} | ||
/> | ||
</PopoverPanel> | ||
</Popover> |