-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
switch emoji picker to emojimart and add a proper Ark UI popover style
- Loading branch information
1 parent
5f7dbd5
commit 71d0be3
Showing
12 changed files
with
231 additions
and
56 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
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
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
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
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,43 +1,31 @@ | ||
import { NativeRenderer, createPicker } from "picmo"; | ||
import { mutate } from "swr"; | ||
|
||
import { postReactAdd } from "src/api/openapi/posts"; | ||
import { PostProps } from "src/api/openapi/schemas"; | ||
import { getThreadGetKey } from "src/api/openapi/threads"; | ||
import { useSession } from "src/auth"; | ||
|
||
export const emojiPickerContainerID = `react-emoji-select`; | ||
|
||
export type Props = PostProps & { | ||
slug?: string; | ||
}; | ||
|
||
type EmojiSelectEvent = { | ||
native: string; | ||
}; | ||
|
||
export function useReactList(props: Props) { | ||
const account = useSession(); | ||
const authenticated = !!account; | ||
|
||
async function onSelect(event: { emoji: string }) { | ||
await postReactAdd(props.id, { emoji: event.emoji }); | ||
async function onSelect(event: EmojiSelectEvent) { | ||
await postReactAdd(props.id, { emoji: event.native }); | ||
props.slug && mutate(getThreadGetKey(props.slug)); | ||
} | ||
|
||
async function onOpen() { | ||
const rootElement = document.querySelector( | ||
`#${emojiPickerContainerID}-${props.id}`, | ||
) as HTMLElement; | ||
|
||
if (!rootElement) { | ||
throw new Error("cannot find emoji picker container"); | ||
} | ||
|
||
const picker = createPicker({ | ||
rootElement, | ||
renderer: new NativeRenderer(), | ||
// emojiSize: "1.8rem", | ||
}); | ||
|
||
picker.addEventListener("emoji:select", onSelect); | ||
} | ||
|
||
return { onOpen, authenticated }; | ||
return { | ||
authenticated, | ||
handlers: { | ||
onSelect, | ||
}, | ||
}; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { Popover as ArkPopover } from "@ark-ui/react/popover"; | ||
import { styled } from "styled-system/jsx"; | ||
import { popover } from "styled-system/recipes"; | ||
|
||
import { createStyleContext } from "src/theme/create-style-context"; | ||
|
||
const { withProvider, withContext } = createStyleContext(popover); | ||
|
||
const Popover = withProvider(ArkPopover.Root); | ||
const PopoverAnchor = withContext(styled(ArkPopover.Anchor), "anchor"); | ||
const PopoverArrow = withContext(styled(ArkPopover.Arrow), "arrow"); | ||
const PopoverArrowTip = withContext(styled(ArkPopover.ArrowTip), "arrowTip"); | ||
const PopoverCloseTrigger = withContext( | ||
styled(ArkPopover.CloseTrigger), | ||
"closeTrigger", | ||
); | ||
const PopoverContent = withContext(styled(ArkPopover.Content), "content"); | ||
const PopoverDescription = withContext( | ||
styled(ArkPopover.Description), | ||
"description", | ||
); | ||
// const PopoverIndicator = withContext(styled(ArkPopover.Indicator), "indicator"); | ||
const PopoverPositioner = withContext( | ||
styled(ArkPopover.Positioner), | ||
"positioner", | ||
); | ||
const PopoverTitle = withContext(styled(ArkPopover.Title), "title"); | ||
const PopoverTrigger = withContext(styled(ArkPopover.Trigger), "trigger"); | ||
|
||
export { | ||
Popover, | ||
PopoverAnchor, | ||
PopoverArrow, | ||
PopoverArrowTip, | ||
PopoverCloseTrigger, | ||
PopoverContent, | ||
PopoverDescription, | ||
// PopoverIndicator, | ||
PopoverPositioner, | ||
PopoverTitle, | ||
PopoverTrigger, | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { popoverAnatomy } from "@ark-ui/react"; | ||
import { defineSlotRecipe } from "@pandacss/dev"; | ||
|
||
export const popover = defineSlotRecipe({ | ||
className: "popover", | ||
slots: popoverAnatomy.keys(), | ||
base: { | ||
positioner: { | ||
position: "relative", | ||
zIndex: "popover", | ||
}, | ||
content: { | ||
borderRadius: "lg", | ||
boxShadow: "lg", | ||
display: "flex", | ||
flexDirection: "column", | ||
maxWidth: "sm", | ||
_open: { | ||
animation: "fadeIn 0.25s ease-out", | ||
}, | ||
_closed: { | ||
animation: "fadeOut 0.2s ease-out", | ||
}, | ||
_hidden: { | ||
display: "none", | ||
}, | ||
}, | ||
title: { | ||
fontWeight: "medium", | ||
textStyle: "sm", | ||
}, | ||
description: { | ||
color: "fg.muted", | ||
textStyle: "sm", | ||
}, | ||
closeTrigger: { | ||
color: "fg.muted", | ||
}, | ||
}, | ||
}); |
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
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
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* eslint-disable */ | ||
import type { ConditionalValue } from '../types/index'; | ||
import type { Pretty } from '../types/helpers'; | ||
import type { DistributiveOmit } from '../types/system-types'; | ||
|
||
interface PopoverVariant { | ||
|
||
} | ||
|
||
type PopoverVariantMap = { | ||
[key in keyof PopoverVariant]: Array<PopoverVariant[key]> | ||
} | ||
|
||
export type PopoverVariantProps = { | ||
[key in keyof PopoverVariant]?: ConditionalValue<PopoverVariant[key]> | ||
} | ||
|
||
export interface PopoverRecipe { | ||
__type: PopoverVariantProps | ||
(props?: PopoverVariantProps): Pretty<Record<"arrow" | "arrowTip" | "anchor" | "trigger" | "positioner" | "content" | "title" | "description" | "closeTrigger", string>> | ||
raw: (props?: PopoverVariantProps) => PopoverVariantProps | ||
variantMap: PopoverVariantMap | ||
variantKeys: Array<keyof PopoverVariant> | ||
splitVariantProps<Props extends PopoverVariantProps>(props: Props): [PopoverVariantProps, Pretty<DistributiveOmit<Props, keyof PopoverVariantProps>>] | ||
} | ||
|
||
|
||
export declare const popover: PopoverRecipe |
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { splitProps, getSlotCompoundVariant } from '../helpers.mjs'; | ||
import { createRecipe } from './create-recipe.mjs'; | ||
|
||
const popoverDefaultVariants = {} | ||
const popoverCompoundVariants = [] | ||
|
||
const popoverSlotNames = [ | ||
[ | ||
"arrow", | ||
"popover__arrow" | ||
], | ||
[ | ||
"arrowTip", | ||
"popover__arrowTip" | ||
], | ||
[ | ||
"anchor", | ||
"popover__anchor" | ||
], | ||
[ | ||
"trigger", | ||
"popover__trigger" | ||
], | ||
[ | ||
"positioner", | ||
"popover__positioner" | ||
], | ||
[ | ||
"content", | ||
"popover__content" | ||
], | ||
[ | ||
"title", | ||
"popover__title" | ||
], | ||
[ | ||
"description", | ||
"popover__description" | ||
], | ||
[ | ||
"closeTrigger", | ||
"popover__closeTrigger" | ||
] | ||
] | ||
const popoverSlotFns = /* @__PURE__ */ popoverSlotNames.map(([slotName, slotKey]) => [slotName, createRecipe(slotKey, popoverDefaultVariants, getSlotCompoundVariant(popoverCompoundVariants, slotName))]) | ||
|
||
const popoverFn = (props = {}) => { | ||
return Object.fromEntries(popoverSlotFns.map(([slotName, slotFn]) => [slotName, slotFn(props)])) | ||
} | ||
|
||
const popoverVariantKeys = [] | ||
|
||
export const popover = /* @__PURE__ */ Object.assign(popoverFn, { | ||
__recipe__: false, | ||
__name__: 'popover', | ||
raw: (props) => props, | ||
variantKeys: popoverVariantKeys, | ||
variantMap: {}, | ||
splitVariantProps(props) { | ||
return splitProps(props, popoverVariantKeys) | ||
}, | ||
}) |
Oops, something went wrong.
71d0be3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
storyden-homepage – ./home
www.storyden.org
storyden.org
storyden-homepage-git-main-southclaws.vercel.app
storyden-homepage.vercel.app
storyden-homepage-southclaws.vercel.app
71d0be3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
storyden – ./web
storyden-southclaws.vercel.app
storyden.vercel.app
www.makeroom.club
storyden-git-main-southclaws.vercel.app
makeroom.club
demo.storyden.org