Skip to content

Commit

Permalink
Added support for social profiles in facts list. Closes #250.
Browse files Browse the repository at this point in the history
  • Loading branch information
impworks committed Dec 16, 2023
1 parent 8e28924 commit 5575389
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@using Bonsai.Code.DomainModel.Facts.Models
@using Impworks.Utils.Format
@model SocialProfilesFactModel

@Model.ShortTitle:
<ul>
@foreach (var item in Model.Values)
{
<li>@item.Type.GetEnumDescription(): @item.Value</li>
}
</ul>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@using Bonsai.Code.DomainModel.Facts.Models
@using Impworks.Utils.Format
<script type="text/x-template" data-kind="fact-template" id="SocialProfilesFactModel">
<div class="fact-wrapper">
<h6>
{{def.title}}
<button type="button" class="btn btn-outline-secondary btn-sm" v-on:click="add({})" title="Указать ссылку">
<i class="fa fa-plus"></i>
</button>
</h6>
<div v-if="!emptyList()" class="fact-list">
<div class="row" v-for="row in getList()">
<div class="col-sm-8 form form-fact fact-list-item">
<div class="form-row">
<div class="form-group col-sm-4">
<label>Тип</label>
<select v-model="row.Type" class="form-control form-control-sm mr-2">
@foreach (var prof in EnumHelper.GetEnumDescriptions<SocialProfileType>())
{
<option value="@prof.Key">@prof.Value</option>
}
</select>
</div>
<div class="form-group col-sm-8">
<button type="button" class="btn btn-outline-danger btn-sm btn-remove-fact" v-on:click="remove(row)" title="Удалить ссылку">
<i class="fa fa-remove"></i>
</button>
<label>Ссылка</label>
<input type="text" v-model="row.Value" class="form-control form-control-sm mr-2" />
</div>
</div>
</div>
</div>
</div>
</div>
</script>
10 changes: 10 additions & 0 deletions src/Bonsai/Areas/Common/Styles/Components/front/infoblock.scss
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,15 @@
.fact-item {
margin-bottom: 0.3rem;
}

.big-icons {
font-size: 32px;
line-height: 32px;

.big-icon {
display: inline-block;
margin-right: 0.5rem;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
@using Bonsai.Code.DomainModel.Facts.Models
@using Impworks.Utils.Format
@model SocialProfilesFactModel

<tr class="fact">
<th class="fact-title">@Model.ShortTitle</th>
</tr>
<tr class="fact">
<td class="fact-value big-icons">
@foreach (var item in Model.Values)
{
<a class="big-icon" href="@item.Value" target="_blank" title="@item.Type.GetEnumDescription()">
<span class="fa @(GetIcon(item.Type))"></span>
</a>
}
</td>
</tr>

@functions {
string GetIcon(SocialProfileType type)
{
return type switch
{
SocialProfileType.Facebook => "fa-facebook-square",
SocialProfileType.Twitter => "fa-twitter-square",
SocialProfileType.Github => "fa-github",
SocialProfileType.Youtube => "fa-youtube-play",
SocialProfileType.Telegram => "fa-telegram",
SocialProfileType.Odnoklassniki => "fa-odnoklassniki-square",
SocialProfileType.Vkontakte => "fa-vk",
_ => null
};
}
}
6 changes: 6 additions & 0 deletions src/Bonsai/Code/DomainModel/Facts/FactDefinitions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ static FactDefinitions()
new FactDefinition<SkillFactModel>("Skill", "Хобби"),
new FactDefinition<StringListFactModel>("Profession", "Профессия", "Профессия|Профессии"),
new FactDefinition<StringListFactModel>("Religion", "Религия", "Религия|Религии")
),
new FactDefinitionGroup(
"Meta",
"Прочее",
false,
new FactDefinition<SocialProfilesFactModel>("SocialProfiles", "Соцсети")
)
},

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System.ComponentModel;

namespace Bonsai.Code.DomainModel.Facts.Models
{
/// <summary>
/// Template for specifying known social profile links.
/// </summary>
public class SocialProfilesFactModel: FactListModelBase<SocialProfileFactItem>
{
}

/// <summary>
/// Single social profile link.
/// </summary>
public class SocialProfileFactItem
{
/// <summary>
/// Type of the profile.
/// </summary>
public SocialProfileType Type { get; set; }

/// <summary>
/// Link to the profile.
/// </summary>
public string Value { get; set; }
}

/// <summary>
/// Known social profile links (to display icons properly).
/// </summary>
public enum SocialProfileType
{
[Description("Facebook")]
Facebook,

[Description("Twitter")]
Twitter,

[Description("Одноклассники")]
Odnoklassniki,

[Description("Вконтакте")]
Vkontakte,

[Description("Telegram")]
Telegram,

[Description("Youtube")]
Youtube,

[Description("Github")]
Github,
}
}

0 comments on commit 5575389

Please sign in to comment.