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