Style the landing page

pull/2/head
Doc Ritezel 7 years ago
parent 36a3fb2a2f
commit 630d811159
  1. 2
      assets/brunch-config.js
  2. 3
      assets/css/app.scss
  3. 2
      assets/css/components/_all.scss
  4. 16
      assets/css/components/_blocks.scss
  5. 21
      assets/css/components/_container.scss
  6. 8
      assets/css/components/_footer.scss
  7. 24
      assets/css/components/_header.scss
  8. 16
      assets/css/components/_transactions.scss
  9. 8
      assets/css/explorer/_all.scss
  10. 5
      assets/css/explorer/_breakpoints.scss
  11. 29
      assets/css/explorer/_color.scss
  12. 19
      assets/css/explorer/_header.scss
  13. 17
      assets/css/explorer/_open_sans.scss
  14. 7
      assets/css/explorer/_paper.scss
  15. 17
      assets/css/explorer/_size.scss
  16. 23
      assets/css/explorer/_table.scss
  17. 23
      assets/css/explorer/_typography.scss
  18. 5
      assets/package-lock.json
  19. 1
      assets/package.json
  20. 3
      lib/explorer_web/router.ex
  21. 3
      lib/explorer_web/templates/layout/_footer.html.eex
  22. 8
      lib/explorer_web/templates/layout/_header.html.eex
  23. 26
      lib/explorer_web/templates/layout/app.html.eex
  24. 104
      lib/explorer_web/templates/page/index.html.eex
  25. 8
      lib/explorer_web/views/layout_view.ex
  26. 62
      priv/gettext/default.pot
  27. 62
      priv/gettext/en/LC_MESSAGES/default.po
  28. 2
      test/explorer_web/controllers/page_controller_test.exs
  29. 4
      test/explorer_web/features/contributor_browsing_test.exs

@ -56,7 +56,7 @@ exports.config = {
precision: 8,
allowCache: true,
options: {
includePaths: ["node_modules/bootstrap-sass/assets/stylesheets"]
includePaths: ["node_modules/normalize-scss/sass"]
}
}
},

@ -1,4 +1,5 @@
@import "bootstrap";
@import "explorer/all";
@import "normalize/import-now";
@import "components/all";
/* Phoenix flash messages */

@ -1,3 +1,5 @@
@import "blocks";
@import "container";
@import "header";
@import "transactions";
@import "footer";

@ -1,9 +1,21 @@
.blocks {
@extend %paper;
&__container {
padding: explorer-size(-1) explorer-size(0);
& + & { padding-top: 0; }
&--title { padding-top: explorer-size(0); }
}
&__title {
@extend h2;
@include explorer-typography("title");
color: explorer-color("slate", "100");
margin: 0;
}
&__table {
@extend .table;
@extend %table;
@include explorer-typography("body1");
color: explorer-color("slate", "100");
}
}

@ -0,0 +1,21 @@
%explorer-container-height { min-height: calc(100vh - #{$explorer-header-small} - #{explorer-size(-1) * 2}); }
@media (orientation: landscape) and (max-height: $explorer-breakpoint-landscape) {
%explorer-container-height { min-height: calc(100vh - #{$explorer-header-medium} - #{explorer-size(-1) * 2}); }
}
@media (min-width: $explorer-breakpoint-landscape) {
%explorer-container-height { min-height: calc(100vh - #{$explorer-header-large} - #{explorer-size(-1) * 2}); }
}
.container {
@extend %explorer-container-height;
background: explorer-color("slate", "500");
padding-top: explorer-size(-1);
padding-bottom: explorer-size(-1);
&__section {
display: block;
padding: 0 explorer-size(-2);
}
}

@ -0,0 +1,8 @@
.footer {
@include explorer-typography("body1");
display: block;
background: explorer-color("slate", "100");
color: explorer-color("white");
text-align: center;
padding: explorer-size(-1) 0;
}

@ -1,10 +1,24 @@
.header {
&__logo {
@extend .img-responsive;
width: 5em;
@extend %explorer-header-min-height;
background: explorer-color("gray", 900);
&__container {
width: 100%;
}
&__title {
@extend h1;
&__row { vertical-align: middle; }
&__cell {
@extend %explorer-header-height;
&--logo { @extend %explorer-header-square-width; }
}
&__logo-link {
@extend %explorer-header-height;
@extend %explorer-header-square-width;
display: block;
}
&__logo {
@extend %explorer-header-height;
@extend %explorer-header-square-width;
display: block;
}
}

@ -1,9 +1,21 @@
.transactions {
@extend %paper;
&__container {
padding: explorer-size(-1) explorer-size(0);
& + & { padding-top: 0; }
&--title { padding-top: explorer-size(0); }
}
&__title {
@extend h2;
@include explorer-typography("title");
color: explorer-color("slate", "100");
margin: 0;
}
&__table {
@extend .table;
@extend %table;
@include explorer-typography("body1");
color: explorer-color("slate", "100");
}
}

@ -0,0 +1,8 @@
@import "breakpoints";
@import "color";
@import "header";
@import "size";
@import "open_sans";
@import "paper";
@import "table";
@import "typography";

@ -0,0 +1,5 @@
$explorer-breakpoint-landscape: 480px;
$explorer-breakpoint-sm: 544px;
$explorer-breakpoint-md: 768px;
$explorer-breakpoint-lg: 992px;
$explorer-breakpoint-xl: 1200px;

@ -0,0 +1,29 @@
$explorer-colors: (
"blue": (
"500": #4786ff
),
"slate": (
"100": #1b2437,
"500": #f5f7fa,
"900": #e4e6e9
),
"gray": (
"900": #fafcff
),
"green": (
"500": #1bb85a
),
"purple": (
"500": #8940d5
),
"white": #ffffff,
"black": #000000
);
@function explorer-color($color-name, $tone: null) {
@if ($tone) {
@return map-get(map-get($explorer-colors, $color-name), $tone);
} @else {
@return map-get($explorer-colors, $color-name);
}
}

@ -0,0 +1,19 @@
$explorer-header-small: 48px;
$explorer-header-medium: 56px;
$explorer-header-large: 64px;
%explorer-header-height { height: $explorer-header-small; }
%explorer-header-square-width { width: $explorer-header-small; }
%explorer-header-min-height { min-height: $explorer-header-small; }
@media (orientation: landscape) and (max-height: $explorer-breakpoint-landscape) {
%explorer-header-height { height: $explorer-header-medium; }
%explorer-header-square-width { width: $explorer-header-medium; }
%explorer-header-min-height { min-height: $explorer-header-medium; }
}
@media (min-width: $explorer-breakpoint-landscape) {
%explorer-header-height { height: $explorer-header-large; }
%explorer-header-square-width { width: $explorer-header-large; }
%explorer-header-min-height { min-height: $explorer-header-large; }
}

File diff suppressed because one or more lines are too long

@ -0,0 +1,7 @@
%paper {
margin-bottom: 1rem;
border-radius: explorer-size(-4);
background-color: explorer-color("white");
box-shadow: 0 2px 2px 0 rgba(explorer-color("black"), 0.16),
0 0px 2px 0 rgba(explorer-color("black"), 0.12);
}

@ -0,0 +1,17 @@
$golden-ratio: 1.61803398875;
@function explorer-size($exponent) {
$value: $golden-ratio;
@if $exponent > 0 {
@for $i from 1 through $exponent {
$value: $value * $golden-ratio;
}
} @elseif $exponent < 0 {
@for $i from 1 through -$exponent {
$value: $value / $golden-ratio;
}
}
@return 1rem * $value;
}

@ -0,0 +1,23 @@
%table {
width: 100%;
max-width: 100%;
margin-bottom: 1rem;
> thead,
> tbody,
> tfoot {
> tr {
> th { text-align: left; }
> th,
> td {
padding: explorer-size(-2) 0;
line-height: 1rem;
}
}
}
> thead > tr > th {
border-bottom: 2px solid explorer-color("slate", "900");
}
}

@ -0,0 +1,23 @@
$explorer-typography-styles: (
headline: (
"font-weight": 400,
"font-size": 24px,
"line-height": 32px
),
title: (
"font-weight": 400,
"font-size": 18px,
"line-height": 28px
),
body1: (
"font-weight": 400,
"font-size": 13px,
"line-height": 36px
)
);
@mixin explorer-typography($style) {
font-weight: map-get(map-get($explorer-typography-styles, $style), "font-weight");
font-size: map-get(map-get($explorer-typography-styles, $style), "font-size");
line-height: map-get(map-get($explorer-typography-styles, $style), "line-height");
}

@ -5086,6 +5086,11 @@
"remove-trailing-separator": "1.1.0"
}
},
"normalize-scss": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/normalize-scss/-/normalize-scss-7.0.0.tgz",
"integrity": "sha1-kuqsZVTMN2M2wGaCoNaiCZu7CIk="
},
"npmlog": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz",

@ -17,6 +17,7 @@
},
"dependencies": {
"bootstrap-sass": "^3.3.7",
"normalize-scss": "^7.0.0",
"phoenix": "file:../deps/phoenix",
"phoenix_html": "file:../deps/phoenix_html"
},

@ -10,7 +10,8 @@ defmodule ExplorerWeb.Router do
"content-security-policy" => "\
default-src 'self';\
script-src 'self' 'unsafe-inline' 'unsafe-eval';\
style-src 'self' 'unsafe-inline' 'unsafe-eval'\
style-src 'self' 'unsafe-inline' 'unsafe-eval';\
font-src 'self' 'unsafe-inline' 'unsafe-eval' data:;\
"
}
plug SetLocale, gettext: ExplorerWeb.Gettext, default_locale: "en"

@ -0,0 +1,3 @@
<footer class="footer">
<%= gettext "Copyright %{year} POA", year: 2018 %>
</footer>

@ -0,0 +1,8 @@
<header class="header">
<table class="header__container" cellspacing="0" cellpadding="0" border="0">
<tr class="header__row">
<td class="header__cell header__cell--logo"><%= logo_image(@conn, alt: gettext "POA Network Explorer") %></td>
<td class="header__cell" align="right"></td>
</tr>
</table>
</header>

@ -4,27 +4,17 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><%= gettext "explorer-title" %></title>
<title><%= gettext "POA Network Explorer" %></title>
<link rel="stylesheet" href="<%= static_path(@conn, "/css/app.css") %>">
</head>
<body>
<div class="container">
<header class="header">
<%=
static_path(@conn, "/images/logo.png")
|> img_tag(class: "header__logo")
|> link(to: ExplorerWeb.Endpoint.url())
%>
<div class="header__title"><%= gettext "explorer-title" %></div>
</header>
<p class="alert alert-info" role="alert"><%= get_flash(@conn, :info) %></p>
<p class="alert alert-danger" role="alert"><%= get_flash(@conn, :error) %></p>
<main role="main">
<%= render @view_module, @view_template, assigns %>
</main>
</div>
<%= render ExplorerWeb.LayoutView, "_header.html", assigns %>
<p class="alert alert-info" role="alert"><%= get_flash(@conn, :info) %></p>
<p class="alert alert-danger" role="alert"><%= get_flash(@conn, :error) %></p>
<main role="main" class="container">
<%= render @view_module, @view_template, assigns %>
</main>
<%= render ExplorerWeb.LayoutView, "_footer.html", assigns %>
<script src="<%= static_path(@conn, "/js/app.js") %>"></script>
</body>
</html>

@ -1,49 +1,57 @@
<div><%= gettext "explorer-welcome" %></div>
<section class="container__section">
<div class="blocks">
<div class="blocks__container blocks__container--title">
<h2 class="blocks__title"><%= gettext "Blocks" %></h2>
</div>
<div class="blocks__container">
<table class="blocks__table">
<thead class="blocks__header">
<tr>
<th class="blocks__column-header"><%= gettext "Height" %></th>
<th class="blocks__column-header"><%= gettext "Age" %></th>
<th class="blocks__column-header"><%= gettext "Transactions" %></th>
<th class="blocks__column-header"><%= gettext "Gas Used" %></th>
</tr>
</thead>
<tbody>
<%= for block <- @blocks do %>
<tr class="blocks__row">
<td class="blocks__column blocks__column--height"><%= block.number %></td>
<td class="blocks__column blocks__column--age"><%= block.age %></td>
<td class="blocks__column blocks__column--transactions_count"><%= block.transactions_count %></td>
<td class="blocks__column blocks__column--gas-used"><%= block.gas_used %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
<div class="blocks">
<div class="blocks__title"><%= gettext "blocks-title" %></div>
<table class="blocks__table">
<thead class="blocks__header">
<tr>
<th><%= gettext "Height" %></th>
<th><%= gettext "Age" %></th>
<th><%= gettext "Transactions" %></th>
<th><%= gettext "Gas Used" %></th>
</tr>
</thead>
<tbody>
<%= for block <- @blocks do %>
<tr class="blocks__row">
<td class="blocks__column--height"><%= block.number %></td>
<td class="blocks__column--age"><%= block.age %></td>
<td class="blocks__column--transactions_count"><%= block.transactions_count %></td>
<td class="blocks__column--gas-used"><%= block.gas_used %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
<div class="transactions">
<div class="transactions__title"><%= gettext "Transactions" %></div>
<table class="transactions__table">
<thead class="transactions__header">
<tr>
<th><%= gettext "Hash" %></th>
<th><%= gettext "Block" %></th>
<th><%= gettext "Age" %></th>
<th><%= gettext "Value" %></th>
</tr>
</thead>
<tbody>
<%= for transaction <- @transactions do %>
<tr class="transactions__row">
<td class="transactions__column--hash"><%= transaction.hash %></td>
<td class="transactions__column--block"><%= transaction.block.number %></td>
<td class="transactions__column--age"><%= transaction.block.timestamp |> Timex.from_now %></td>
<td class="transactions__column--value"><%= transaction.value %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
<div class="transactions">
<div class="transactions__container transactions__container--title">
<h2 class="transactions__title"><%= gettext "Transactions" %></h2>
</div>
<div class="transactions__container">
<table class="transactions__table">
<thead class="transactions__header">
<tr>
<th class="transactions__column-header"><%= gettext "Hash" %></th>
<th class="transactions__column-header"><%= gettext "Block" %></th>
<th class="transactions__column-header"><%= gettext "Age" %></th>
<th class="transactions__column-header"><%= gettext "Value" %></th>
</tr>
</thead>
<tbody>
<%= for transaction <- @transactions do %>
<tr class="transactions__row">
<td class="transactions__column transactions__column--hash"><%= transaction.hash %></td>
<td class="transactions__column transactions__column--block"><%= transaction.block.number %></td>
<td class="transactions__column transactions__column--age"><%= transaction.block.timestamp |> Timex.from_now %></td>
<td class="transactions__column transactions__column--value"><%= transaction.value %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
</section>

@ -1,3 +1,11 @@
defmodule ExplorerWeb.LayoutView do
use ExplorerWeb, :view
alias ExplorerWeb.Endpoint
def logo_image(conn, alt: alt) do
conn
|> static_path("/images/logo.png")
|> img_tag(class: "header__logo", alt: alt)
|> link(to: Endpoint.url(), class: "header__logo-link")
end
end

@ -1,58 +1,52 @@
## This file is a PO Template file.
##
## `msgid`s here are often extracted from source code.
## Add new translations manually only if they're dynamic
## translations that can't be statically extracted.
##
## Run `mix gettext.extract` to bring this file up to
## date. Leave `msgstr`s empty as changing them here as no
## effect: edit them in PO (`.po`) files instead.
msgid ""
#, elixir-format
#: lib/explorer_web/templates/page/index.html.eex:11
#: lib/explorer_web/templates/page/index.html.eex:40
msgid "Age"
msgstr ""
#: lib/explorer_web/templates/layout/app.html.eex:7
#: lib/explorer_web/templates/layout/app.html.eex:18
msgid "explorer-title"
#, elixir-format
#: lib/explorer_web/templates/page/index.html.eex:39
msgid "Block"
msgstr ""
#: lib/explorer_web/templates/page/index.html.eex:1
msgid "explorer-welcome"
#, elixir-format
#: lib/explorer_web/templates/page/index.html.eex:4
msgid "Blocks"
msgstr ""
#: lib/explorer_web/templates/page/index.html.eex:4
msgid "blocks-title"
#, elixir-format
#: lib/explorer_web/templates/layout/_footer.html.eex:2
msgid "Copyright %{year} POA"
msgstr ""
#: lib/explorer_web/templates/page/index.html.eex:11
#, elixir-format
#: lib/explorer_web/templates/page/index.html.eex:13
msgid "Gas Used"
msgstr ""
#: lib/explorer_web/templates/page/index.html.eex:8
msgid "Height"
#, elixir-format
#: lib/explorer_web/templates/page/index.html.eex:38
msgid "Hash"
msgstr ""
#, elixir-format
#: lib/explorer_web/templates/page/index.html.eex:10
msgid "Validated"
msgid "Height"
msgstr ""
#: lib/explorer_web/templates/page/index.html.eex:9
#: lib/explorer_web/templates/page/index.html.eex:34
msgid "Age"
#, elixir-format
#: lib/explorer_web/templates/layout/_header.html.eex:4
#: lib/explorer_web/templates/layout/app.html.eex:7
msgid "POA Network Explorer"
msgstr ""
#, elixir-format
#: lib/explorer_web/templates/page/index.html.eex:12
#: lib/explorer_web/templates/page/index.html.eex:32
msgid "Hash"
msgstr ""
#: lib/explorer_web/templates/page/index.html.eex:10
#: lib/explorer_web/templates/page/index.html.eex:28
msgid "Transactions"
msgstr ""
#: lib/explorer_web/templates/page/index.html.eex:33
msgid "Block"
msgstr ""
#: lib/explorer_web/templates/page/index.html.eex:35
#, elixir-format
#: lib/explorer_web/templates/page/index.html.eex:41
msgid "Value"
msgstr ""

@ -10,49 +10,55 @@ msgid ""
msgstr ""
"Language: en\n"
#: lib/explorer_web/templates/layout/app.html.eex:7
#: lib/explorer_web/templates/layout/app.html.eex:18
msgid "explorer-title"
msgstr "POA Network Explorer"
#, elixir-format
#: lib/explorer_web/templates/page/index.html.eex:11
#: lib/explorer_web/templates/page/index.html.eex:40
msgid "Age"
msgstr "Age"
#: lib/explorer_web/templates/page/index.html.eex:1
msgid "explorer-welcome"
msgstr "Welcome to our blockchain explorer."
#, elixir-format
#: lib/explorer_web/templates/page/index.html.eex:39
msgid "Block"
msgstr "Block"
#, elixir-format
#: lib/explorer_web/templates/page/index.html.eex:4
msgid "blocks-title"
msgid "Blocks"
msgstr "Blocks"
#: lib/explorer_web/templates/page/index.html.eex:11
#, elixir-format
#: lib/explorer_web/templates/layout/_footer.html.eex:2
msgid "Copyright %{year} POA"
msgstr "%{year} POA Network Ltd. All rights reserved"
#, elixir-format
#: lib/explorer_web/templates/page/index.html.eex:13
msgid "Gas Used"
msgstr "Gas Used"
#: lib/explorer_web/templates/page/index.html.eex:8
msgid "Height"
msgstr "Height"
#, elixir-format
#: lib/explorer_web/templates/page/index.html.eex:38
msgid "Hash"
msgstr "Hash"
#, elixir-format
#: lib/explorer_web/templates/page/index.html.eex:10
msgid "Validated"
msgstr "Validated"
msgid "Height"
msgstr "Height"
#: lib/explorer_web/templates/page/index.html.eex:9
#: lib/explorer_web/templates/page/index.html.eex:34
msgid "Age"
msgstr "Age"
#, elixir-format
#: lib/explorer_web/templates/layout/_header.html.eex:4
#: lib/explorer_web/templates/layout/app.html.eex:7
msgid "POA Network Explorer"
msgstr "POA Network Explorer"
#, elixir-format
#: lib/explorer_web/templates/page/index.html.eex:12
#: lib/explorer_web/templates/page/index.html.eex:32
msgid "Hash"
msgstr "Hash"
#: lib/explorer_web/templates/page/index.html.eex:10
#: lib/explorer_web/templates/page/index.html.eex:28
msgid "Transactions"
msgstr "Transactions"
#: lib/explorer_web/templates/page/index.html.eex:33
msgid "Block"
msgstr "Block"
#: lib/explorer_web/templates/page/index.html.eex:35
#, elixir-format
#: lib/explorer_web/templates/page/index.html.eex:41
msgid "Value"
msgstr "Value"

@ -11,7 +11,7 @@ defmodule ExplorerWeb.PageControllerTest do
describe "GET index/2 with a locale" do
test "returns a welcome message", %{conn: conn} do
conn = get conn, "/en"
assert html_response(conn, 200) =~ "Welcome"
assert html_response(conn, 200) =~ "POA"
end
test "returns a block", %{conn: conn} do

@ -10,9 +10,9 @@ defmodule ExplorerWeb.UserListTest do
assert current_path(session) == "/en"
session
|> assert_has(css(".header__title", text: "POA Network Explorer"))
|> assert_has(css(".header__logo"))
|> click(@logo)
|> assert_has(css("main", text: "Welcome to our blockchain explorer."))
|> assert_has(css("main", text: "Blocks"))
end
test "views blocks on the home page", %{session: session} do

Loading…
Cancel
Save