Example #1
0
        public ItemsList(ObservableList <IComponent> items, params UnitSize[] columns)
        {
            Items = items ?? new ObservableList <IComponent>();

            if (columns.Length < 2)
            {
                _stack            = Stack().Horizontal().Wrap().WidthStretch().MaxHeight(100.percent()).Scroll();
                _maxStackItemSize = columns.FirstOrDefault() ?? 100.percent();
            }
            else
            {
                _grid = Grid(columns).WidthStretch().MaxHeight(100.percent()).Scroll();
            }
            _emptyListMessageGenerator = null;

            _defered = DeferedComponent.Observe(
                Items,
                observedItems =>
            {
                if (!observedItems.Any())
                {
                    if (_emptyListMessageGenerator is object)
                    {
                        if (_grid is object)
                        {
                            return(_grid.Children(_emptyListMessageGenerator().GridColumnStretch()).AsTask());
                        }
                        else
                        {
                            return(_stack.Children(_emptyListMessageGenerator().WidthStretch().HeightStretch()).AsTask());
                        }
                    }
                    else
                    {
                        if (_grid is object)
                        {
                            _grid.Clear();
                            return(_grid.AsTask());
                        }
                        else
                        {
                            _stack.Clear();
                            return(_stack.AsTask());
                        }
                    }
                }
                else
                {
                    if (_grid is object)
                    {
                        return(_grid.Children(observedItems).AsTask());
                    }
                    else
                    {
                        return(_stack.Children(observedItems.Select(i => i.Width(_maxStackItemSize)).ToArray()).AsTask());
                    }
                }
            }
                );
        }
Example #2
0
 private static void SetHtmlElementHeight(HTMLElement htmlElement, UnitSize height)
 {
     htmlElement.SetStyle(cssStyleDeclaration =>
     {
         cssStyleDeclaration.height = height.ToString();
     });
 }
Example #3
0
        public DetailsListColumn(string title, UnitSize width, UnitSize maxWidth, bool isRowHeader = false, bool enableColumnSorting = false, string sortingKey = null, Action onColumnClick = null)
        {
            if (string.IsNullOrWhiteSpace(title))
            {
                throw new ArgumentException(nameof(title));
            }

            if (enableColumnSorting && string.IsNullOrWhiteSpace(sortingKey))
            {
                throw new ArgumentException(nameof(sortingKey));
            }

            Width               = width ?? throw new ArgumentNullException(nameof(width));
            MaxWidth            = maxWidth;
            SortingKey          = sortingKey ?? string.Empty;
            Title               = title;
            IsRowHeader         = isRowHeader;
            EnableColumnSorting = enableColumnSorting;

            if (onColumnClick != null)
            {
                _onColumnClick           = onColumnClick;
                EnableOnColumnClickEvent = true;
            }

            InnerElement = TextBlock(Title).Regular().SemiBold().Render();
        }
Example #4
0
 public static T Padding <T>(this T component, UnitSize unitSize) where T : IComponent
 {
     Stack.SetPaddingLeft(component, unitSize);
     Stack.SetPaddingRight(component, unitSize);
     Stack.SetPaddingTop(component, unitSize);
     Stack.SetPaddingBottom(component, unitSize);
     return(component);
 }
Example #5
0
 public static UnitSize px(this int value)
 {
     if (value > 0 && value < 32)
     {
         return(UnitSize.FromPixelCache(value));
     }
     return(new UnitSize(value, Unit.Pixels));
 }
Example #6
0
 public TutorialModal Border(string color, UnitSize size = null)
 {
     size = size ?? 1.px();
     _modal.StylingContainer.style.borderColor = color;
     _modal.StylingContainer.style.borderWidth = size.ToString();
     _modal.StylingContainer.style.borderStyle = "solid";
     return(this);
 }
Example #7
0
 public static T Margin <T>(this T component, UnitSize unitSize) where T : IComponent
 {
     Stack.SetMarginLeft(component, unitSize);
     Stack.SetMarginRight(component, unitSize);
     Stack.SetMarginTop(component, unitSize);
     Stack.SetMarginBottom(component, unitSize);
     return(component);
 }
Example #8
0
        private static UnitSize[] CreateCache(int count)
        {
            var us = new UnitSize[count];

            for (int i = 0; i < us.Length; i++)
            {
                us[i] = new UnitSize(i, Unit.Pixels);
            }
            return(us);
        }
Example #9
0
        public SplitView RightIsSmaller(UnitSize rightSize, UnitSize maxRightSize = null)
        {
            _rightComponent.Width    = rightSize.ToString();
            _rightComponent.MaxWidth = maxRightSize?.ToString() ?? "";
            _rightComponent.FlexGrow = "";

            _leftComponent.Width    = "10px";
            _leftComponent.MaxWidth = "";
            _leftComponent.FlexGrow = "1";
            _splitContainer.classList.add("tss-split-right");
            _splitContainer.classList.remove("tss-split-left");
            return(this);
        }
Example #10
0
        public SplitView(UnitSize splitterSize = null)
        {
            _leftComponent           = Raw(Div(_()));
            _splitterComponent       = Raw(Div(_("tss-splitter")));
            _rightComponent          = Raw(Div(_()));
            _splitterComponent.Width = (splitterSize is object && splitterSize.Unit != Unit.Auto && splitterSize.Unit != Unit.Inherit)
                                          ? splitterSize.ToString()
                                          : "8px";
            _leftComponent.Height     = "100%";
            _splitterComponent.Height = "100%";
            _rightComponent.Height    = "100%";

            _leftComponent.Width  = "10px";
            _rightComponent.Width = "10px";

            _leftComponent.FlexGrow  = "1";
            _rightComponent.FlexGrow = "1";

            _splitContainer = Div(_("tss-splitview"), _leftComponent.Render(), _splitterComponent.Render(), _rightComponent.Render());
        }
        public DetailsListIconColumn(Icon icon, UnitSize width, UnitSize maxWidth, bool enableColumnSorting = false, string sortingKey = null, Action onColumnClick = null)
        {
            if (enableColumnSorting && string.IsNullOrWhiteSpace(sortingKey))
            {
                throw new ArgumentException(nameof(sortingKey));
            }

            Icon                = icon;
            Width               = width ?? throw new ArgumentNullException(nameof(width));
            MaxWidth            = maxWidth;
            SortingKey          = sortingKey ?? string.Empty;
            EnableColumnSorting = enableColumnSorting;

            if (onColumnClick != null)
            {
                _onColumnClick           = onColumnClick;
                EnableOnColumnClickEvent = true;
            }

            InnerElement = Div(_()).appendChild(Icon.Render());
        }
Example #12
0
 public Toast Width(UnitSize width)
 {
     _toastContainer.style.width = width.ToString();
     return(this);
 }
Example #13
0
 public static T MarginTop <T>(this T component, UnitSize unitSize) where T : IComponent
 {
     Stack.SetMarginTop(component, unitSize);
     return(component);
 }
Example #14
0
 public static T MinWidth <T>(this T component, UnitSize unitSize) where T : IComponent
 {
     Stack.SetMinWidth(component, unitSize);
     return(component);
 }
Example #15
0
 /// <summary>PaddingBottom</summary>
 public static T PB <T>(this T component, UnitSize unitSize) where T : IComponent => PaddingBottom(component, unitSize);
Example #16
0
 /// <summary>PaddingTop</summary>
 public static T PT <T>(this T component, UnitSize unitSize) where T : IComponent => PaddingTop(component, unitSize);
Example #17
0
 public static T MaxHeight <T>(this T component, UnitSize unitSize) where T : IComponent
 {
     Stack.SetMaxHeight(component, unitSize);
     return(component);
 }
Example #18
0
        public InfiniteScrollingList(IComponent[] items, Func <Task <IComponent[]> > getNextItemPage, params UnitSize[] columns)
        {
            _container = Div(_("tss-basiclist"));

            if (columns.Length < 2)
            {
                _stack            = Stack().Horizontal().Wrap().WidthStretch().MaxHeight(100.percent()).Scroll();
                _maxStackItemSize = columns.FirstOrDefault() ?? 100.percent();
            }
            else
            {
                _grid = Grid(columns).WS().MaxHeight(100.percent()).GridColumnStretch().Scroll();
            }
            _emptyListMessageGenerator = null;
            AddItems(items);

            if (getNextItemPage is object)
            {
                var vs = VisibilitySensor(v =>
                {
                    Task.Run <Task>(async() =>
                    {
                        if (_grid is object)
                        {
                            var nextPageItems = await getNextItemPage();
                            _grid.Remove(v);
                            if (nextPageItems is object && nextPageItems.Any())
                            {
                                foreach (var item in nextPageItems)
                                {
                                    _grid.Add(item);
                                }
                                v.Reset();
                                _grid.Add(v);
                            }
                        }
                        else
                        {
                            var nextPageItems = await getNextItemPage();
                            _stack.Remove(v);
                            if (nextPageItems is object && nextPageItems.Any())
                            {
                                foreach (var item in nextPageItems)
                                {
                                    _stack.Add(item.W(_maxStackItemSize));
                                }
                                v.Reset();
                                _stack.Add(v);
                            }
                        }
                    }).FireAndForget();
                }, message: TextBlock("Loading..."));

                if (_grid is object)
                {
                    _grid.Add(vs);
                }
                else
                {
                    _stack.Add(vs);
                }
            }
        }
Example #19
0
 /// <summary>MarginBottom</summary>
 public static T MB <T>(this T component, UnitSize unitSize) where T : IComponent => MarginBottom(component, unitSize);
Example #20
0
 public static DetailsListIconColumn IconColumn(Icon icon, UnitSize width, bool enableColumnSorting = false, string sortingKey = null, Action onColumnClick = null) => new DetailsListIconColumn(icon, width, enableColumnSorting, sortingKey, onColumnClick);
Example #21
0
 /// <summary>MarginLeft</summary>
 public static T ML <T>(this T component, UnitSize unitSize) where T : IComponent => MarginLeft(component, unitSize);
Example #22
0
 /// <summary>Height</summary>
 public static T H <T>(this T component, UnitSize unitSize) where T : IComponent => Height(component, unitSize);
Example #23
0
        //Shortcuts:

        /// <summary>Width</summary>
        public static T W <T>(this T component, UnitSize unitSize) where T : IComponent => Width(component, unitSize);
Example #24
0
 public Toast Height(UnitSize height)
 {
     _toastContainer.style.height = height.ToString();
     return(this);
 }
Example #25
0
 /// <summary>PaddingLeft</summary>
 public static T PL <T>(this T component, UnitSize unitSize) where T : IComponent => PaddingLeft(component, unitSize);
Example #26
0
 /// <summary>PaddingRight</summary>
 public static T PR <T>(this T component, UnitSize unitSize) where T : IComponent => PaddingRight(component, unitSize);
Example #27
0
 /// <summary>MarginRight</summary>
 public static T MR <T>(this T component, UnitSize unitSize) where T : IComponent => MarginRight(component, unitSize);
Example #28
0
 public static T HeightAuto <T>(this T component) where T : IComponent
 {
     Stack.SetHeight(component, UnitSize.Auto());
     return(component);
 }
Example #29
0
 public static DetailsListColumn DetailsListColumn(string title, UnitSize width, bool isRowHeader = false, bool enableColumnSorting = false, string sortingKey = null, Action onColumnClick = null) => new DetailsListColumn(title, width, isRowHeader, enableColumnSorting, sortingKey, onColumnClick);
Example #30
0
 /// <summary>MarginTop</summary>
 public static T MT <T>(this T component, UnitSize unitSize) where T : IComponent => MarginTop(component, unitSize);