From 60f66b79fc4c432a30bbc0073c303fbc46a5367e Mon Sep 17 00:00:00 2001 From: Gokce Ozkan Date: Thu, 17 Oct 2024 14:51:03 +0300 Subject: [PATCH 1/2] Tooltip component and enum added --- .../Components/Tooltip/Tooltip.Razor.cs | 37 +++++++++++++++++++ .../Components/Tooltip/Tooltip.razor | 25 +++++++++++++ .../Enums/Tooltip/TooltipVariant.cs | 19 ++++++++++ 3 files changed, 81 insertions(+) create mode 100644 SiemensIXBlazor/Components/Tooltip/Tooltip.Razor.cs create mode 100644 SiemensIXBlazor/Components/Tooltip/Tooltip.razor create mode 100644 SiemensIXBlazor/Enums/Tooltip/TooltipVariant.cs diff --git a/SiemensIXBlazor/Components/Tooltip/Tooltip.Razor.cs b/SiemensIXBlazor/Components/Tooltip/Tooltip.Razor.cs new file mode 100644 index 0000000..f2e5a41 --- /dev/null +++ b/SiemensIXBlazor/Components/Tooltip/Tooltip.Razor.cs @@ -0,0 +1,37 @@ +// ----------------------------------------------------------------------- +// SPDX-FileCopyrightText: 2024 Siemens AG +// +// SPDX-License-Identifier: MIT +// +// This source code is licensed under the MIT license found in the +// LICENSE file in the root directory of this source tree. +// ----------------------------------------------------------------------- + + + +using Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; +using SiemensIXBlazor.Enums.Chip; +using SiemensIXBlazor.Enums.Tooltip; +using SiemensIXBlazor.Interops; + +namespace SiemensIXBlazor.Components +{ + public partial class Tooltip + { + [Parameter, EditorRequired] + public string Id { get; set; } = string.Empty; + [Parameter] + public bool Interactive { get; set; } = false; + [Parameter] + public string? TitleContent { get; set; } + [Parameter] + public TooltipVariant Placement { get; set; } = TooltipVariant.top; + [Parameter] + public string? For { get; set; } + [Parameter] + public RenderFragment? ChildContent { get; set; } + private BaseInterop _interop; + } +} + diff --git a/SiemensIXBlazor/Components/Tooltip/Tooltip.razor b/SiemensIXBlazor/Components/Tooltip/Tooltip.razor new file mode 100644 index 0000000..2a8423e --- /dev/null +++ b/SiemensIXBlazor/Components/Tooltip/Tooltip.razor @@ -0,0 +1,25 @@ +@* ----------------------------------------------------------------------- +// SPDX-FileCopyrightText: 2024 Siemens AG +// +// SPDX-License-Identifier: MIT +// +// This source code is licensed under the MIT license found in the +// LICENSE file in the root directory of this source tree. +// ----------------------------------------------------------------------- +*@ + +@using Microsoft.JSInterop; +@namespace SiemensIXBlazor.Components +@inject IJSRuntime JSRuntime +@inherits IXBaseComponent + + + @ChildContent + diff --git a/SiemensIXBlazor/Enums/Tooltip/TooltipVariant.cs b/SiemensIXBlazor/Enums/Tooltip/TooltipVariant.cs new file mode 100644 index 0000000..77904ec --- /dev/null +++ b/SiemensIXBlazor/Enums/Tooltip/TooltipVariant.cs @@ -0,0 +1,19 @@ +// ----------------------------------------------------------------------- +// SPDX-FileCopyrightText: 2024 Siemens AG +// +// SPDX-License-Identifier: MIT +// +// This source code is licensed under the MIT license found in the +// LICENSE file in the root directory of this source tree. +// --- + +namespace SiemensIXBlazor.Enums.Tooltip +{ + public enum TooltipVariant + { + bottom, + left, + right, + top + } +} \ No newline at end of file From a4d878e741e4ddcf87dee9653c952794ab193819 Mon Sep 17 00:00:00 2001 From: Gokce Ozkan Date: Mon, 21 Oct 2024 15:53:09 +0300 Subject: [PATCH 2/2] Tooltip component test is added --- SiemensIXBlazor.Tests/TooltipTest.cs | 39 +++++++++++++++++++ .../Components/Tooltip/Tooltip.razor | 4 +- 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 SiemensIXBlazor.Tests/TooltipTest.cs diff --git a/SiemensIXBlazor.Tests/TooltipTest.cs b/SiemensIXBlazor.Tests/TooltipTest.cs new file mode 100644 index 0000000..2e49f47 --- /dev/null +++ b/SiemensIXBlazor.Tests/TooltipTest.cs @@ -0,0 +1,39 @@ +// ----------------------------------------------------------------------- +// SPDX-FileCopyrightText: 2024 Siemens AG +// +// SPDX-License-Identifier: MIT +// +// This source code is licensed under the MIT license found in the +// LICENSE file in the root directory of this source tree. +// ----------------------------------------------------------------------- + + +using Bunit; +using Microsoft.AspNetCore.Components; +using SiemensIXBlazor.Components; +using SiemensIXBlazor.Enums.Tooltip; +using Xunit; + +namespace SiemensIXBlazor.Tests +{ + public class TooltipTests : TestContextBase + { + [Fact] + public void TooltipRendersCorrectly() + { + // Arrange + var cut = RenderComponent( + ("Id", "tooltipId"), + ("TitleContent", "Test Tooltip"), + ("Interactive", true), + ("Placement", TooltipVariant.bottom), + ("For", "testElement") + ); + + // Assert + cut.MarkupMatches(""); + } + + + } +} diff --git a/SiemensIXBlazor/Components/Tooltip/Tooltip.razor b/SiemensIXBlazor/Components/Tooltip/Tooltip.razor index 2a8423e..282f44f 100644 --- a/SiemensIXBlazor/Components/Tooltip/Tooltip.razor +++ b/SiemensIXBlazor/Components/Tooltip/Tooltip.razor @@ -16,8 +16,8 @@