diff --git a/app/assets/stylesheets/_variables.scss b/app/assets/stylesheets/_variables.scss new file mode 100644 index 0000000..04f158f --- /dev/null +++ b/app/assets/stylesheets/_variables.scss @@ -0,0 +1,13 @@ +$content-width: 800px; +$content-max-width: 100%; + +$text-color-body: #222; +$text-color-discreet: #888; + +$background-color-notice: #efffc4; +$background-color-alert: #fff4c2; + +$color-blue: #0d4f99; +$color-purple: #8955a0; +$color-red-bright: #c00; +$color-red-dark: #990c0e; diff --git a/app/assets/stylesheets/admin.scss b/app/assets/stylesheets/admin.scss new file mode 100644 index 0000000..6013c66 --- /dev/null +++ b/app/assets/stylesheets/admin.scss @@ -0,0 +1,22 @@ +@import "variables"; + +body#admin-panel { + #wrapper { + > header { + background: $color-red-bright; + background: linear-gradient(35deg, $color-purple 0, $color-red-dark 100%); + } + } + + #main-nav { + ul { + li { + a { + &.active { + border-bottom: 2px solid $color-red-bright; + } + } + } + } + } +} diff --git a/app/assets/stylesheets/fonts.scss b/app/assets/stylesheets/fonts.scss index ce3de15..2d1842f 100644 --- a/app/assets/stylesheets/fonts.scss +++ b/app/assets/stylesheets/fonts.scss @@ -1,3 +1,5 @@ +@import "variables"; + @font-face { font-family: 'Raleway'; src: url('/fonts/raleway-light.woff') format('woff2'); @@ -8,6 +10,7 @@ body { font-family: "Open Sans", Helvetica, Arial, sans-serif; font-weight: 400; + color: $text-color-body; } h1, h2, h3 { diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index c615505..41ff821 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -1,11 +1,6 @@ +@import "variables"; @import "mediaqueries"; -$content-width: 800px; -$content-max-width: 100%; - -body { -} - #wrapper { width: 100%; text-align: center; @@ -14,8 +9,8 @@ body { margin: 0 auto; padding: 4rem 0; text-align: center; - background: #0d4f99; - background: linear-gradient(35deg, #8955a0 0, #0d4f99 100%); + background: $color-blue; + background: linear-gradient(35deg, $color-purple 0, $color-blue 100%); @include media-max(small) { padding: 3rem 0; @@ -77,18 +72,18 @@ body { padding: 2rem 0; &.notice { - background: #efffc4; + background: $background-color-notice; } &.alert { - background: #fff4c2; + background: $background-color-alert; } } main { width: $content-width; max-width: $content-max-width; - margin: 4rem auto; + margin: 4rem auto 6rem auto; text-align: left; @include media-max(medium) { @@ -135,8 +130,8 @@ main { section { border-bottom: 1px dotted #ccc; - padding-bottom: 4rem; - margin-bottom: 4rem; + padding-bottom: 3rem; + margin-bottom: 3rem; @include media-max(small) { padding-bottom: 3rem; @@ -169,9 +164,13 @@ main { .grid-item { p { - color: #888; + color: $text-color-discreet; font-size: 0.85rem; } } } } + +.text-centered { + text-align: center; +} diff --git a/app/assets/stylesheets/main_nav.scss b/app/assets/stylesheets/main_nav.scss new file mode 100644 index 0000000..eaa1756 --- /dev/null +++ b/app/assets/stylesheets/main_nav.scss @@ -0,0 +1,51 @@ +@import "variables"; +@import "mediaqueries"; + +#main-nav { + width: 100%; + text-align: center; + background-color: #efefef; + + .wrapper { + width: $content-width; + max-width: $content-max-width; + margin: 0 auto; + } + + ul { + @include media-max(large) { + display: grid; + grid-template-columns: repeat(1fr); + grid-template-columns: 1fr 1fr 1fr; + } + + li { + @include media-min(large) { + display: inline; + } + + @include media-max(large) { + display: block; + } + + a { + display: inline-block; + padding: 1.5rem 2rem; + text-decoration: none; + color: $text-color-discreet; + + @include media-max(large) { + display: block; + text-align: center; + padding-left: 0; + padding-right: 0; + } + + &.active { + color: $text-color-body; + border-bottom: 2px solid #ffd000; + } + } + } + } +} diff --git a/app/controllers/admin/base_controller.rb b/app/controllers/admin/base_controller.rb index 883c829..8688535 100644 --- a/app/controllers/admin/base_controller.rb +++ b/app/controllers/admin/base_controller.rb @@ -3,4 +3,6 @@ class Admin::BaseController < ApplicationController before_action :authenticate_user! before_action :authorize_admin + layout "admin" + end diff --git a/app/controllers/admin/dashboard_controller.rb b/app/controllers/admin/dashboard_controller.rb index 311d077..9cf8114 100644 --- a/app/controllers/admin/dashboard_controller.rb +++ b/app/controllers/admin/dashboard_controller.rb @@ -1,4 +1,5 @@ class Admin::DashboardController < Admin::BaseController def index + @current_section = :dashboard end end diff --git a/app/controllers/admin/donations_controller.rb b/app/controllers/admin/donations_controller.rb index 7b00bac..e6c37cc 100644 --- a/app/controllers/admin/donations_controller.rb +++ b/app/controllers/admin/donations_controller.rb @@ -1,5 +1,6 @@ class Admin::DonationsController < Admin::BaseController before_action :set_donation, only: [:show, :edit, :update, :destroy] + before_action :set_current_section, only: [:index, :show, :new, :edit] # GET /donations # GET /donations.json @@ -71,4 +72,8 @@ class Admin::DonationsController < Admin::BaseController def donation_params params.require(:donation).permit(:user_id, :amount_sats, :amount_eur, :amount_usd, :public_name, :paid_at) end + + def set_current_section + @current_section = :donations + end end diff --git a/app/controllers/admin/ldap_users_controller.rb b/app/controllers/admin/ldap_users_controller.rb index def46f4..1dfea57 100644 --- a/app/controllers/admin/ldap_users_controller.rb +++ b/app/controllers/admin/ldap_users_controller.rb @@ -1,4 +1,6 @@ class Admin::LdapUsersController < Admin::BaseController + before_action :set_current_section + def index attributes = %w{dn cn uid mail admin} filter = Net::LDAP::Filter.eq("uid", "*") @@ -38,4 +40,8 @@ class Admin::LdapUsersController < Admin::BaseController def ldap_config ldap_config ||= YAML.load(ERB.new(File.read("#{Rails.root}/config/ldap.yml")).result)[Rails.env] end + + def set_current_section + @current_section = :ldap_users + end end diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index cbcbe43..49c0764 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -2,5 +2,6 @@ class DashboardController < ApplicationController before_action :require_user_signed_in def index + @current_section = :dashboard end end diff --git a/app/controllers/donations_controller.rb b/app/controllers/donations_controller.rb index 74ee81c..7800e09 100644 --- a/app/controllers/donations_controller.rb +++ b/app/controllers/donations_controller.rb @@ -5,5 +5,6 @@ class DonationsController < ApplicationController # GET /donations.json def index @donations = current_user.donations.completed + @current_section = :contributions end end diff --git a/app/controllers/invitations_controller.rb b/app/controllers/invitations_controller.rb index c0affd8..72743e5 100644 --- a/app/controllers/invitations_controller.rb +++ b/app/controllers/invitations_controller.rb @@ -8,6 +8,7 @@ class InvitationsController < ApplicationController def index @invitations_unused = current_user.invitations.unused @invitations_used = current_user.invitations.used + @current_section = :invitations end # GET /invitations/a-random-invitation-token diff --git a/app/views/admin/dashboard/index.html.erb b/app/views/admin/dashboard/index.html.erb index 34a898c..2e04a10 100644 --- a/app/views/admin/dashboard/index.html.erb +++ b/app/views/admin/dashboard/index.html.erb @@ -1,8 +1,3 @@ -
- Ohai there, admin human. +
+ With great power comes great responsibility.
-URL | -Accepted | -Invited user | -
---|
<%= invitation_url(invitation.token) %> | -<%= invitation.used_at.strftime("%Y-%m-%d") %> | -<%= User.find(invitation.invited_user_id).address %> | +URL | +Accepted | +Invited user |
---|
+ Signed in as <%= current_user.cn %>@kosmos.org. + <%= link_to "Log out", destroy_user_session_path, method: :delete %> +
+ <% end %> +<%= msg %>
+<%= msg %>
diff --git a/app/views/shared/_admin_nav.html.erb b/app/views/shared/_admin_nav.html.erb new file mode 100644 index 0000000..c907b60 --- /dev/null +++ b/app/views/shared/_admin_nav.html.erb @@ -0,0 +1,18 @@ + diff --git a/app/views/shared/_main_nav.html.erb b/app/views/shared/_main_nav.html.erb new file mode 100644 index 0000000..3b1d5b9 --- /dev/null +++ b/app/views/shared/_main_nav.html.erb @@ -0,0 +1,18 @@ + diff --git a/spec/features/admin/dashboard_spec.rb b/spec/features/admin/dashboard_spec.rb index b6e04c5..3120d5b 100644 --- a/spec/features/admin/dashboard_spec.rb +++ b/spec/features/admin/dashboard_spec.rb @@ -10,6 +10,6 @@ RSpec.describe 'Admin dashboard', type: :feature do scenario 'View dashboard' do visit admin_root_path - expect(page).to have_content('Admin Panel') + expect(page).to have_content('great power') end end