/// <summary> /// Gets a string of Bootstrap column classes for various breakpoints that would allow to properly display /// the given child view at each breakpoint given the current number of open inline views. /// </summary> /// <param name="childView">The child view, for which to return the column classes.</param> /// <returns>A string of Bootstrap column classes for various breakpoints for this view.</returns> protected string GetViewCol(BlazorView childView) { if (bpWidths == null) { bpWidths = new BreakpointWidths(Mode == ViewParams.Mode.Popup ? BreakpointWidths.ModalDefaults : BreakpointWidths.GridDefaults); } selfWidths = new BreakpointWidths(bpWidths); int totalViews = OpenInlineViews; if (totalViews <= 1) { return("d-flex"); // no visible children } int currentView = childView?.OpenInlineViews ?? 1; int mainCol = (12 / totalViews); // calculate the point to hide the main view based on its column width Breakpoint hidePt = mainCol < 4 ? Breakpoint.xxl : mainCol < 6 ? Breakpoint.xl : Breakpoint.lg; int col = 12 * currentView / totalViews; string res = $"col-{hidePt}-{col} "; if (childView == null) { res += $"d-none d-{hidePt}-flex"; selfWidths.ApplyColumns(hidePt, 0, col); } else { int bkCol = 12 * currentView / (totalViews - 1); res += $"col-{bkCol}"; BreakpointWidths childWidths = new BreakpointWidths(bpWidths); childWidths.ApplyColumns(hidePt, bkCol, col); childView.bpWidths = childWidths; } return(res); }
/// <summary> /// Constructs new widths based on the specified widths. /// </summary> public BreakpointWidths(BreakpointWidths otherWidths) : this(otherWidths.widths) { }