|
| 1 | +<div |
| 2 | + class=" |
| 3 | + card |
| 4 | + @(Variant switch |
| 5 | + { |
| 6 | + CardVariant.Post => "post", |
| 7 | + CardVariant.Event => "event", |
| 8 | + CardVariant.ParentEvent => "parent-event", |
| 9 | + _ => throw new NotImplementedException(), |
| 10 | + }) |
| 11 | + "> |
| 12 | + @* |
| 13 | + When showing an Event's parent above it, we want to make the main Event an h1 and the parent an h2. |
| 14 | + Because of accessibility, the h2 must be after the h1 in the HTML. |
| 15 | + To do this we render the h1 first, then reorder the headings using a CSS flexbox. |
| 16 | + https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/Heading_Elements#accessibility |
| 17 | + *@ |
| 18 | + @if (Variant is CardVariant.ParentEvent) |
| 19 | + { |
| 20 | + <div class="child-content"> |
| 21 | + @ChildContent |
| 22 | + </div> |
| 23 | + } |
| 24 | + |
| 25 | + <article> |
| 26 | + @if (TopDetails is { } || AdminButtons is { }) |
| 27 | + { |
| 28 | + <div class="top-details"> |
| 29 | + <div class="top-details-content"> |
| 30 | + @TopDetails |
| 31 | + </div> |
| 32 | + <div class="admin-buttons"> |
| 33 | + @AdminButtons |
| 34 | + </div> |
| 35 | + </div> |
| 36 | + } |
| 37 | + <header> |
| 38 | + @if (Variant is CardVariant.Event or CardVariant.ParentEvent) |
| 39 | + { |
| 40 | + <md-icon>event</md-icon> |
| 41 | + } |
| 42 | + <div style="flex: 1"> |
| 43 | + <div class="title"> |
| 44 | + @if (InternalUrl is { }) |
| 45 | + { |
| 46 | + <a href="@InternalUrl"> |
| 47 | + <Heading Level="@HeadingLevel"> |
| 48 | + @Title |
| 49 | + </Heading> |
| 50 | + </a> |
| 51 | + } |
| 52 | + else |
| 53 | + { |
| 54 | + <Heading Level="@HeadingLevel"> |
| 55 | + @Title |
| 56 | + </Heading> |
| 57 | + } |
| 58 | + </div> |
| 59 | + @if (MiddleDetails is { }) |
| 60 | + { |
| 61 | + <div class="middle-details"> |
| 62 | + @MiddleDetails |
| 63 | + </div> |
| 64 | + } |
| 65 | + </div> |
| 66 | + @if (ActionButton is { }) |
| 67 | + { |
| 68 | + <div class="action-button"> |
| 69 | + @ActionButton |
| 70 | + </div> |
| 71 | + } |
| 72 | + </header> |
| 73 | + |
| 74 | + @if (Content is { }) |
| 75 | + { |
| 76 | + <div class="content"> |
| 77 | + @Content |
| 78 | + </div> |
| 79 | + } |
| 80 | + @if (ChildContent is { } && Variant is not CardVariant.ParentEvent) |
| 81 | + { |
| 82 | + <div class="child-content"> |
| 83 | + @ChildContent |
| 84 | + </div> |
| 85 | + } |
| 86 | + </article> |
| 87 | + |
| 88 | + @* More reordering for accessibility, but for a Post and its Event *@ |
| 89 | + @if (ContainerContent is { }) |
| 90 | + { |
| 91 | + <div class="container-content"> |
| 92 | + @ContainerContent |
| 93 | + </div> |
| 94 | + } |
| 95 | +</div> |
| 96 | + |
| 97 | +@code { |
| 98 | + [Parameter, EditorRequired] public CardVariant Variant { get; set; } |
| 99 | + [Parameter] public RenderFragment? ContainerContent { get; set; } |
| 100 | + [Parameter] public RenderFragment? AdminButtons { get; set; } |
| 101 | + [Parameter, EditorRequired] public int HeadingLevel { get; set; } |
| 102 | + [Parameter] public RenderFragment? TopDetails { get; set; } |
| 103 | + [Parameter] public RenderFragment? Title { get; set; } |
| 104 | + [Parameter] public string? InternalUrl { get; set; } |
| 105 | + [Parameter] public RenderFragment? MiddleDetails { get; set; } |
| 106 | + [Parameter] public RenderFragment? ActionButton { get; set; } |
| 107 | + [Parameter] public RenderFragment? Content { get; set; } |
| 108 | + [Parameter] public RenderFragment? ChildContent { get; set; } |
| 109 | +} |
0 commit comments