diff --git a/app/assets/stylesheets/landing.css.scss b/app/assets/stylesheets/landing.css.scss new file mode 100644 index 0000000..e33c853 --- /dev/null +++ b/app/assets/stylesheets/landing.css.scss @@ -0,0 +1,44 @@ +.landing_columns { + & > div { + border-style: solid; + border-color: black; + border-width: 0; + text-align: center; + @media screen and (min-width: 48em) { + border-width: 0 1px; + padding: 1em 3em; + &:first-child { + text-align: right; + border-left: 0; + } + &:last-child { + text-align: left; + border-right: 0; + } + + a.login-button { + margin: 2em 2em 0 0; + } + } + } +} + +a.login-button { + font-size: 200%; +} + +.full-table { + width: 100%; +} + +.landing-column { + padding: 1em; +} + +.columns-title { + text-align: center; +} + +.shame-percentage { + text-align: right +} diff --git a/app/assets/stylesheets/pages.css.scss b/app/assets/stylesheets/pages.css.scss new file mode 100644 index 0000000..0d6878a --- /dev/null +++ b/app/assets/stylesheets/pages.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the pages controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/pages.scss b/app/assets/stylesheets/pages.scss deleted file mode 100644 index 72c5f89..0000000 --- a/app/assets/stylesheets/pages.scss +++ /dev/null @@ -1,35 +0,0 @@ -// Place all the styles related to the pages controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ -.shame-percentage { - text-align: right -} - -a.login-button { - font-size: 200%; - margin: 2em; -} - -.columns-title { - text-align: center; -} - -.left-column { - text-align: right; - padding: 1em 3em; - border-right: 1px solid black; -} - -.right-column { - text-align: left; - padding: 1em 3em; - border-left: 1px solid black; -} - -.full-table { - width: 100%; -} - -.landing-column { - padding: 1em; -} diff --git a/app/controllers/concerns/statistics.rb b/app/controllers/concerns/statistics.rb index a74cd3b..ce17079 100644 --- a/app/controllers/concerns/statistics.rb +++ b/app/controllers/concerns/statistics.rb @@ -1,6 +1,4 @@ - class Statistics < Rails::Application - def shameful_users User.humans .where('-balance > :amount', amount: config.shameful_balance) @@ -32,12 +30,5 @@ class Statistics < Rails::Application .count .take([shameful_users.count, 4].max) end - - private - - def zeus_balance - User.zeus.balance - end - end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be79..c9cdb01 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,13 @@ module ApplicationHelper + def euro f + number_to_currency f, unit: '€' + end + + def euro_from_cents(f) + if f + euro (f / 100.0) + else + nil + end + end end diff --git a/app/views/partials/_flash.html.haml b/app/views/application/_flash.html.haml similarity index 100% rename from app/views/partials/_flash.html.haml rename to app/views/application/_flash.html.haml diff --git a/app/views/application/_menu.html.haml b/app/views/application/_menu.html.haml new file mode 100644 index 0000000..4de3be6 --- /dev/null +++ b/app/views/application/_menu.html.haml @@ -0,0 +1,9 @@ +.pure-u-1 + .pure-menu.pure-menu-horizontal + = link_to "Tab", root_path, class: "pure-menu-heading pure-menu-link" + %ul.pure-menu-list + %li.pure-menu-item + = link_to current_user.name.capitalize, current_user, class: "pure-menu-link" + - if current_user.penning + %li.pure-menu-item + =link_to "Zeus", User.zeus, class: "pure-menu-link" diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index bdd6542..3be4dee 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -2,21 +2,14 @@ %html %head %meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/ + %meta{:name => "viewport", :content => "width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"} %title Tab = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true = javascript_include_tag 'application', 'data-turbolinks-track' => true = csrf_meta_tags %body .pure-g + = render 'menu' if current_user .pure-u-1 - .pure-menu.pure-menu-horizontal - %ul.pure-menu-list - - if current_user - %li.pure-menu-item - = link_to current_user.name.capitalize, current_user, class: "pure-menu-link" - - if current_user.penning - %li.pure-menu-item - =link_to "Zeus", User.zeus, class: "pure-menu-link" - .pure-u-1 - = render 'partials/flash' + = render 'flash' = yield diff --git a/app/views/pages/landing.html.haml b/app/views/pages/landing.html.haml index 61db22b..37d0477 100644 --- a/app/views/pages/landing.html.haml +++ b/app/views/pages/landing.html.haml @@ -1,18 +1,18 @@ %h1.columns-title Tab = javascript_include_tag "//www.google.com/jsapi", "chartkick" - unless user_signed_in? - .pure-g - .pure-u-1-2.left-column + .pure-g.landing_columns + .pure-u-1.pure-u-md-1-2 %h2 Authentication %p Log een keer in en betaal uw schulden! %p= link_to "Log in met Zeus WPI", user_omniauth_authorize_path(:zeuswpi), class: "pure-button pure-button-primary login-button" - .pure-u-1-2.right-column + .pure-u-1.pure-u-md-1-2 %h2 Pie of Shame = pie_chart @statistics.shamehash - else %h2.columns-title Cute Little Statistics .pure-g - .pure-u-1-2.landing-column + .pure-u-1.pure-u-md-1-2.landing-column %h3.columns-title Pie of Shame = pie_chart @statistics.shamehash %h3.columns-title Table of Shame @@ -27,7 +27,7 @@ // Won't divide by zero because there won't be any users with // a shameful debt if the total debt is zero. %td.shame-percentage= "#{-100 * user.balance / @statistics.total_debt}%" - .pure-u-1-2.landing-column + .pure-u-1.pure-u-md-1-2.landing-column %h3.columns-title Distribution of Debt Sources = pie_chart @statistics.by_issuer %h3.columns-title Top Debt Creators diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index 3dcecec..5260746 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -1,4 +1,6 @@ -%h2= "#{@user.name} (balance: €#{@user.balance/100.0})" +%h2 + = @user.name + %small= "balance: #{euro_from_cents @user.balance}" = render 'transactions/new'