Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(backoffice): markdown and kb styling #174

Merged
merged 2 commits into from
Aug 23, 2024
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ appsettings.json
appsettings-backoffice.json
firebase.json


## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

Expand All @@ -12,6 +11,7 @@ firebase.json
*.user
*.userosscache
*.sln.docstates
/_private

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
Expand Down
13 changes: 13 additions & 0 deletions src/Eurofurence.App.Backoffice/Components/MarkdownRenderer.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@namespace Eurofurence.App.Backoffice.Components
@using Eurofurence.App.Domain.Model.Knowledge
@using Markdig

<div class="md-renderer">
@((MarkupString)Markdown.ToHtml(Text ?? ""))
</div>

@code {

[Parameter] public string? Text { get; set; }

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
div.md-renderer ::deep * {
box-sizing: border-box;
}

div.md-renderer ::deep p {
margin-top: 1em;
margin-bottom: 1em;
margin-block-start: 1em;
margin-block-end: 1em;
margin-inline-start: 0px;
margin-inline-end: 0px;
}

div.md-renderer ::deep hr {
display: block;
margin-top: 0.5em;
margin-bottom: 0.5em;
border-style: inset;
border-width: 1px
}


div.md-renderer ::deep ul,
div.md-renderer ::deep ol {
padding-inline-start: 40px;
}

div.md-renderer ::deep ul {
list-style: disc;
}

div.md-renderer ::deep ol {
list-style: decimal;
}
18 changes: 8 additions & 10 deletions src/Eurofurence.App.Backoffice/Pages/KnowledgeBase.razor
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,16 @@
<MudText Typo="Typo.h6">Show All</MudText>
</CardHeaderContent>
</MudCardHeader>
<MudCardActions>
</MudCardActions>
<MudCardContent>
<MudText>Show all entries</MudText>
<MudText>Select group below to filter.</MudText>
</MudCardContent>
</MudCard>
</MudListItem>
@if (Loading)
{
<MudProgressLinear Color="Color.Primary" Indeterminate="true" Class="my-7" />
}
@foreach (var knowledgeGroup in _knowledgeGroups)
@foreach (var knowledgeGroup in _knowledgeGroups.Values)
{
<MudListItem @onclick="() => _selectedGroup = knowledgeGroup">
<MudCard Style="background-color: transparent">
Expand All @@ -58,8 +56,6 @@
@onclick="() => DeleteKnowledgeGroup(knowledgeGroup.Id)"></MudIconButton>
</CardHeaderActions>
</MudCardHeader>
<MudCardActions>
</MudCardActions>
<MudCardContent>
<MudText>@knowledgeGroup.Description</MudText>
</MudCardContent>
Expand Down Expand Up @@ -97,6 +93,7 @@
<MudCard Class="mt-4">
<MudCardHeader>
<CardHeaderContent>
<MudText Typo="Typo.caption" HtmlTag="h5">@knowledgeEntry.KnowledgeGroup.Name</MudText>
<MudText Typo="Typo.h6">@knowledgeEntry.Title</MudText>
</CardHeaderContent>
<CardHeaderActions>
Expand All @@ -107,7 +104,7 @@
</CardHeaderActions>
</MudCardHeader>
<MudCardContent>
<MudText Class="mb-4">@((MarkupString)Markdown.ToHtml(knowledgeEntry.Text))</MudText>
<MarkdownRenderer Text="@knowledgeEntry.Text"></MarkdownRenderer>

@foreach (var image in knowledgeEntry.Images)
{
Expand All @@ -130,13 +127,13 @@
public bool Loading = true;
private string? _knowledgeEntrySearch;
private KnowledgeGroupRecord? _selectedGroup;
private List<KnowledgeGroupRecord> _knowledgeGroups = new List<KnowledgeGroupRecord>();
private Dictionary<Guid, KnowledgeGroupRecord> _knowledgeGroups = new Dictionary<Guid, KnowledgeGroupRecord>();
private List<KnowledgeEntryRecord> _knowledgeEntries = new List<KnowledgeEntryRecord>();

protected override async Task OnInitializedAsync()
{
await LoadKnowledgeEntries();
await LoadKnowledgeGroups();
await LoadKnowledgeEntries();
}

private async Task LoadKnowledgeEntries()
Expand All @@ -151,6 +148,7 @@
{
Id = response.Id,
KnowledgeGroupId = response.KnowledgeGroupId,
KnowledgeGroup = _knowledgeGroups[response.KnowledgeGroupId],
Title = response.Title,
Text = response.Text,
Order = response.Order,
Expand Down Expand Up @@ -188,7 +186,7 @@
private async Task LoadKnowledgeGroups()
{
Loading = true;
_knowledgeGroups = (await KnowledgeService.GetKnowledgeGroupsAsync()).OrderBy(kg => kg.Order).ToList();
_knowledgeGroups = (await KnowledgeService.GetKnowledgeGroupsAsync()).OrderBy(kg => kg.Order).ToDictionary(kg => kg.Id);
Loading = false;
}

Expand Down