| 
1 | 1 | import type { FC } from "hono/jsx";  | 
2 |  | -import { HelpCircleIcon } from "../icons";  | 
 | 2 | +import { CloseIcon, HelpCircleIcon } from "../icons";  | 
3 | 3 | import { HtmlContent } from "./HtmlContent";  | 
4 | 4 | 
 
  | 
5 | 5 | type TooltipProps = {  | 
@@ -85,43 +85,81 @@ const tooltipContent: Record<  | 
85 | 85 | export const Tooltip: FC<TooltipProps> = ({ kind }) => {  | 
86 | 86 | 	const content = tooltipContent[kind];  | 
87 | 87 | 
 
  | 
88 |  | -	if (content.isShowLabel) {  | 
89 |  | -		return (  | 
 | 88 | +	return (  | 
 | 89 | +		<div  | 
 | 90 | +			className={  | 
 | 91 | +				content.isShowLabel  | 
 | 92 | +					? `tooltip-context px-2 py-1 ${content.bgColor} ${content.textColor} rounded-md text-xs font-medium flex items-center`  | 
 | 93 | +					: "tooltip-context relative inline-flex"  | 
 | 94 | +			}  | 
 | 95 | +			{...{ "x-data": "{ helpOpen: false }" }}  | 
 | 96 | +		>  | 
 | 97 | +			{content.isShowLabel && (  | 
 | 98 | +				<span class="text-xs font-medium mr-1">{content.label}</span>  | 
 | 99 | +			)}  | 
 | 100 | + | 
 | 101 | +			<button  | 
 | 102 | +				type="button"  | 
 | 103 | +				class="w-4 h-4 hover:bg-black/10 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 cursor-pointer"  | 
 | 104 | +				aria-label={`${content.label}の詳細情報を表示`}  | 
 | 105 | +				tabindex={0}  | 
 | 106 | +				{...{ "x-on:click": "helpOpen = true" }}  | 
 | 107 | +				{...{ "x-on:keydown.enter": "helpOpen = true" }}  | 
 | 108 | +				{...{ "x-on:keydown.space": "helpOpen = true" }}  | 
 | 109 | +			>  | 
 | 110 | +				<HelpCircleIcon />  | 
 | 111 | +			</button>  | 
 | 112 | + | 
90 | 113 | 			<div  | 
91 |  | -				className={`tooltip-context px-2 py-1 ${content.bgColor} ${content.textColor} rounded-md text-xs font-medium flex items-center`}  | 
 | 114 | +				{...{ "x-show": "helpOpen" }}  | 
 | 115 | +				class="fixed inset-0 bg-black/50 backdrop-blur-sm z-50 flex items-start justify-center pt-16"  | 
 | 116 | +				{...{ "x-cloak": "" }}  | 
 | 117 | +				{...{ "x-transition:enter": "ease-out duration-300" }}  | 
 | 118 | +				{...{ "x-transition:enter-start": "opacity-0" }}  | 
 | 119 | +				{...{ "x-transition:enter-end": "opacity-100" }}  | 
 | 120 | +				{...{ "x-transition:leave": "ease-in duration-200" }}  | 
 | 121 | +				{...{ "x-transition:leave-start": "opacity-100" }}  | 
 | 122 | +				{...{ "x-transition:leave-end": "opacity-0" }}  | 
 | 123 | +				{...{ "x-on:click": "helpOpen = false" }}  | 
 | 124 | +				{...{ "x-on:keydown.escape": "helpOpen = false" }}  | 
92 | 125 | 			>  | 
93 |  | -				<span class="text-xs font-medium mr-1">{content.label}</span>  | 
94 |  | -				<div class="relative group">  | 
95 |  | -					<div class="w-4 h-4">  | 
96 |  | -						<HelpCircleIcon />  | 
 | 126 | +				<div  | 
 | 127 | +					class="bg-white rounded-lg shadow-xl w-full max-w-md mx-4"  | 
 | 128 | +					{...{ "x-on:click.stop": "" }}  | 
 | 129 | +					{...{ "x-transition:enter": "ease-out duration-300" }}  | 
 | 130 | +					{...{ "x-transition:enter-start": "opacity-0 scale-95" }}  | 
 | 131 | +					{...{ "x-transition:enter-end": "opacity-100 scale-100" }}  | 
 | 132 | +					{...{ "x-transition:leave": "ease-in duration-200" }}  | 
 | 133 | +					{...{ "x-transition:leave-start": "opacity-100 scale-100" }}  | 
 | 134 | +					{...{ "x-transition:leave-end": "opacity-0 scale-95" }}  | 
 | 135 | +				>  | 
 | 136 | +					<div class="flex justify-between items-center p-4 border-b border-gray-200">  | 
 | 137 | +						<div  | 
 | 138 | +							class={`px-3 py-1 ${content.bgColor} ${content.textColor} rounded-md text-sm font-medium`}  | 
 | 139 | +						>  | 
 | 140 | +							{content.label}  | 
 | 141 | +						</div>  | 
 | 142 | +						<button  | 
 | 143 | +							type="button"  | 
 | 144 | +							class="text-gray-400 hover:text-gray-600 cursor-pointer"  | 
 | 145 | +							tabindex={0}  | 
 | 146 | +							{...{ "x-on:click": "helpOpen = false" }}  | 
 | 147 | +							{...{ "x-on:keydown.enter": "helpOpen = false" }}  | 
 | 148 | +							{...{ "x-on:keydown.space": "helpOpen = false" }}  | 
 | 149 | +							aria-label="閉じる"  | 
 | 150 | +						>  | 
 | 151 | +							<div class="w-6 h-6">  | 
 | 152 | +								<CloseIcon />  | 
 | 153 | +							</div>  | 
 | 154 | +						</button>  | 
97 | 155 | 					</div>  | 
98 |  | -					<div  | 
99 |  | -						role="tooltip"  | 
100 |  | -						tabIndex={-1}  | 
101 |  | -						class="absolute invisible opacity-0 group-hover:visible group-hover:opacity-100  | 
102 |  | -                  transition-opacity duration-200 bg-gray-900 text-white p-2 rounded shadow-lg  | 
103 |  | -                  text-xs z-50 top-full mt-1 -left-4 w-64"  | 
104 |  | -					>  | 
105 |  | -						<HtmlContent html={content.desc} />  | 
 | 156 | +					<div class="p-4">  | 
 | 157 | +						<div class="text-sm font-normal text-gray-700">  | 
 | 158 | +							<HtmlContent html={content.desc} />  | 
 | 159 | +						</div>  | 
106 | 160 | 					</div>  | 
107 | 161 | 				</div>  | 
108 | 162 | 			</div>  | 
109 |  | -		);  | 
110 |  | -	}  | 
111 |  | -	return (  | 
112 |  | -		<div class="tooltip-context relative group inline-flex">  | 
113 |  | -			<div class="w-4 h-4">  | 
114 |  | -				<HelpCircleIcon />  | 
115 |  | -			</div>  | 
116 |  | -			<div  | 
117 |  | -				role="tooltip"  | 
118 |  | -				tabIndex={-1}  | 
119 |  | -				class="absolute invisible opacity-0 group-hover:visible group-hover:opacity-100  | 
120 |  | -                transition-opacity duration-200 bg-gray-900 text-white p-2 rounded shadow-lg  | 
121 |  | -                text-xs z-50 top-full mt-1 -left-4 w-64"  | 
122 |  | -			>  | 
123 |  | -				<HtmlContent html={content.desc} />  | 
124 |  | -			</div>  | 
125 | 163 | 		</div>  | 
126 | 164 | 	);  | 
127 | 165 | };  | 
0 commit comments