Skip to content

Commit 17fad42

Browse files
committed
Give option to remove and add new entries
1 parent 9c7385b commit 17fad42

File tree

7 files changed

+74
-6
lines changed

7 files changed

+74
-6
lines changed

LinkDotNet.Blog.Web/Pages/AboutMe.razor

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
@page "/AboutMe"
2+
@using Microsoft.AspNetCore.Http
23
@inject AppConfiguration appConfiguration
4+
@inject IHttpContextAccessor httpContextAccessor
35
/* TODO: Meta Tags About Me - [Name here] */
46

57
<div class="page">
68
<div class="container">
79
<div class="row">
810
<div class="col-lg-3 col-md-4">
9-
<Profile ProfileImageUrl="@appConfiguration.Introduction.ProfilePictureUrl"/>
11+
<Profile ProfileImageUrl="@appConfiguration.Introduction.ProfilePictureUrl"
12+
IsAuthenticated="@httpContextAccessor.HttpContext.User.Identity.IsAuthenticated"/>
1013
</div>
1114
<div class="col-lg-9 col-md-8 tab-container">
1215
<div class="row">
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<li><input type="text" @bind-value="@key" />:<input type="text" @bind-value="@value"/>
2+
<button type="button" class="btn btn-default" aria-label="Add Item" @onclick="@AddItemAsync">
3+
<i class="far fa-plus-square" aria-hidden="true"></i>
4+
</button>
5+
</li>
6+
7+
@code {
8+
[Parameter]
9+
public EventCallback<KeyValuePair<string, string>> ValueAdded { get; set; }
10+
11+
private string key = string.Empty;
12+
private string value = string.Empty;
13+
14+
private async Task AddItemAsync()
15+
{
16+
if (string.IsNullOrWhiteSpace(key) || string.IsNullOrWhiteSpace(value))
17+
{
18+
return;
19+
}
20+
21+
await ValueAdded.InvokeAsync(new KeyValuePair<string, string>(key, value));
22+
key = value = string.Empty;
23+
}
24+
}

LinkDotNet.Blog.Web/Shared/IntroductionCard.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
@using LinkDotNet.Domain
22
@inherits MarkdownComponentBase
33

4-
<div style="background-image: linear-gradient(0deg, rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.4)), url(@Introduction.BackgroundUrl);"
4+
<div style="--profile-background: url(@Introduction.BackgroundUrl)"
55
class="inverted-colors introduction-background">
66
<div class="introduction-container">
7-
<div class="profile-picture" style="background-image: url(@Introduction.ProfilePictureUrl)">
7+
<div class="profile-picture" style="--profile-image: url(@Introduction.ProfilePictureUrl)">
88

99
</div>
1010
<div class="profile-text">

LinkDotNet.Blog.Web/Shared/IntroductionCard.razor.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.introduction-background {
22
background-repeat: no-repeat;
33
background-size: cover;
4+
background-image: linear-gradient(0deg, rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.4)), var(--profile-background);
45
}
56

67
.introduction-container {
@@ -21,6 +22,7 @@
2122
border: white;
2223
margin: 4px 0 0 4px;
2324
box-shadow: 0 0 0 4px white;
25+
background-image: var(--profile-image);
2426
background-repeat: no-repeat;
2527
background-position: center center;
2628
background-size: cover;

LinkDotNet.Blog.Web/Shared/MarkdownComponentBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace LinkDotNet.Blog.Web.Shared
55
{
6-
public class MarkdownComponentBase : ComponentBase
6+
public abstract class MarkdownComponentBase : ComponentBase
77
{
88
private static readonly MarkdownPipeline MarkdownPipeline = new MarkdownPipelineBuilder()
99
.UseAdvancedExtensions()

LinkDotNet.Blog.Web/Shared/Profile.razor

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,35 @@
1111
<ul class="profile-keypoints">
1212
@foreach (var (key, value) in cv)
1313
{
14-
<li><bold> @RenderMarkupString(key)</bold>: @RenderMarkupString(value)</li>
14+
<li><bold>@RenderMarkupString(key)</bold>: @RenderMarkupString(value)
15+
@if (IsAuthenticated)
16+
{
17+
<button type="button" class="btn btn-default" aria-label="Delete Item" @onclick="() => ShowDeleteDialog(key)">
18+
<i class="fas fa-trash-alt" aria-hidden="true"></i>
19+
</button>
20+
}
21+
</li>
22+
}
23+
@if (IsAuthenticated)
24+
{
25+
<AddProfileShortItem ValueAdded="@AddValue"></AddProfileShortItem>
1526
}
1627
</ul>
1728
</div>
29+
30+
<ConfirmDialog @ref="Dialog" Content="Do you really want to delete this entry?" Title="Delete"
31+
OnYesPressed="DeleteItem"></ConfirmDialog>
32+
1833
@code {
1934
[Parameter]
2035
public string ProfileImageUrl { get; set; }
36+
37+
[Parameter]
38+
public bool IsAuthenticated { get; set; }
39+
40+
private ConfirmDialog Dialog { get; set; }
41+
42+
private string currentDeleteKey;
2143

2244
private readonly Dictionary<string, string> cv = new()
2345
{
@@ -27,4 +49,20 @@
2749
{"LinkedIn", "[Steven Giesel](https://www.linkedin.com/in/steven.giesel)"},
2850
{"Github", "<i class=\"fab fa-github \"></i>[linkdotnet](https://github.com/linkdotnet)"},
2951
};
52+
53+
private void ShowDeleteDialog(string key)
54+
{
55+
currentDeleteKey = key;
56+
Dialog.Open();
57+
}
58+
59+
private void DeleteItem()
60+
{
61+
cv.Remove(currentDeleteKey);
62+
}
63+
64+
private void AddValue(KeyValuePair<string, string> toAdd)
65+
{
66+
cv.Add(toAdd.Key, toAdd.Value);
67+
}
3068
}

LinkDotNet.Blog.Web/appsettings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@
2222
"ClientId": "",
2323
"ClientSecret": ""
2424
},
25-
"BlogPostsPerPage": 10
25+
"BlogPostsPerPage": 10,
26+
"IsAboutMeEnabled": true
2627
}

0 commit comments

Comments
 (0)