| | 1 | | @inherits TELComponentBase |
| | 2 | | @implements IAccessibleComponent |
| | 3 | |
|
| | 4 | | <button type="submit" |
| | 5 | | class="@ButtonStyle.ToCssClass() @AdditionalCssClasses" |
| | 6 | | aria-label="@AriaLabel" |
| | 7 | | role="@AriaRole" |
| | 8 | | aria-describedby="@AriaDescribedBy" |
| | 9 | | title="@ToolTipTitle" |
| | 10 | | tabindex="@TabIndex"> |
| | 11 | | <span class="button-text">@ButtonText</span> |
| 18 | 12 | | @if (!string.IsNullOrEmpty(AssistiveText)) |
| 18 | 13 | | { |
| | 14 | | <span id="@AriaDescribedBy" class="nhsuk-u-visually-hidden"> @AssistiveText</span> <!-- Hidden element for scree |
| 18 | 15 | | } |
| | 16 | | </button> |
| | 17 | |
|
| | 18 | | @code { |
| | 19 | |
|
| | 20 | | /// <summary> |
| | 21 | | /// Guid generated on creation to link elements for screen readers |
| | 22 | | /// </summary> |
| | 23 | | private string _ariaDescribedBy; |
| 36 | 24 | | public string AriaDescribedBy => _ariaDescribedBy; |
| | 25 | |
|
| | 26 | | protected override void OnInitialized() |
| 18 | 27 | | { |
| 18 | 28 | | _ariaDescribedBy = $"assistive-text-{Guid.NewGuid()}"; |
| 18 | 29 | | } |
| | 30 | |
|
| | 31 | | /// <summary> |
| | 32 | | /// Button Options |
| | 33 | | ///</summary> |
| | 34 | | [Parameter] |
| 54 | 35 | | public TELButtonStyle ButtonStyle { get; set; } = TELButtonStyle.Primary; // Default to Generic |
| | 36 | |
|
| | 37 | | [EditorRequired, Parameter] |
| 36 | 38 | | public required string ButtonText { get; set; } |
| | 39 | |
|
| 54 | 40 | | [Parameter] public string AdditionalCssClasses { get; set; } = ""; // Custom CSS classes for additional styling |
| | 41 | |
|
| | 42 | | [Parameter] |
| 36 | 43 | | public bool PreventDoubleClick { get; set; } = false; |
| | 44 | |
|
| | 45 | | /// <summary> |
| | 46 | | /// Assisitive |
| | 47 | | /// </summary> |
| | 48 | | // This property is public, satisfying the interface, but not a Parameter because I wanted to force it to be used in |
| 36 | 49 | | public string AriaRole { get; set; } = "Button"; // Set to button by default |
| | 50 | |
|
| | 51 | | [EditorRequired, Parameter] |
| 36 | 52 | | public required string AriaLabel { get; set; } |
| | 53 | |
|
| | 54 | | [EditorRequired, Parameter] |
| 54 | 55 | | public required string AssistiveText { get; set; } |
| | 56 | |
|
| | 57 | | // Tab index for keyboard navigation |
| | 58 | | [EditorRequired, Parameter] |
| 54 | 59 | | public required int TabIndex { get; set; } = 0; |
| | 60 | |
|
| | 61 | | [EditorRequired, Parameter] |
| 36 | 62 | | public required string ToolTipTitle { get; set; } |
| | 63 | |
|
| | 64 | | } |