From 0abfc23cf22115ac54370f1d69efc8675696761f 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 | 45 +++++++++++++++++-- 4 files changed, 88 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..62ed76662 100644 --- a/ui-core/src/styles/inputs/fieldWrapper.css +++ b/ui-core/src/styles/inputs/fieldWrapper.css @@ -3,21 +3,22 @@ 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 +29,43 @@ 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: 1; + + .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; + } } }