Skip to content

Commit eb72f44

Browse files
committedFeb 20, 2022
Moved social accounts to introduction card
1 parent c82e03d commit eb72f44

File tree

6 files changed

+60
-53
lines changed

6 files changed

+60
-53
lines changed
 
Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,32 @@
11
@using LinkDotNet.Blog.Domain
2+
@inject AppConfiguration configuration
23
@inherits LinkDotNet.Blog.Web.Features.MarkdownComponentBase
34

4-
<div style="--profile-background: url(@Introduction.BackgroundUrl)" class="@IntroductionClass">
5+
<div style="--profile-background: url(@configuration.Introduction.BackgroundUrl)" class="@IntroductionClass">
56
<div class="introduction-container">
6-
<div class="profile-picture" style="--profile-image: url(@Introduction.ProfilePictureUrl)">
7+
<div class="profile-picture" style="--profile-image: url(@configuration.Introduction.ProfilePictureUrl)">
78
</div>
8-
<div class="profile-text">
9-
@RenderMarkupString(Introduction.Description)
9+
<div class="profile-text d-flex flex-column">
10+
<div>@RenderMarkupString(configuration.Introduction.Description)</div>
11+
<div class="d-flex flex-row justify-content-center">
12+
@if (configuration.HasLinkedinAccount)
13+
{
14+
<a id="linkedin" class="nav-link" target="_blank" href="@configuration.LinkedinAccountUrl">
15+
<i class="fab fa-linkedin"></i>
16+
</a>
17+
}
18+
@if (configuration.HasGithubAccount)
19+
{
20+
<a id="github" class="nav-link" target="_blank" href="@configuration.GithubAccountUrl">
21+
<i class="fab fa-github"></i>
22+
</a>
23+
}
24+
</div>
1025
</div>
1126
</div>
1227
</div>
1328
@code {
14-
[Parameter]
15-
public Introduction Introduction { get; set; }
16-
17-
private string IntroductionClass => !string.IsNullOrEmpty(Introduction.BackgroundUrl)
29+
private string IntroductionClass => !string.IsNullOrEmpty(configuration.Introduction.BackgroundUrl)
1830
? "introduction-background"
1931
: string.Empty;
2032
}

‎src/LinkDotNet.Blog.Web/Features/Home/Components/IntroductionCard.razor.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@
3737
font-size: clamp(0.9rem, 0.6479rem + 1.1268vw, 1.5rem);
3838
color: var(--text-color-inverted);
3939
line-height: clamp(1.5em, 0.6479rem + 1.1268vw, 2.25em);
40-
text-align: center
40+
text-align: center;
4141
}

‎src/LinkDotNet.Blog.Web/Features/Home/Components/NavMenu.razor

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,6 @@
2323
<ul class="navbar-nav ms-auto mb-2 mb-lg-0 me-5">
2424
<li class="nav-item active"><a class="nav-link" href="/"><i class="fa-solid fa-house"></i> Home</a></li>
2525
<li class="nav-item active"><a class="nav-link" href="/archive"><i class="fa-solid fa-box-archive"></i> Archive</a></li>
26-
@if (configuration.HasLinkedinAccount)
27-
{
28-
<li class="nav-item">
29-
<a class="nav-link" target="_blank" href="@configuration.LinkedinAccountUrl">
30-
<i
31-
class="fab fa-linkedin"></i>
32-
LinkedIn</a></li>
33-
}
34-
@if (configuration.HasGithubAccount)
35-
{
36-
<li class="nav-item">
37-
<a class="nav-link" target="_blank" href="@configuration.GithubAccountUrl"><i class="fab
38-
fa-github"></i>
39-
Github</a></li>
40-
}
4126
@if (configuration.IsAboutMeEnabled)
4227
{
4328
<li class="nav-item">

‎src/LinkDotNet.Blog.Web/Features/Home/Index.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
AbsolutePreviewImageUrl="@ImageUrl"
1616
Description="@(Markdown.ToPlainText(appConfiguration.Introduction.Description))"></OgData>
1717
<section class="introduction">
18-
<IntroductionCard Introduction="appConfiguration.Introduction"></IntroductionCard>
18+
<IntroductionCard></IntroductionCard>
1919
</section>
2020

2121
<section>

‎tests/LinkDotNet.Blog.IntegrationTests/Web/Shared/NavMenuTests.cs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,30 +28,6 @@ public void ShouldNavigateToSearchPage()
2828
navigationManager.Uri.Should().EndWith("search/Text");
2929
}
3030

31-
[Theory]
32-
[InlineData(null, null, false, false)]
33-
[InlineData(null, "linkedin", false, true)]
34-
[InlineData("github", null, true, false)]
35-
public void ShouldDisplayGithubAndLinkedInPageWhenOnlyWhenSet(
36-
string github,
37-
string linkedin,
38-
bool githubAvailable,
39-
bool linkedinAvailable)
40-
{
41-
var config = new AppConfiguration
42-
{
43-
GithubAccountUrl = github,
44-
LinkedinAccountUrl = linkedin,
45-
};
46-
Services.AddScoped(_ => config);
47-
this.AddTestAuthorization();
48-
49-
var cut = RenderComponent<NavMenu>();
50-
51-
cut.FindAll("li").Any(l => l.TextContent.Contains("Github")).Should().Be(githubAvailable);
52-
cut.FindAll("li").Any(l => l.TextContent.Contains("LinkedIn")).Should().Be(linkedinAvailable);
53-
}
54-
5531
[Fact]
5632
public void ShouldDisplayAboutMePage()
5733
{

‎tests/LinkDotNet.Blog.UnitTests/Web/Features/Home/Components/IntroductionCardTests.cs

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
using AngleSharp.Css.Dom;
33
using Bunit;
44
using LinkDotNet.Blog.Domain;
5+
using LinkDotNet.Blog.Web;
56
using LinkDotNet.Blog.Web.Features.Home.Components;
7+
using Microsoft.Extensions.DependencyInjection;
68

79
namespace LinkDotNet.Blog.UnitTests.Web.Features.Home.Components;
810

@@ -15,9 +17,13 @@ public void ShouldSetBackgroundWhenSet()
1517
{
1618
BackgroundUrl = "something_but_null",
1719
};
20+
var appConfiguration = new AppConfiguration
21+
{
22+
Introduction = introduction,
23+
};
24+
Services.AddScoped(_ => appConfiguration);
1825

19-
var cut = RenderComponent<IntroductionCard>(
20-
p => p.Add(s => s.Introduction, introduction));
26+
var cut = RenderComponent<IntroductionCard>();
2127

2228
var background = cut.FindAll(".introduction-background");
2329
background.Should().NotBeNullOrEmpty();
@@ -34,11 +40,39 @@ public void ShouldNotSetBackgroundWhenNotSet(string url)
3440
{
3541
BackgroundUrl = url,
3642
};
43+
var appConfiguration = new AppConfiguration
44+
{
45+
Introduction = introduction,
46+
};
47+
Services.AddScoped(_ => appConfiguration);
3748

38-
var cut = RenderComponent<IntroductionCard>(
39-
p => p.Add(s => s.Introduction, introduction));
49+
var cut = RenderComponent<IntroductionCard>();
4050

4151
var background = cut.FindAll(".introduction-background");
4252
background.Should().BeNullOrEmpty();
4353
}
54+
55+
[Theory]
56+
[InlineData(null, null, false, false)]
57+
[InlineData(null, "linkedin", false, true)]
58+
[InlineData("github", null, true, false)]
59+
public void ShouldDisplayGithubAndLinkedInPageWhenOnlyWhenSet(
60+
string github,
61+
string linkedin,
62+
bool githubAvailable,
63+
bool linkedinAvailable)
64+
{
65+
var config = new AppConfiguration
66+
{
67+
Introduction = new Introduction(),
68+
GithubAccountUrl = github,
69+
LinkedinAccountUrl = linkedin,
70+
};
71+
Services.AddScoped(_ => config);
72+
73+
var cut = RenderComponent<IntroductionCard>();
74+
75+
cut.FindAll("#github").Any().Should().Be(githubAvailable);
76+
cut.FindAll("#linkedin").Any().Should().Be(linkedinAvailable);
77+
}
4478
}

0 commit comments

Comments
 (0)