From 7932979613593527d036d31b9a9c789f44c1e3a7 Mon Sep 17 00:00:00 2001 From: Egor Berezovskiy Date: Thu, 19 Dec 2024 17:05:06 +0100 Subject: [PATCH] front: ui-core input tooltip status messages Signed-off-by: Egor Berezovskiy --- ui-core/src/components/inputs/Input.tsx | 1 + .../src/components/inputs/StatusMessage.tsx | 13 ++++- ui-core/src/stories/Input.stories.tsx | 34 +++++++++++ ui-core/src/styles/inputs/fieldWrapper.css | 56 ++++++++++++++++++- 4 files changed, 99 insertions(+), 5 deletions(-) diff --git a/ui-core/src/components/inputs/Input.tsx b/ui-core/src/components/inputs/Input.tsx index f896c0d72..90553ef4a 100644 --- a/ui-core/src/components/inputs/Input.tsx +++ b/ui-core/src/components/inputs/Input.tsx @@ -86,6 +86,7 @@ const Input = React.forwardRef( disabled={disabled} required={required} small={small} + statusIconPosition="before-status-message" className={cx('input-field-wrapper', inputFieldWrapperClassname)} >
{ - const { status, message } = statusWithMessage; + const { tooltip, status, message } = statusWithMessage; if (message === undefined) return null; return ( -
+
{showIcon && } {message}
diff --git a/ui-core/src/stories/Input.stories.tsx b/ui-core/src/stories/Input.stories.tsx index aa869bec9..068be6a58 100644 --- a/ui-core/src/stories/Input.stories.tsx +++ b/ui-core/src/stories/Input.stories.tsx @@ -172,6 +172,40 @@ export const ErrorInput: Story = { }, }, }; +export const TooltipErrorInput: Story = { + decorators: [ + (Story) => ( +
+ + +
+ ), + ], +}; export const ErrorWithoutMessageInput: Story = { args: { diff --git a/ui-core/src/styles/inputs/fieldWrapper.css b/ui-core/src/styles/inputs/fieldWrapper.css index cd8112c39..08eb530cc 100644 --- a/ui-core/src/styles/inputs/fieldWrapper.css +++ b/ui-core/src/styles/inputs/fieldWrapper.css @@ -1,23 +1,28 @@ +:root { + --tooltip-transition-duration: 0.2s; +} + .feed-back { border-radius: 0.5rem; position: relative; padding: 0.625rem 0.813rem 1rem 1rem; - &.info { + &.info:not(:has(.status-message-wrapper-tooltip)) { @apply bg-info-5; } - &.warning { + &.warning:not(:has(.status-message-wrapper-tooltip)) { @apply bg-warning-5; } - &.error { + &.error:not(:has(.status-message-wrapper-tooltip)) { @apply bg-error-5; } .custom-field { display: flex; flex-direction: column; + position: relative; .field-and-status-icon, .field-wrapper-status-message { @@ -28,5 +33,50 @@ margin-left: 0.563rem; } } + + input:focus:has(.status-message-wrapper-tooltip) .status-message-wrapper-tooltip { + z-index: 2; + } + + .status-message-wrapper-tooltip { + position: absolute; + display: flex; + align-items: center; + top: 60px; + gap: 12px; + border-radius: 8px; + box-shadow: 0px 10px 20px 0px rgba(0, 0, 0, 0.2), 0px 1px 0px rgba(255, 255, 255, 0.6) inset; + background-color: rgba(255, 238, 237, 1); + opacity: 1; + padding: 8px 12px; + min-height: 64px; + width: 320px; + z-index: 10; + transition: var(--tooltip-transition-duration) ease; + + .status-message { + opacity: 1; + color: theme('colors.error.60'); + font-size: 16px; + font-weight: 600; + font-style: SemiBold; + letter-spacing: 0px; + text-align: left; + line-height: 24px; + } + } + .tooltip-left { + left: -20px; + } + + .tooltip-right { + right: -20px; + } + } +} + +@media (prefers-reduced-motion: reduce) { + :root { + --tooltip-transition-duration: 0s; } }