From 6beb5ca88765ef9a35648d4b01ed775cba23ae11 Mon Sep 17 00:00:00 2001 From: jamiegyoung Date: Sun, 17 Dec 2023 03:27:34 +0000 Subject: [PATCH] fix(modified): fix modified tooltip clipping --- src/components/atoms/Modified.module.css | 55 ++++++++++++++++++------ src/components/atoms/Modified.tsx | 4 +- 2 files changed, 44 insertions(+), 15 deletions(-) diff --git a/src/components/atoms/Modified.module.css b/src/components/atoms/Modified.module.css index 4e39084..fe5702f 100644 --- a/src/components/atoms/Modified.module.css +++ b/src/components/atoms/Modified.module.css @@ -1,37 +1,64 @@ .tooltip { + display: inline-flex; + cursor: help; + align-items: flex-start; +} + +.tooltipWrapper { + position: absolute; + margin-left: 124px; +} + +.modifiedText { position: relative; cursor: help; color: white; margin: 0; } -.tooltip .tooltiptext { - visibility: hidden; - width: 200px; +.tooltipText { background-color: var(--color-card); - color: white; - text-align: center; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.5); border-radius: 6px; padding: 10px; + width: 150px; position: absolute; - z-index: 1; - bottom: 150%; - left: 0%; - margin-left: -80px; - box-shadow: 0 0 10px rgba(0, 0, 0, 0.5); + height: fit-content; + bottom: 0; + right: 0; + opacity: 0; + pointer-events: none; + transition: opacity 0.1s ease-in-out; + margin-bottom: 10px; +} + +@media (prefers-reduced-motion) { + transition: none; +} + + +.tooltip:hover .tooltipText { + opacity: 1; + pointer-events: auto; +} + +.tooltipText:hover { + opacity: 1; + pointer-events: auto; } -.tooltip .tooltiptext::after { +.tooltipText::after { content: ''; position: absolute; top: 100%; left: 50%; - margin-left: -5px; - border-width: 5px; + margin-left: -10px; + border-width: 10px; + padding-bottom: 20px; border-style: solid; border-color: var(--color-card) transparent transparent transparent; } -.tooltip:hover .tooltiptext { +.modifiedText:hover .tooltipText { visibility: visible; } diff --git a/src/components/atoms/Modified.tsx b/src/components/atoms/Modified.tsx index f94fbe2..7696ff1 100644 --- a/src/components/atoms/Modified.tsx +++ b/src/components/atoms/Modified.tsx @@ -4,7 +4,9 @@ export default function Modified({ children }: { children: string }) { return ( (modified) - {children} + + {children} + ); }