Skip to content

Commit

Permalink
🎨 Update Semantic UI option for web template to RC2 (OmniSharp#659)
Browse files Browse the repository at this point in the history
👯
  • Loading branch information
peterblazejewicz committed May 14, 2016
1 parent 286037e commit 6bbcfe8
Show file tree
Hide file tree
Showing 20 changed files with 67 additions and 70 deletions.
2 changes: 1 addition & 1 deletion templates/overrides/semantic/web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ validation summary.

For a form to be validated, add the `validate-me` class. To display the error messages use:

`<div asp-validation-summary="ValidationSummary.All" class="ui error message"></div>`
`<div asp-validation-summary="All" class="ui error message"></div>`

semantic.validation.js is where the magic happens. Upon error (highlight), find the nearest field element and add the error class.
When the error is cleared (unhighlight), remove the error class from the nearest field element.
Expand Down
45 changes: 15 additions & 30 deletions templates/overrides/semantic/web/TagHelpers/MenuLinkTagHelper.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
using Microsoft.AspNet.Mvc;
using Microsoft.AspNet.Mvc.Rendering;
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNet.Html.Abstractions;
using Microsoft.AspNet.Mvc.TagHelpers;
using Microsoft.AspNet.Mvc.ViewFeatures;
using Microsoft.AspNet.Razor.TagHelpers;
using Microsoft.Extensions.WebEncoders;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.Routing;
using Microsoft.AspNetCore.Mvc.TagHelpers;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Razor.TagHelpers;

namespace <%= namespace %>.TagHelpers
{
Expand All @@ -30,25 +27,16 @@ public class MenuLinkTagHelper : TagHelper
[ViewContext]
public ViewContext ViewContext { get; set; }

public IUrlHelper _UrlHelper { get; set; }

public MenuLinkTagHelper(IUrlHelper urlHelper)
{
_UrlHelper = urlHelper;
}

public override void Process(TagHelperContext context, TagHelperOutput output)
{
string menuUrl = _UrlHelper.Action(ActionName, ControllerName);
var urlHelper = new UrlHelper(ViewContext);

output.TagName = "";
string menuUrl = urlHelper.Action(ActionName, ControllerName);

var a = new TagBuilder("a");

a.MergeAttribute("href", $"{menuUrl}");
a.MergeAttribute("class", "item");

a.InnerHtml.Append(MenuText);
output.TagName = "a";
output.Attributes.Add("href", $"{menuUrl}");
output.Attributes.Add("class", "item blue");
output.Content.SetContent(MenuText);

var routeData = ViewContext.RouteData.Values;
var currentController = routeData["controller"];
Expand All @@ -57,12 +45,9 @@ public override void Process(TagHelperContext context, TagHelperOutput output)
if (String.Equals(ActionName, currentAction as string, StringComparison.OrdinalIgnoreCase)
&& String.Equals(ControllerName, currentController as string, StringComparison.OrdinalIgnoreCase))
{
a.AddCssClass("active");
a.AddCssClass("blue");
output.Attributes.SetAttribute("class", "active item blue");
}

output.Content.SetContent(a);

}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<input type="submit" class="ui large blue submit button" value="Register" />
<br />

<div asp-validation-summary="ValidationSummary.All" class="ui error message"></div>
<div asp-validation-summary="All" class="ui error message"></div>

</form>

Expand Down
14 changes: 7 additions & 7 deletions templates/overrides/semantic/web/Views/Account/Login.cshtml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
@using System.Collections.Generic
@using Microsoft.AspNet.Http
@using Microsoft.AspNet.Http.Authentication
@using Microsoft.AspNetCore.Http
@using Microsoft.AspNetCore.Http.Authentication
@model LoginViewModel
@inject SignInManager<ApplicationUser> SignInManager
@inject SignInManager<ApplicationUser> SignInManager

@{
ViewData["Title"] = "Log in";
}
@{
ViewData["Title"] = "Log in";
}

<div class="ui two column middle aligned very relaxed stackable grid" style="position:relative">
<div class="column">
Expand Down Expand Up @@ -37,7 +37,7 @@
<br/>
<br/>
Forgot your password? Click <a asp-action="ForgotPassword" asp-controller="Account">here</a>.
<div asp-validation-summary="ValidationSummary.All" class="ui error message"></div>
<div asp-validation-summary="All" class="ui error message"></div>

</form>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</div>
</div>
<input type="submit" class="ui large blue submit button" value="Register" />
<div asp-validation-summary="ValidationSummary.All" class="ui error message"></div>
<div asp-validation-summary="All" class="ui error message"></div>
</div>
</form>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
</div>
</div>
<button type="submit" class="ui large blue submit button">Reset</button>
<div asp-validation-summary="ValidationSummary.All" class="ui error message"></div>
<div asp-validation-summary="All" class="ui error message"></div>

</div>



</form>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

<input type="submit" class="ui blue submit button" value="Submit" />
<br />
<div asp-validation-summary="ValidationSummary.All" class="ui error message"></div>
<div asp-validation-summary="All" class="ui error message"></div>
<br />

</form>
Expand Down
2 changes: 0 additions & 2 deletions templates/overrides/semantic/web/Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,3 @@
</div>
</div>
</div>


Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
</div>
</div>
<input type="submit" class="ui blue submit button" value="Send Verification Code" />
<div asp-validation-summary="ValidationSummary.All" class="ui error message"></div>

<div asp-validation-summary="All" class="ui error message"></div>

</form>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<br/>
<input type="submit" class="ui large blue submit button" value="Change Password"/>
<br/>
<div asp-validation-summary="ValidationSummary.All" class="ui error message"></div>
<div asp-validation-summary="All" class="ui error message"></div>
</form>

@section Scripts {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@model ManageLoginsViewModel
@using Microsoft.AspNet.Http.Authentication
@using Microsoft.AspNetCore.Http.Authentication
@{
ViewData["Title"] = "Manage your external logins";
}
Expand Down Expand Up @@ -34,7 +34,7 @@
{
@: &nbsp;
}</div>

}
}
@if (Model.OtherLogins.Count > 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<br/>
<input type="submit" class="ui blue submit button" value="Set Password" />
<br/>
<div asp-validation-summary="ValidationSummary.All" class="ui error message"></div>
<div asp-validation-summary="All" class="ui error message"></div>
</form>

@section Scripts {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
<input asp-for="Code" placeholder="Verification Code" />
</div>
</div>

<input type="submit" class="ui blue submit button" value="Submit" />
<br/>
<div asp-validation-summary="ValidationSummary.All" class="ui error message"></div>
<div asp-validation-summary="All" class="ui error message"></div>
<br/>
</form>

Expand Down
7 changes: 7 additions & 0 deletions templates/overrides/semantic/web/Views/Shared/Error.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@

<h1 class="ui header">Error</h1>
<h2 class="ui header">An error occurred while processing your request.</h2>
<h3>Development Mode</h3>
<p>
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
</p>
<p>
<strong>Development environment should not be enabled in deployed applications</strong>, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>, and restarting the application.
</p>
12 changes: 8 additions & 4 deletions templates/overrides/semantic/web/Views/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
@using System.Security.Claims
@using Microsoft.AspNetCore.Identity
@using WebSemantic.Models
@inject SignInManager<ApplicationUser> SignInManager
@inject UserManager<ApplicationUser> UserManager

<!doctype html>
<html lang="">
<head>
Expand Down Expand Up @@ -44,9 +48,9 @@
<menulink class="blue item" controller-name="Home" action-name="Contact" menu-text="Contact"></menulink>


@if (User.IsSignedIn())
@if (SignInManager.IsSignedIn(User))
{
<div class="blue item"><a asp-controller="Manage" asp-action="Index" title="Manage">Hello @User.GetUserName()</a>
<div class="blue item"><a asp-controller="Manage" asp-action="Index" title="Manage">Hello @UserManager.GetUserName(User)</a>
</div>
<form asp-controller="Account" asp-action="LogOff" method="post" id="logoutForm" class="item">
<button type="submit" class="ui button">Log off</button>
Expand Down Expand Up @@ -104,7 +108,7 @@
<script src="~/js/site.js"></script>
</environment>
<environment names="Staging,Production">
<script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-2.1.4.min.js"
<script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-2.2.0.min.js"
asp-fallback-src="~/lib/jquery/dist/jquery.min.js"
asp-fallback-test="window.jQuery">
</script>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
@using System.Security.Claims
@using Microsoft.AspNetCore.Identity
@using <%= namespace %>.Models

@inject SignInManager<ApplicationUser> SignInManager
@inject UserManager<ApplicationUser> UserManager

@if (User.IsSignedIn())
@if (SignInManager.IsSignedIn(User))
{
<div class="right menu">
<div class="item"><a asp-controller="Manage" asp-action="Index" title="Manage">Hello @User.GetUserName()!</a></div>
<div class="item"><a asp-controller="Manage" asp-action="Index" title="Manage">Hello @UserManager.GetUserName(User)!</a></div>
<form asp-controller="Account" asp-action="LogOff" method="post" id="logoutForm" class="item">
<button type="submit" class="ui button">Log off</button>
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</script>
<script src="~/js/semantic.validation.min.js"></script>
<script src="https://ajax.aspnetcdn.com/ajax/mvc/5.2.3/jquery.validate.unobtrusive.min.js"
<script src="https://ajax.aspnetcdn.com/ajax/jquery.validation.unobtrusive/3.2.6/jquery.validate.unobtrusive.min.js"
asp-fallback-src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"
asp-fallback-test="window.jQuery && window.jQuery.validator && window.jQuery.validator.unobtrusive">
</script>
Expand Down
10 changes: 5 additions & 5 deletions templates/overrides/semantic/web/Views/_ViewImports.cshtml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@using <%= namespace %>
@using <%= namespace %>.Models
@using <%= namespace %>.ViewModels.Account
@using <%= namespace %>.ViewModels.Manage
@using Microsoft.AspNet.Identity
@addTagHelper "*, Microsoft.AspNet.Mvc.TagHelpers"
@addTagHelper "*, <%= namespace %>"
@using <%= namespace %>.Models.AccountViewModels
@using <%= namespace %>.Models.ManageViewModels
@using Microsoft.AspNetCore.Identity
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, <%= namespace %>
4 changes: 2 additions & 2 deletions templates/overrides/semantic/web/bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"name": "<%= namespace %>",
"private": true,
"dependencies": {
"jquery": "2.1.4",
"jquery": "2.2.0",
"jquery-validation": "1.14.0",
"jquery-validation-unobtrusive": "3.2.4",
"jquery-validation-unobtrusive": "3.2.6",
"semantic": "2.1.8"
}
}
2 changes: 1 addition & 1 deletion templates/overrides/semantic/webbasic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ validation summary.

For a form to be validated, add the `validate-me` class. To display the error messages use:

`<div asp-validation-summary="ValidationSummary.All" class="ui error message"></div>`
`<div asp-validation-summary="All" class="ui error message"></div>`

semantic.validation.js is where the magic happens. Upon error (highlight), find the nearest field element and add the error class.
When the error is cleared (unhighlight), remove the error class from the nearest field element.
Expand Down

0 comments on commit 6bbcfe8

Please sign in to comment.