Skip to content

Commit 54d2dcc

Browse files
author
Ryan Bigg
committed
Section 4.5: Added Bootstrap for styling
1 parent 6a9b6b1 commit 54d2dcc

File tree

14 files changed

+458
-50
lines changed

14 files changed

+458
-50
lines changed

ticketee/Gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ gem 'jbuilder', '~> 2.0'
2323
# bundle exec rake doc:rails generates the API under doc/api.
2424
gem 'sdoc', '~> 0.4.0', group: :doc
2525

26+
gem 'bootstrap-sass', '~> 3.3'
27+
gem 'font-awesome-rails', '~> 4.2'
28+
gem 'simple_form', '3.1.0.rc2'
29+
2630
# Use ActiveModel has_secure_password
2731
# gem 'bcrypt', '~> 3.1.7'
2832

ticketee/Gemfile.lock

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ GEM
3939
arel (6.0.0.beta2)
4040
binding_of_caller (0.7.3.pre1)
4141
debug_inspector (>= 0.0.1)
42+
bootstrap-sass (3.3.0.1)
43+
sass (~> 3.2)
4244
builder (3.2.2)
4345
byebug (3.5.1)
4446
columnize (~> 0.8)
@@ -68,6 +70,8 @@ GEM
6870
factory_girl_rails (4.5.0)
6971
factory_girl (~> 4.5.0)
7072
railties (>= 3.0.0)
73+
font-awesome-rails (4.2.0.0)
74+
railties (>= 3.2, < 5.0)
7175
globalid (0.3.0)
7276
activesupport (>= 4.1.0)
7377
hike (1.2.3)
@@ -145,6 +149,9 @@ GEM
145149
sdoc (0.4.1)
146150
json (~> 1.7, >= 1.7.7)
147151
rdoc (~> 4.0)
152+
simple_form (3.1.0.rc2)
153+
actionpack (~> 4.0)
154+
activemodel (~> 4.0)
148155
slop (3.6.0)
149156
spring (1.1.3)
150157
sprockets (2.12.3)
@@ -179,16 +186,19 @@ PLATFORMS
179186
ruby
180187

181188
DEPENDENCIES
189+
bootstrap-sass (~> 3.3)
182190
byebug
183191
capybara (~> 2.4)
184192
coffee-rails (~> 4.1.0)
185193
factory_girl_rails (~> 4.5)
194+
font-awesome-rails (~> 4.2)
186195
jbuilder (~> 2.0)
187196
jquery-rails (~> 4.0.0.beta2)
188197
rails (= 4.2.0.beta4)
189198
rspec-rails (~> 3.1.0)
190199
sass-rails (~> 5.0.0.beta1)
191200
sdoc (~> 0.4.0)
201+
simple_form (= 3.1.0.rc2)
192202
spring
193203
sqlite3
194204
turbolinks

ticketee/app/assets/stylesheets/application.css

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
@import "bootstrap-sprockets";
2+
@import "bootstrap";
3+
@import "font-awesome";
4+
5+
body {
6+
padding: 20px 0px;
7+
}
8+
9+
a.new, a.edit, a.delete {
10+
@extend .btn;
11+
12+
13+
&:before {
14+
font-family: "FontAwesome";
15+
padding-right: 0.5em;
16+
}
17+
}
18+
19+
a.new {
20+
@extend .btn-primary;
21+
22+
&:before {
23+
@extend .fa-plus;
24+
}
25+
}
26+
27+
a.edit {
28+
@extend .btn-primary;
29+
30+
&:before {
31+
@extend .fa-pencil;
32+
}
33+
}
34+
35+
a.delete {
36+
@extend .btn-danger;
37+
38+
&:before {
39+
@extend .fa-trash;
40+
}
41+
}
42+
43+
.alert-notice {
44+
@extend .alert-success;
45+
}
46+
47+
.alert-alert {
48+
@extend .alert-danger;
49+
}

ticketee/app/views/layouts/application.html.erb

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,31 @@
1414
</head>
1515
<body>
1616

17-
<% flash.each do |key, message| %>
18-
<div class='flash' id='<%= key %>'>
19-
<%= message %>
20-
</div>
21-
<% end %>
17+
<div class='container'>
18+
<nav class="navbar navbar-default" role="navigation">
19+
<div class="container-fluid">
20+
<div class="navbar-header">
21+
<%= link_to "Ticketee", root_path, class: 'navbar-brand' %>
22+
</div>
23+
<ul class="nav navbar-nav">
24+
<li class='<%= 'active' if current_page?('/') %>'>
25+
<%= link_to "Home", root_path %>
26+
</li>
27+
</ul>
28+
</div>
29+
</nav>
30+
31+
<% flash.each do |key, message| %>
32+
<div class='alert alert-<%= key %>'>
33+
<%= message %>
34+
</div>
35+
<% end %>
2236

23-
<%= yield %>
37+
38+
<div class='col-md-12'>
39+
<%= yield %>
40+
</div>
41+
</div>
2442

2543
</body>
2644
</html>
Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
1-
<%= form_for(@project) do |f| %>
2-
<% if @project.errors.any? %>
3-
<div id="error_explanation">
4-
<h2><%= pluralize(@project.errors.count, "error") %>
5-
prohibited this project from being saved:</h2>
1+
<div class='col-md-4'>
2+
<%= simple_form_for(@project) do |f| %>
3+
<% if @project.errors.any? %>
4+
<div id="error_explanation">
5+
<h2><%= pluralize(@project.errors.count, "error") %>
6+
prohibited this project from being saved:</h2>
67

7-
<ul>
8-
<% @project.errors.full_messages.each do |msg| %>
9-
<li><%= msg %></li>
10-
<% end %>
11-
</ul>
12-
</div>
13-
<% end %>
14-
<p>
15-
<%= f.label :name %><br>
16-
<%= f.text_field :name %>
17-
</p>
8+
<ul>
9+
<% @project.errors.full_messages.each do |msg| %>
10+
<li><%= msg %></li>
11+
<% end %>
12+
</ul>
13+
</div>
14+
<% end %>
1815

19-
<p>
20-
<%= f.label :description %><br>
21-
<%= f.text_field :description %>
22-
</p>
16+
<%= f.input :name %>
17+
<%= f.input :description %>
2318

24-
<%= f.submit %>
25-
<% end %>
19+
<%= f.button :submit, class: 'btn-primary' %>
20+
<% end %>
21+
</div>
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
<h2>Edit project</h2>
1+
<div class='row'>
2+
<h2>Edit project</h2>
23

3-
<%= render "form" %>
4+
<%= render "form" %>
5+
</div>

ticketee/app/views/projects/index.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<%= link_to "New Project", new_project_path %>
1+
<%= link_to "New Project", new_project_path, class: "new" %>
22

33
<h2>Projects</h2>
44
<ul>
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
<h2>New Project</h2>
1+
<div class='row'>
2+
<h2>New Project</h2>
23

3-
<%= render "form" %>
4+
<%= render "form" %>
5+
</div>
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
<% title(@project.name, "Projects") %>
22
<h2><%= @project.name %></h2>
3-
<%= link_to "Edit Project", edit_project_path(@project) %>
3+
<%= link_to "Edit Project",
4+
edit_project_path(@project),
5+
class: "edit" %>
6+
47
<%= link_to "Delete Project",
58
project_path(@project),
69
method: :delete,
710
data: { confirm:
811
"Are you sure you want to delete this project?"
9-
} %>
12+
},
13+
class: "delete" %>

0 commit comments

Comments
 (0)