MCPcopy Create free account
hub / github.com/dailydotdev/apps / AlertPointer

Function AlertPointer

packages/shared/src/components/alert/AlertPointer.tsx:85–139  ·  view source on GitHub ↗
({
  placement = AlertPlacement.Right,
  color = PointerColor.Cabbage,
  className = {},
  children,
  message,
  offset,
  isAlertDisabled,
  onClose,
}: AlertPointerProps)

Source from the content-addressed store, hash-verified

83});
84
85export default function AlertPointer({
86 placement = AlertPlacement.Right,
87 color = PointerColor.Cabbage,
88 className = {},
89 children,
90 message,
91 offset,
92 isAlertDisabled,
93 onClose,
94}: AlertPointerProps): ReactElement {
95 const pointerRef = useRef<HTMLDivElement | null>(null);
96 const rect = pointerRef?.current?.getBoundingClientRect?.();
97
98 if (isAlertDisabled) {
99 return <>{children}</>;
100 }
101
102 return (
103 <AlertPointerWrapper className={className.wrapper}>
104 {children}
105 <AlertPointerContainer
106 style={getContainerStyle(offset)[placement]}
107 className={classNames(
108 alertContainerClasses[placement],
109 className.container,
110 )}
111 >
112 <Pointer
113 ref={pointerRef}
114 color={color}
115 className={classNames(pointerClasses[placement], className.pointer)}
116 />
117 <AlertPointerMessage
118 className={classNames(messageBorder[color], className.message)}
119 style={getMessageStyle(rect?.height)[placement]}
120 >
121 {typeof message === 'string' ? (
122 <AlertPointerCopy className={className.label}>
123 {message}
124 </AlertPointerCopy>
125 ) : (
126 message
127 )}
128 <CloseButton
129 data-testid="alert-close"
130 onClick={onClose}
131 size={ButtonSize.XSmall}
132 className="absolute right-2 top-2"
133 type="button"
134 />
135 </AlertPointerMessage>
136 </AlertPointerContainer>
137 </AlertPointerWrapper>
138 );
139}

Callers

nothing calls this directly

Calls 2

getContainerStyleFunction · 0.85
getMessageStyleFunction · 0.85

Tested by

no test coverage detected