@@ -3,7 +3,8 @@ import styled from "styled-components"
33import { useState , useRef , useEffect } from "react"
44import { TextInput } from "./TextInput"
55import { Button } from "./Button"
6- import { EditIcon , CameraIcon , QuestionIcon } from "./icons"
6+ import { EditIcon , CameraIcon } from "./icons"
7+ import { HelpInfoButton } from "./HelpInfoButton"
78
89type NametagData = {
910 fullName : string
@@ -38,10 +39,8 @@ export const Nametag = ({
3839 const [ isEditing , setIsEditing ] = useState ( initialEditing || forcedEditMode )
3940 const [ formData , setFormData ] = useState < NametagData > ( data )
4041 const [ rotation , setRotation ] = useState ( { x : 0 , y : 0 } )
41- const [ openTooltip , setOpenTooltip ] = useState < string | null > ( null )
4242 const fileInputRef = useRef < HTMLInputElement > ( null )
4343 const containerRef = useRef < HTMLDivElement > ( null )
44- const tooltipRefs = useRef < { [ key : string ] : HTMLDivElement | null } > ( { } )
4544
4645 // In forced edit mode, always keep editing enabled (unless readOnly)
4746 // In readOnly mode, never allow editing
@@ -79,29 +78,6 @@ export const Nametag = ({
7978 // eslint-disable-next-line react-hooks/exhaustive-deps
8079 } , [ data , isEditing ] )
8180
82- // Close tooltip when clicking outside
83- useEffect ( ( ) => {
84- const handleClickOutside = ( event : MouseEvent ) => {
85- if ( openTooltip ) {
86- const tooltipElement = tooltipRefs . current [ openTooltip ]
87- if ( tooltipElement && ! tooltipElement . contains ( event . target as Node ) ) {
88- setOpenTooltip ( null )
89- }
90- }
91- }
92-
93- if ( openTooltip ) {
94- document . addEventListener ( "mousedown" , handleClickOutside )
95- return ( ) => {
96- document . removeEventListener ( "mousedown" , handleClickOutside )
97- }
98- }
99- } , [ openTooltip ] )
100-
101- const toggleTooltip = ( fieldName : string ) => {
102- setOpenTooltip ( openTooltip === fieldName ? null : fieldName )
103- }
104-
10581 const handleMouseMove = ( e : React . MouseEvent < HTMLDivElement > ) => {
10682 if ( ! containerRef . current ) return
10783
@@ -304,18 +280,7 @@ export const Nametag = ({
304280 required
305281 />
306282 </ NametagInputWrapper >
307- < HelpIconWrapper onClick = { ( ) => toggleTooltip ( "title" ) } >
308- < QuestionIcon />
309- { openTooltip === "title" && (
310- < Tooltip
311- ref = { ( el ) => {
312- tooltipRefs . current [ "title" ] = el
313- } }
314- >
315- Your job title or role.
316- </ Tooltip >
317- ) }
318- </ HelpIconWrapper >
283+ < HelpInfoButton > Your job title or role.</ HelpInfoButton >
319284 </ InputWithHelpContainer >
320285 </ NametagInputGroup >
321286
@@ -337,18 +302,7 @@ export const Nametag = ({
337302 required
338303 />
339304 </ NametagInputWrapper >
340- < HelpIconWrapper onClick = { ( ) => toggleTooltip ( "affiliation" ) } >
341- < QuestionIcon />
342- { openTooltip === "affiliation" && (
343- < Tooltip
344- ref = { ( el ) => {
345- tooltipRefs . current [ "affiliation" ] = el
346- } }
347- >
348- Your company, organization, or school name.
349- </ Tooltip >
350- ) }
351- </ HelpIconWrapper >
305+ < HelpInfoButton > Your company, organization, or school name.</ HelpInfoButton >
352306 </ InputWithHelpContainer >
353307 </ NametagInputGroup >
354308 </ NametagRight >
@@ -672,52 +626,6 @@ const NametagInputWrapper = styled.div<{ $fontSize?: string; $fontWeight?: strin
672626 }
673627`
674628
675- const HelpIconWrapper = styled . div `
676- position: relative;
677- cursor: pointer;
678- display: inline-flex;
679- align-items: center;
680- justify-content: center;
681- color: rgba(255, 255, 255, 0.6);
682- transition: color 0.2s ease;
683- flex-shrink: 0;
684-
685- &:hover {
686- color: rgba(255, 255, 255, 0.9);
687- }
688- `
689-
690- const Tooltip = styled . div `
691- position: absolute;
692- bottom: calc(100% + 8px);
693- right: 0;
694- background: rgba(0, 0, 0, 0.95);
695- color: rgba(255, 255, 255, 0.95);
696- padding: 0.75rem 1rem;
697- border-radius: 8px;
698- font-size: 0.875rem;
699- line-height: 1.4;
700- white-space: normal;
701- min-width: 200px;
702- max-width: 250px;
703- width: max-content;
704- z-index: 1000;
705- box-shadow:
706- 0 4px 12px rgba(0, 0, 0, 0.4),
707- 0 0 0 1px rgba(255, 255, 255, 0.1);
708- pointer-events: auto;
709-
710- &::after {
711- content: "";
712- position: absolute;
713- top: 100%;
714- right: 1rem;
715- transform: translateX(50%);
716- border: 6px solid transparent;
717- border-top-color: rgba(0, 0, 0, 0.95);
718- }
719- `
720-
721629const NametagDisplayText = styled . div < { $fontSize ?: string ; $fontWeight ?: string } > `
722630 font-size: ${ ( props ) => props . $fontSize || "1rem" } ;
723631 font-weight: ${ ( props ) => props . $fontWeight || "normal" } ;
0 commit comments