diff --git a/packages/core/src/components/Trigger.tsx b/packages/core/src/components/Trigger.tsx index 062ba5cc..12f88bb9 100644 --- a/packages/core/src/components/Trigger.tsx +++ b/packages/core/src/components/Trigger.tsx @@ -1,11 +1,22 @@ +import { ComponentPropsWithoutRef } from 'react'; import { ReactComponent as Logo } from '~/assets/glyph.svg'; import classNames from '../lib/classNames'; import { TriggerButtonCount } from '../types'; -export type Anchor = 'bottomRight' | 'bottomLeft'; +export const DEFAULT_ANCHOR = 'bottomRight'; + +export type Anchor = 'bottomRight' | 'bottomLeft' | 'centerRight' | 'centerLeft' | 'topLeft' | 'topRight'; function getAnchorClasses(anchor: Anchor) { switch (anchor) { + case 'centerRight': + return 'bottom-[45%] right-4'; + case 'centerLeft': + return 'bottom-[45%] left-4'; + case 'topLeft': + return 'top-4 left-4'; + case 'topRight': + return 'top-4 right-4'; case 'bottomLeft': return 'bottom-4 left-4'; case 'bottomRight': @@ -14,11 +25,38 @@ function getAnchorClasses(anchor: Anchor) { } } +function ToolbarItem({ + count, + children, + severe = false, + ...props +}: Omit, 'className'> & { + severe?: boolean; + count?: number | null; +}) { + return ( +
+ {children} + + {!!count && ( + + {count} + + )} +
+ ); +} + export default function Trigger({ isOpen, setOpen, count, - anchor = 'bottomRight', + anchor = DEFAULT_ANCHOR, }: { isOpen: boolean; setOpen: (value: boolean) => void; @@ -26,23 +64,25 @@ export default function Trigger({ anchor?: Anchor; }) { const countSum = count.general + count.severe; + const iconSize = 24; return (
setOpen(!isOpen)} > - - {countSum} + + +
); } diff --git a/packages/core/src/index.tsx b/packages/core/src/index.tsx index e4c4178d..7ce3ccea 100644 --- a/packages/core/src/index.tsx +++ b/packages/core/src/index.tsx @@ -4,7 +4,7 @@ import fontStyles from '@fontsource/raleway/index.css?inline'; import spotlightEventTarget from './lib/eventTarget.ts'; import App from './App.tsx'; -import { type Anchor } from './components/Trigger.tsx'; +import { DEFAULT_ANCHOR, type Anchor } from './components/Trigger.tsx'; import globalStyles from './index.css?inline'; import type { Integration } from './integrations/integration.ts'; import { initIntegrations } from './integrations/integration.ts'; @@ -50,7 +50,7 @@ export async function init({ defaultEventId, injectImmediately = false, sidecar = DEFAULT_SIDECAR, - anchor = 'bottomRight', + anchor = DEFAULT_ANCHOR, }: { integrations?: Integration[]; fullScreen?: boolean;