// Copyright (c) MudBlazor 2021
// MudBlazor licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Connected.Annotations;
using Connected.Utilities;
using Microsoft.AspNetCore.Components;

namespace Connected.Components;

public partial class RTLProvider : UIComponent
{
   protected string Classname =>
      new CssBuilder("rtl-provider")
         .AddClass("application-layout-rtl", RightToLeft)
         .AddClass(AdditionalClassList)
         .Build();

   private bool _rtl;
   /// <summary>
   /// If true, changes the layout to RightToLeft.
   /// </summary>
   [Parameter]
   [Category(CategoryTypes.RTLProvider.Behavior)]
   public bool RightToLeft
   {
      get => _rtl;
      set
      {
         _rtl = value;
         CustomAttributes["dir"] = RightToLeft ? "rtl" : "ltr";
      }
   }

   /// <summary>
   /// Child content of the component.
   /// </summary>
   [Parameter]
   [Category(CategoryTypes.RTLProvider.Behavior)]
   public RenderFragment ChildContent { get; set; }
}
