Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ public partial class BitCallout : BitComponentBase
/// </summary>
[Parameter] public BitDropDirection? Direction { get; set; }

/// <summary>
/// The id of the footer element that renders at the end of the scrolling container of the callout contnet.
/// </summary>
[Parameter] public string? FooterId { get; set; }

/// <summary>
/// The id of the header element that renders at the top of the scrolling container of the callout contnet.
/// </summary>
[Parameter] public string? HeaderId { get; set; }

/// <summary>
/// Determines the opening state of the callout.
/// </summary>
Expand All @@ -58,11 +68,31 @@ public partial class BitCallout : BitComponentBase
[ResetClassBuilder, ResetStyleBuilder, TwoWayBound]
public bool IsOpen { get; set; }

/// <summary>
/// The max window width to consider when calculating the position of the callout before openning.
/// </summary>
[Parameter] public int? MaxWindowWidth { get; set; }

/// <summary>
/// The callback that is called when the callout opens or closes.
/// </summary>
[Parameter] public EventCallback<bool> OnToggle { get; set; }

/// <summary>
/// Force the callout to set its content container width while openning it based on the available space and actual content.
/// </summary>
[Parameter] public bool SetCalloutWidth { get; set; }

/// <summary>
/// The id of the element which needs to be scrollable in the content of the callout.
/// </summary>
[Parameter] public string? ScrollContainerId { get; set; }

/// <summary>
/// The vertical offset of the scroll container to consider in the positining and height calculation of the callout.
/// </summary>
[Parameter] public int? ScrollOffset { get; set; }

/// <summary>
/// Configures the responsive mode of the callout for the small screens.
/// </summary>
Expand Down Expand Up @@ -155,20 +185,22 @@ private async Task ToggleCallout()

var id = Anchor is not null ? _anchorId : AnchorId ?? _Id;

await _js.BitCalloutToggleCallout(_dotnetObj,
id,
AnchorEl is null ? null : AnchorEl(),
_contentId,
null,
IsOpen,
ResponsiveMode ?? BitResponsiveMode.None,
Direction ?? BitDropDirection.TopAndBottom,
Dir is BitDir.Rtl,
"",
0,
"",
"",
false);
await _js.BitCalloutToggleCallout(
dotnetObj: _dotnetObj,
componentId: id,
component: AnchorEl is null ? null : AnchorEl(),
calloutId: _contentId,
callout: null,
isCalloutOpen: IsOpen,
responsiveMode: ResponsiveMode ?? BitResponsiveMode.None,
dropDirection: Direction ?? BitDropDirection.TopAndBottom,
isRtl: Dir is BitDir.Rtl,
scrollContainerId: ScrollContainerId ?? "",
scrollOffset: ScrollOffset ?? 0,
headerId: HeaderId ?? "",
footerId: FooterId ?? "",
setCalloutWidth: SetCalloutWidth,
maxWindowWidth: MaxWindowWidth ?? 0);

await OnToggle.InvokeAsync(IsOpen);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ internal static class CalloutsJsRuntimeExtensions
string headerId,
string footerId,
bool setCalloutWidth,
int maxWidth = 0) where T : class
int maxWindowWidth = 0) where T : class
{
return jsRuntime.Invoke<bool>("BitBlazorUI.Callouts.toggle",
dotnetObj,
Expand All @@ -37,7 +37,7 @@ internal static class CalloutsJsRuntimeExtensions
headerId,
footerId,
setCalloutWidth,
maxWidth);
maxWindowWidth);
}

internal static ValueTask BitCalloutClearCallout(this IJSRuntime jsRuntime, string calloutId)
Expand Down
6 changes: 3 additions & 3 deletions src/BlazorUI/Bit.BlazorUI/Scripts/Callouts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace BitBlazorUI {
headerId: string,
footerId: string,
setCalloutWidth: boolean,
maxWidth: number,
maxWindowWidth: number,
) {
component ??= document.getElementById(componentId);
if (component == null) return false;
Expand Down Expand Up @@ -110,8 +110,8 @@ namespace BitBlazorUI {
let left = componentX + (isRtl ? (componentWidth - calloutWidth) : 0);
const right = left + calloutWidth;
const correctedLeft = windowWidth - calloutWidth - 3;
if (maxWidth) {
left = (windowWidth >= maxWidth && (right > windowWidth)) ? correctedLeft : left;
if (maxWindowWidth) {
left = (windowWidth >= maxWindowWidth && (right > windowWidth)) ? correctedLeft : left;
} else {
left = (right > windowWidth) ? correctedLeft : left;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,46 +79,65 @@
<DemoExample Title="DropDirection" RazorCode="@example4RazorCode" Id="example4">
<div>Explores different drop directions for the BitCallout component, including automatic and explicit directions.</div>
<br /><br />
<div>
<div>DropDirection: All</div><br />
<BitCallout Direction="BitDropDirection.All">
<Anchor>
<BitButton>Show callout</BitButton>
</Anchor>
<Content>
<div style="padding: 1rem; border: 1px solid gray;">
@for (int i = 1; i < 13; i++)
{
var item = i;
<div>Callout content @(item)</div>
<div>DropDirection: All</div><br />
<BitCallout Direction="BitDropDirection.All">
<Anchor>
<BitButton>Show callout</BitButton>
</Anchor>
<Content>
<div style="padding: 1rem; border: 1px solid gray;">
@for (int i = 1; i < 13; i++)
{
var item = i;
<div>Callout content @(item)</div>

<br />
}
</div>
</Content>
</BitCallout>
<br /><br />
<div>DropDirection: TopAndBottom</div><br />
<BitCallout Direction="BitDropDirection.TopAndBottom">
<Anchor>
<BitButton>Show callout</BitButton>
</Anchor>
<Content>
<div style="padding: 1rem; border: 1px solid gray;">
@for (int i = 1; i < 13; i++)
{
var item = i;
<div>Callout content @(item)</div>
<br />
}
</div>
</Content>
</BitCallout>
<br /><br /><br />
<div>DropDirection: TopAndBottom</div><br />
<BitCallout Direction="BitDropDirection.TopAndBottom">
<Anchor>
<BitButton>Show callout</BitButton>
</Anchor>
<Content>
<div style="padding: 1rem; border: 1px solid gray;">
@for (int i = 1; i < 13; i++)
{
var item = i;
<div>Callout content @(item)</div>

<br />
}
</div>
</Content>
</BitCallout>
</div>
<br />
}
</div>
</Content>
</BitCallout>
</DemoExample>

<DemoExample Title="Style & Class" RazorCode="@example5RazorCode" Id="example5">
<DemoExample Title="ScrollContainerId" RazorCode="@example5RazorCode" Id="example5">
<div>Utilizaing the ScrollContainerId one can enable scrolling the content of the callout.</div>
<br /><br />
<BitCallout ScrollContainerId="scroller-container">
<Anchor>
<BitButton>Show callout</BitButton>
</Anchor>
<Content>
<div id="scroller-container" style="padding: 1rem; border: 1px solid gray; overflow: auto;">
@for (int i = 1; i < 69; i++)
{
var item = i;
<div>Callout content @(item)</div>

<br />
}
</div>
</Content>
</BitCallout>
</DemoExample>

<DemoExample Title="Style & Class" RazorCode="@example6RazorCode" Id="example6">
<div>Explores styling and class customization for BitCallout, including component styles, custom classes, and detailed style options.</div>
<br />
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,62 @@ public partial class BitCalloutDemo
Href = "#drop-direction-enum"
},
new()
{
Name = "FooterId",
Type = "string?",
DefaultValue = "null",
Description = "The id of the footer element that renders at the end of the scrolling container of the callout contnet."
},
new()
{
Name = "HeaderId",
Type = "string?",
DefaultValue = "null",
Description = "The id of the header element that renders at the top of the scrolling container of the callout contnet."
},
new()
{
Name = "IsOpen",
Type = "bool",
DefaultValue = "false",
Description = "Determines the opening state of the callout."
},
new()
{
Name = "MaxWindowWidth",
Type = "int?",
DefaultValue = "null",
Description = "The max window width to consider when calculating the position of the callout before openning."
},
new()
{
Name = "OnToggle",
Type = "EventCallback<bool>",
DefaultValue = "",
Description = "The callback that is called when the callout opens or closes."
},
new()
{
Name = "SetCalloutWidth",
Type = "bool",
DefaultValue = "false",
Description = "Force the callout to set its content container width while openning it based on the available space and actual content."
},
new()
{
Name = "ScrollContainerId",
Type = "string?",
DefaultValue = "null",
Description = "The id of the element which needs to be scrollable in the content of the callout."
},
new()
{
Name = "ScrollOffset",
Type = "int?",
DefaultValue = "null",
Description = "The vertical offset of the scroll container to consider in the positining and height calculation of the callout."
},
new()
{
Name = "ResponsiveMode",
Type = "BitResponsiveMode?",
Expand Down Expand Up @@ -296,6 +338,24 @@ You can even close it from here!
</BitCallout>";

private readonly string example5RazorCode = @"
<BitCallout ScrollContainerId=""scroller-container"">
<Anchor>
<BitButton>Show callout</BitButton>
</Anchor>
<Content>
<div id=""scroller-container"" style=""padding: 1rem; border: 1px solid gray; overflow: auto;"">
@for (int i = 1; i < 69; i++)
{
var item = i;
<div>Callout content @(item)</div>

<br />
}
</div>
</Content>
</BitCallout>";

private readonly string example6RazorCode = @"
<style>
.custom-class {
width: fit-content;
Expand Down
Loading