Skip to content

Commit 546f030

Browse files
authored
Enhance API docs and metadata for Offcanvas, Pagination, PdfViewer (#1223)
* Enhance Offcanvas & Pagination with metadata and docs Added [AddedVersion], [DefaultValue], [Description], and [ParameterTypeName] attributes to Offcanvas and Pagination components for improved API clarity and tooling support. Updated XML docs to clarify default values and usage. Refactored fields and properties to use nullable types where appropriate, and removed obsolete or redundant code. These changes improve maintainability, usability, and self-documentation of the components. * Update Pagination property descriptions with bold tags Enhanced the XML documentation for FirstLinkText, LastLinkText, NextLinkText, and PreviousLinkText properties in the Pagination component by wrapping property and icon names in <b> tags for better emphasis and clarity. No changes to component logic or behavior. * Enhance PdfViewer: nullable JS interop & param metadata Refactored PdfViewer to use nullable injection for PdfViewerJsInterop and applied the null-forgiving operator for null-safety. Added metadata attributes ([AddedVersion], [Description], [DefaultValue], [ParameterTypeName]) to several parameters and improved XML documentation. No changes to component logic; updates focus on safety and documentation. * Update PDF paths to parent-relative in demo components Changed the Url property in password-protected PDF demo components to use a parent-relative path ("../static-assets/docs/...") instead of a direct relative path. This ensures correct file loading after directory structure changes.
1 parent cb8af04 commit 546f030

5 files changed

Lines changed: 237 additions & 124 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<PdfViewer Class="mb-3"
2-
Url="@($"{DemoStringConstants.StaticAssets_Docs_Path}/pdf_password_protected.pdf")"
2+
Url="@($"../{DemoStringConstants.StaticAssets_Docs_Path}/pdf_password_protected.pdf")"
33
Password="12345" />

BlazorBootstrap.Demo.RCL/Components/Pages/Demos/PdfViewer/PdfViewer_Demo_05_Password_Protected_B_Prompt_For_Password.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@if (showPdfViewer)
22
{
3-
<PdfViewer Class="mb-3" Url="@($"{DemoStringConstants.StaticAssets_Docs_Path}/pdf_password_protected.pdf")" PromptForPassword="true" />
3+
<PdfViewer Class="mb-3" Url="@($"../{DemoStringConstants.StaticAssets_Docs_Path}/pdf_password_protected.pdf")" PromptForPassword="true" />
44
}
55
else
66
{

blazorbootstrap/Components/Offcanvas/Offcanvas.razor.cs

Lines changed: 118 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ public partial class Offcanvas : BlazorBootstrapComponentBase
66

77
private Type? childComponent;
88

9-
private DotNetObjectReference<Offcanvas> objRef = default!;
9+
private DotNetObjectReference<Offcanvas>? objRef;
1010

11-
private Dictionary<string, object> parameters = default!;
11+
private Dictionary<string, object>? parameters;
1212

13-
private string title = default!;
13+
private string? title;
1414

1515
#endregion
1616

@@ -69,11 +69,15 @@ protected override async Task OnInitializedAsync()
6969
/// <summary>
7070
/// Hides an offcanvas.
7171
/// </summary>
72+
[AddedVersion("1.0.0")]
73+
[Description("Hides an offcanvas.")]
7274
public async Task HideAsync() => await JSRuntime.InvokeVoidAsync("window.blazorBootstrap.offcanvas.hide", Id);
7375

7476
/// <summary>
7577
/// Shows an offcanvas.
7678
/// </summary>
79+
[AddedVersion("1.0.0")]
80+
[Description("Shows an offcanvas.")]
7781
public async Task ShowAsync() => await ShowAsync(null, null, null);
7882

7983
/// <summary>
@@ -82,6 +86,8 @@ protected override async Task OnInitializedAsync()
8286
/// <typeparam name="T"></typeparam>
8387
/// <param name="title"></param>
8488
/// <param name="parameters"></param>
89+
[AddedVersion("1.0.0")]
90+
[Description("Opens a offcanvas. T is component.")]
8591
public async Task ShowAsync<T>(string title, Dictionary<string, object>? parameters = null) => await ShowAsync(title, typeof(T), parameters);
8692

8793
private async Task ShowAsync(string? title, Type? type, Dictionary<string, object>? parameters)
@@ -107,163 +113,208 @@ private async Task ShowAsync(string? title, Type? type, Dictionary<string, objec
107113

108114
/// <summary>
109115
/// Gets or sets the body CSS class.
116+
/// <para>
117+
/// Default value is <see langword="null"/>.
118+
/// </para>
110119
/// </summary>
111-
/// <remarks>
112-
/// Default value is null.
113-
/// </remarks>
120+
[AddedVersion("1.0.0")]
121+
[DefaultValue(null)]
122+
[Description("Gets or sets the body CSS class.")]
123+
[ParameterTypeName("string?")]
114124
[Parameter]
115-
public string BodyCssClass { get; set; } = default!;
125+
public string? BodyCssClass { get; set; }
116126

117127
/// <summary>
118128
/// Gets or sets the body template.
129+
/// <para>
130+
/// Default value is <see langword="null"/>.
131+
/// </para>
119132
/// </summary>
120-
/// <remarks>
121-
/// Default value is null.
122-
/// </remarks>
133+
[AddedVersion("1.0.0")]
134+
[DefaultValue(null)]
135+
[Description("Gets or sets the body template.")]
136+
[ParameterTypeName("RenderFragment?")]
123137
[Parameter]
124-
public RenderFragment BodyTemplate { get; set; } = default!;
138+
public RenderFragment? BodyTemplate { get; set; }
125139

126140
/// <summary>
127141
/// If <see langword="true" />, offcanvas closes when escape key is pressed.
142+
/// <para>
143+
/// Default value is <see langword="true"/>.
144+
/// </para>
128145
/// </summary>
129-
/// <remarks>
130-
/// Default value is true.
131-
/// </remarks>
146+
[AddedVersion("1.0.0")]
147+
[DefaultValue(true)]
148+
[Description("If <b>true</b>, offcanvas closes when escape key is pressed.")]
132149
[Parameter]
133150
public bool CloseOnEscape { get; set; } = true;
134151

135152
/// <summary>
136153
/// Gets or sets the footer CSS class.
154+
/// <para>
155+
/// Default value is <see langword="null"/>.
156+
/// </para>
137157
/// </summary>
138-
/// <remarks>
139-
/// Default value is null.
140-
/// </remarks>
158+
[AddedVersion("1.0.0")]
159+
[DefaultValue(null)]
160+
[Description("Gets or sets the footer CSS class.")]
161+
[ParameterTypeName("string?")]
141162
[Parameter]
142-
public string FooterCssClass { get; set; } = default!;
163+
public string? FooterCssClass { get; set; }
143164

144165
/// <summary>
145166
/// Gets or sets the footer template.
167+
/// <para>
168+
/// Default value is <see langword="null"/>.
169+
/// </para>
146170
/// </summary>
147-
/// <remarks>
148-
/// Default value is null.
149-
/// </remarks>
171+
[AddedVersion("1.0.0")]
172+
[DefaultValue(null)]
173+
[Description("Gets or sets the footer template.")]
174+
[ParameterTypeName("RenderFragment?")]
150175
[Parameter]
151-
public RenderFragment FooterTemplate { get; set; } = default!;
176+
public RenderFragment? FooterTemplate { get; set; }
152177

153178
/// <summary>
154179
/// Gets or sets the header CSS class.
180+
/// <para>
181+
/// Default value is <see langword="null"/>.
182+
/// </para>
155183
/// </summary>
156-
/// <remarks>
157-
/// Default value is null.
158-
/// </remarks>
184+
[AddedVersion("1.0.0")]
185+
[DefaultValue(null)]
186+
[Description("Gets or sets the header CSS class.")]
187+
[ParameterTypeName("string?")]
159188
[Parameter]
160-
public string HeaderCssClass { get; set; } = default!;
189+
public string? HeaderCssClass { get; set; }
161190

162191
/// <summary>
163192
/// Gets or sets the header template.
193+
/// <para>
194+
/// Default value is <see langword="null"/>.
195+
/// </para>
164196
/// </summary>
165-
/// <remarks>
166-
/// Default value is null.
167-
/// </remarks>
197+
[AddedVersion("1.0.0")]
198+
[DefaultValue(null)]
199+
[Description("Gets or sets the header template.")]
200+
[ParameterTypeName("RenderFragment?")]
168201
[Parameter]
169-
public RenderFragment HeaderTemplate { get; set; } = default!;
202+
public RenderFragment? HeaderTemplate { get; set; }
170203

171204
/// <summary>
172205
/// Indicates whether body scrolling is allowed while offcanvas is open.
206+
/// <para>
207+
/// Default value is <see langword="false"/>.
208+
/// </para>
173209
/// </summary>
174-
/// <remarks>
175-
/// Default value is false.
176-
/// </remarks>
210+
[AddedVersion("1.0.0")]
211+
[DefaultValue(false)]
212+
[Description("Indicates whether body scrolling is allowed while offcanvas is open.")]
177213
[Parameter]
178214
public bool IsScrollable { get; set; }
179215

180216
/// <summary>
181-
/// This event is fired when an offcanvas element has been hidden from the user (will wait for CSS transitions to
182-
/// complete).
217+
/// This event is fired when an offcanvas element has been hidden from the user (will wait for CSS transitions to complete).
183218
/// </summary>
219+
[AddedVersion("1.0.0")]
220+
[Description("This event is fired when an offcanvas element has been hidden from the user (will wait for CSS transitions to complete).")]
184221
[Parameter]
185222
public EventCallback OnHidden { get; set; }
186223

187224
/// <summary>
188225
/// This event is fired immediately when the hide method has been called.
189226
/// </summary>
227+
[AddedVersion("1.0.0")]
228+
[Description("This event is fired immediately when the hide method has been called.")]
190229
[Parameter]
191230
public EventCallback OnHiding { get; set; }
192231

193232
/// <summary>
194233
/// This event fires immediately when the show instance method is called.
195234
/// </summary>
235+
[AddedVersion("1.0.0")]
236+
[Description("This event fires immediately when the show instance method is called.")]
196237
[Parameter]
197238
public EventCallback OnShowing { get; set; }
198239

199240
/// <summary>
200-
/// This event is fired when an offcanvas element has been made visible to the user (will wait for CSS transitions to
201-
/// complete).
241+
/// This event is fired when an offcanvas element has been made visible to the user (will wait for CSS transitions to complete).
202242
/// </summary>
243+
[AddedVersion("1.0.0")]
244+
[Description("This event is fired when an offcanvas element has been made visible to the user (will wait for CSS transitions to complete).")]
203245
[Parameter]
204246
public EventCallback OnShown { get; set; }
205247

206248
/// <summary>
207249
/// Gets or sets the offcanvas placement.
208-
/// </summary>
209-
/// <remarks>
250+
/// <para>
210251
/// Default value is <see cref="Placement.End" />.
211-
/// </remarks>
252+
/// </para>
253+
/// </summary>
254+
[AddedVersion("1.0.0")]
255+
[DefaultValue(Placement.End)]
256+
[Description("Gets or sets the offcanvas placement.")]
212257
[Parameter]
213258
public Placement Placement { get; set; } = Placement.End;
214259

215260
/// <summary>
216261
/// If <see langword="true" />, modal shows close button in the header.
262+
/// <para>
263+
/// Default value is <see langword="true"/>.
264+
/// </para>
217265
/// </summary>
218-
/// <remarks>
219-
/// Default value is true.
220-
/// </remarks>
266+
[AddedVersion("1.0.0")]
267+
[DefaultValue(true)]
268+
[Description("If <b>true</b>, modal shows close button in the header.")]
221269
[Parameter]
222270
public bool ShowCloseButton { get; set; } = true;
223271

224272
/// <summary>
225273
/// Gets or sets the offcanvas size.
226-
/// </summary>
227-
/// <remarks>
274+
/// <para>
228275
/// Default value is <see cref="OffcanvasSize.Regular" />.
229-
/// </remarks>
276+
/// </para>
277+
/// </summary>
278+
[AddedVersion("1.0.0")]
279+
[DefaultValue(OffcanvasSize.Regular)]
280+
[Description("Gets or sets the offcanvas size.")]
230281
[Parameter]
231282
public OffcanvasSize Size { get; set; } = OffcanvasSize.Regular;
232283

233284
/// <summary>
234285
/// Gets or sets the tab index.
235-
/// </summary>
236-
/// <remarks>
286+
/// <para>
237287
/// Default value is -1.
238-
/// </remarks>
288+
/// </para>
289+
/// </summary>
290+
[AddedVersion("1.0.0")]
291+
[DefaultValue(-1)]
292+
[Description("Gets or sets the tab index.")]
239293
[Parameter]
240294
public int TabIndex { get; set; } = -1;
241295

242296
/// <summary>
243297
/// Gets or sets the offcanvas title.
298+
/// <para>
299+
/// Default value is <see langword="null"/>.
300+
/// </para>
244301
/// </summary>
245-
/// <remarks>
246-
/// Default value is null.
247-
/// </remarks>
248-
[Parameter]
249-
public string Title { get; set; } = default!;
250-
251-
[Obsolete("Use `UseStaticBackdrop` parameter.")]
252-
/// <summary>
253-
/// Indicates whether to apply a backdrop on body while offcanvas is open.
254-
/// </summary>
255-
/// <remarks>
256-
/// Default value is true.
257-
/// </remarks>
302+
[AddedVersion("1.0.0")]
303+
[DefaultValue(null)]
304+
[Description("Gets or sets the offcanvas title.")]
305+
[ParameterTypeName("string?")]
258306
[Parameter]
259-
public bool UseBackdrop { get; set; } = true;
307+
public string? Title { get; set; }
260308

261309
/// <summary>
262-
/// When `UseStaticBackdrop` is set to true, the offcanvas will not close when clicking outside of it.
310+
/// When `UseStaticBackdrop` is set to <see langword="true"/>, the offcanvas will not close when clicking outside of it.
311+
/// <para>
312+
/// Default value is <see langword="false"/>.
313+
/// </para>
263314
/// </summary>
264-
/// <remarks>
265-
/// Default value is false.
266-
/// </remarks>
315+
[AddedVersion("1.0.0")]
316+
[DefaultValue(false)]
317+
[Description("When `UseStaticBackdrop` is set to <b>true</b>, the offcanvas will not close when clicking outside of it.")]
267318
[Parameter]
268319
public bool UseStaticBackdrop { get; set; }
269320

0 commit comments

Comments
 (0)