AmaLayout
The AmaLayout gem is used to add a standard layout and style to .ama.ab.ca sites.
Installation
Add this line to your application's Gemfile:
gem 'ama_layout'
And then execute:
$ bundle
Or install it yourself as:
$ gem install ama_layout
Usage
Configuration
Ensure that the app responds to:
Rails.configuration.gatekeeper_site
Rails.configuration.youraccount_site
Rails.configuration.insurance_site
Rails.configuration.membership_site
Rails.configuration.driveredonline_site
Rails.configuration.amaabca_site
Rails.configuration.forms_amaabca_site
Navigation
Navigation for each application has been built in custom made Navigation class and set as a hash to ama_layout gem:
Example:
class
include ActiveModel::Model
attr_accessor :current_user
def initialize args={}
self.current_user = args.fetch(:current_user)
end
def
return nil unless current_user
return ["member-in-renewal"] if current_user.profile.in_billing?
return ["member"] if current_user.member?
["non-member"]
end
private
def
YAML.load(ERB.new(File.read("#{Rails.root}/config/locales/navigation.yml")).result)
end
end
Custom Navigation yaml file used to set all navigation:
member:
"Your Account Dashboard":
subtitle: "Member Exclusive Services"
alt: "Back to my dashboard"
link: "<%= Rails.configuration.youraccount_site %>/dashboard"
"Online Profile":
subtitle: "Email / Password Change"
link: "<%= Rails.configuration.gatekeeper_site %>/user/edit"
"Billing":
subtitle: "Statements / Reward Options"
link: "<%= Rails.configuration.youraccount_site %>/billing"
.
.
.
non-member:
"Joins":
alt: "Back to my dashboard"
link: <%= Rails.configuration.membership_site %>
"New Driver Online Program":
link: "<%= Rails.configuration.driveredonline_site %>/login"
target: "_blank"
member-in-renewal:
"Your Account Dashboard":
subtitle: "Member Exclusive Services"
alt: "Back to my dashboard"
link: "<%= Rails.configuration.youraccount_site %>/dashboard"
"Renew":
link: "<%= Rails.configuration.youraccount_site %>/renew"
"Help":
link: "<%= Rails.configuration.youraccount_site %>/help"
"Contact Us":
link: "<%= Rails.configuration.amaabca_site %>/membership/contact-us--centre-locations-hours-and-contact-information"
target: "_blank"
Layout
The following layout example will give you: a header with appropriate navigation if applicable, side navigation if applicable and footer
<body class="<%= controller_name %>" id="top">
<%= render partial: "ama_layout/siteheader", locals: { navigation: Navigation.new(current_user: current_user).navigation } %>
<%= render "ama_layout/notices" %>
<div class="row wrapper">
<%= render partial: "ama_layout/custom_sidebar", locals: { navigation: Navigation.new(current_user: current_user).navigation } %>
<%= yield %>
</div>
<%= render "ama_layout/" %>
</body>
Stylesheets
Add the following to your application.scss
@import "ama_layout/application";
Javascript
Add the following to your application.js
//= require ama_layout/desktop
Mobile Layouts
There is no need for you to set any specific code, values,... for mobile views.
Contributing
- Fork it ( https://github.com/amaabca/ama_layout/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Create rspec tests to cover your feature (100% coverage required)
- Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request