From 9e2933b5a46cd43d777740a4f93cfa42e31f06e1 Mon Sep 17 00:00:00 2001 From: Maja Zarkova Date: Mon, 27 May 2024 12:04:58 +0300 Subject: [PATCH] Implement infoLabel/infoMessage tooltip --- apps/alpha-test-app/src/views/HomeView.vue | 15 ++++- .../src/components/OnyxInput/OnyxInput.ct.tsx | 34 ++++++++++++ .../components/OnyxInput/OnyxInput.stories.ts | 27 +++++++++ .../src/components/OnyxInput/OnyxInput.vue | 46 +++++++++++++++- .../src/components/OnyxInput/types.ts | 9 +++ .../OnyxTextarea/OnyxTextarea.ct.tsx | 32 +++++++++++ .../OnyxTextarea/OnyxTextarea.stories.ts | 27 +++++++++ .../components/OnyxTextarea/OnyxTextarea.vue | 55 ++++++++++++++++++- .../src/components/OnyxTextarea/types.ts | 2 + packages/sit-onyx/src/i18n/locales/de-DE.json | 3 +- packages/sit-onyx/src/i18n/locales/en-US.json | 3 +- 11 files changed, 247 insertions(+), 6 deletions(-) diff --git a/apps/alpha-test-app/src/views/HomeView.vue b/apps/alpha-test-app/src/views/HomeView.vue index dcd0d9e77..9d62436c0 100644 --- a/apps/alpha-test-app/src/views/HomeView.vue +++ b/apps/alpha-test-app/src/views/HomeView.vue @@ -21,6 +21,8 @@ import { OnyxSwitch, OnyxTable, OnyxTag, + OnyxTextarea, + OnyxTimer, OnyxTooltip, type ListboxOption, type SelectOption, @@ -183,7 +185,12 @@ timerEndDate.setHours(timerEndDate.getHours() + 2); :skeleton="useSkeleton" /> - + Link @@ -287,7 +294,11 @@ timerEndDate.setHours(timerEndDate.getHours() + 2); - + diff --git a/packages/sit-onyx/src/components/OnyxInput/OnyxInput.ct.tsx b/packages/sit-onyx/src/components/OnyxInput/OnyxInput.ct.tsx index feaed950d..d169178eb 100644 --- a/packages/sit-onyx/src/components/OnyxInput/OnyxInput.ct.tsx +++ b/packages/sit-onyx/src/components/OnyxInput/OnyxInput.ct.tsx @@ -59,6 +59,40 @@ test.describe("Screenshot tests", () => { }, }); + executeMatrixScreenshotTest({ + name: "Input (infoLabel/infoMessage)", + columns: ["default", "long-text"], + rows: ["infoLabel", "infoMessage"], + // TODO: remove when contrast issues are fixed in https://github.com/SchwarzIT/onyx/issues/410 + disabledAccessibilityRules: ["color-contrast"], + component: (column, row) => { + const label = + column === "long-text" ? "Very long label that should be truncated" : "Test label"; + const message = + column === "long-text" ? "Very long message that should be truncated" : "Test message"; + const infoLabel = "More information"; + const infoMessage = "Additional info message"; + + return ( + + ); + }, + beforeScreenshot: async (component, page, _column, _row) => { + const tooltip = page.getByRole("tooltip"); + await component.evaluate((element) => { + element.style.height = `10rem`; + }); + + await tooltip.hover(); + }, + }); + executeMatrixScreenshotTest({ name: "Input (readonly, disabled, loading)", columns: ["readonly", "disabled", "loading"], diff --git a/packages/sit-onyx/src/components/OnyxInput/OnyxInput.stories.ts b/packages/sit-onyx/src/components/OnyxInput/OnyxInput.stories.ts index d3f0d9f8d..939aea592 100644 --- a/packages/sit-onyx/src/components/OnyxInput/OnyxInput.stories.ts +++ b/packages/sit-onyx/src/components/OnyxInput/OnyxInput.stories.ts @@ -152,3 +152,30 @@ export const CustomError = { placeholder: "Interact with me to show error", }, } satisfies Story; + +/** + * This example shows an input with info label tooltip. + */ +export const WithInfoLabel: Story = { + args: { + label: "Label", + infoLabel: "More information", + }, + decorators: [ + (story) => ({ + components: { story }, + template: `
`, + }), + ], +}; + +/** + * This example shows an input with info message / additional text. + */ +export const WithInfoMessage = { + args: { + ...Default.args, + message: "Example message", + infoMessage: "Additional info message", + }, +} satisfies Story; diff --git a/packages/sit-onyx/src/components/OnyxInput/OnyxInput.vue b/packages/sit-onyx/src/components/OnyxInput/OnyxInput.vue index 9917bd6a4..5b1ab6f58 100644 --- a/packages/sit-onyx/src/components/OnyxInput/OnyxInput.vue +++ b/packages/sit-onyx/src/components/OnyxInput/OnyxInput.vue @@ -5,7 +5,11 @@ import { useRequired } from "../../composables/required"; import { useCustomValidity } from "../../composables/useCustomValidity"; import OnyxLoadingIndicator from "../OnyxLoadingIndicator/OnyxLoadingIndicator.vue"; import OnyxSkeleton from "../OnyxSkeleton/OnyxSkeleton.vue"; +import OnyxTooltip from "../OnyxTooltip/OnyxTooltip.vue"; +import OnyxIcon from "../OnyxIcon/OnyxIcon.vue"; +import circleInformation from "@sit-onyx/icons/circle-information.svg?raw"; import type { OnyxInputProps } from "./types"; +import { injectI18n } from "../../i18n"; const props = withDefaults(defineProps(), { modelValue: "", @@ -65,6 +69,7 @@ const patternSource = computed(() => { }); const shouldShowCounter = computed(() => props.withCounter && props.maxlength); +const { t } = injectI18n();