Skip to content

Commit b773568

Browse files
committed
flag icons in page header
1 parent c63e48b commit b773568

File tree

5 files changed

+58
-0
lines changed

5 files changed

+58
-0
lines changed

lib/doc_page.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
require 'erector_scss'
55
require 'titleizer'
66
require 'html5_page'
7+
require 'flags'
78

89
class DocPage < Html5Page
910
needs :site_name, :doc_title, :doc_path, :page_name, :src, :locale
@@ -96,6 +97,10 @@ def body_content
9697
}
9798
ul(class: "navbar-nav nav") {
9899

100+
li {
101+
widget Flags
102+
}
103+
99104
li(class: "dropdown") {
100105
a("sites", href: "#", class: "dropdown-toggle", "data-toggle" => "dropdown")
101106
widget SiteIndex, site_name: site_name, locale: @locale

lib/flags.rb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
# Flag icons borrowed from https://www.gosquared.com/resources/flag-icons/
3+
# Put them in public/flags
4+
class Flags < Erector::Widget
5+
6+
# swiped from DocPage -- todo: unify
7+
def self.css_path
8+
here = File.expand_path File.dirname(__FILE__)
9+
File.expand_path "#{here}/../public/css"
10+
end
11+
12+
external :style, scss(File.read("#{css_path}/flags.scss"))
13+
14+
def initialize *args
15+
super
16+
@locales = ["us", "es"]
17+
end
18+
19+
def content
20+
ul.flags do
21+
@locales.each do |locale|
22+
subdomain = (locale == "us" ? "docs" : locale)
23+
li {
24+
a(href:"http://#{subdomain}.railsbridge.org") {
25+
img src: "/flags/#{locale.upcase}.png"
26+
}
27+
}
28+
end
29+
end
30+
end
31+
end

public/css/flags.scss

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
ul.flags {
2+
padding: 0;
3+
margin: 0;
4+
5+
> li {
6+
position: relative;
7+
display: block;
8+
float: left;
9+
10+
> a {
11+
position: relative;
12+
display: block;
13+
padding: 10px 15px;
14+
line-height: 20px;
15+
}
16+
17+
> img:hover {
18+
background-color: #eee;
19+
}
20+
}
21+
22+
}

public/flags/ES.png

410 Bytes
Loading

public/flags/US.png

156 Bytes
Loading

0 commit comments

Comments
 (0)