Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jyotibista committed Dec 25, 2020
1 parent 6ba85f3 commit 017d90c
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 49 deletions.
48 changes: 28 additions & 20 deletions public/css/style.css
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
.container {
margin: auto;
max-width: 1100px;
padding: 0 20px;
align-items: center;
}

form {
background: #eee;
width: 450px;
padding: 1rem;
}
ul {
list-style: none;
margin: 0;
padding: 0;
}
button {
margin-top: 10px;
}
#container {
margin: auto;
margin-top: 30px;
padding: 30px 100px;
align-items: center;
width: 40%;
border-radius: 20px;
}

#table {
width: 40%;
margin: auto;
margin-top: 30px;
}

ul {
list-style: none;
margin: 0;
padding: 0;
}

button {
margin-top: 10px;
}

.btn {
margin-top: 20px;
}
6 changes: 4 additions & 2 deletions views/cast.erb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
<p>You cast: <%= CHOICES[@vote] %></p>
<p><a href='/results'>See the results!</a></p>
<div class="container">
<h4>You Cast: <%= CHOICES[@vote] %></h4>
<button onclick="document.location='/results'" class="btn btn-success">See results</button>
</div>
24 changes: 14 additions & 10 deletions views/index.erb
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
<p>What's for dinner?</p>

<form action='cast' method='post'>
<ul>
<% CHOICES.each do |id, text| %>
<div class="container bg-secondary" id="container">
<h4>What's for dinner?</h4>
<form action='cast' method='post'>
<ul>
<% CHOICES.each do |id, text| %>
<li>

<label>
<input type='radio' name='vote' value='<%= id %>' id='vote_<%= id %>' />
<%= text %>
</label>
</li>
<% end %>
</ul>

<button type='submit' class="btn btn-primary">Cast this vote!</button>
</form>
</li>
<% end %>
</ul>
<div class="col text-center">
<button type='submit' class="btn btn-primary left">Cast this vote!</button>
</div>
</form>
</div>
31 changes: 20 additions & 11 deletions views/layout.erb
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8' />
<title>Voting App</title>
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
</head>
<body>
<h1><%= @title %></h1>
<%= yield %>
<script src="js/bootstrap.min.js"></script>
</body>
<head>
<meta charset='UTF-8' />
<title>Voting App</title>
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-secondary">
<a class="navbar-brand" href="/">Foo Resturant</a>
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="/results">Results</a>
</li>

</ul>
</nav>
<h2 class="text-center p-2"> <%= @title%> </h2>
<%= yield %>
<script src="js/bootstrap.min.js"></script>
</body>
</html>
18 changes: 14 additions & 4 deletions views/results.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
<table class='table table-hover table-striped'>
<% CHOICES.each do |id, text| %>
<table class="table table-striped table-light" id ="table">
<thead class="thead-light">
<tr>
<th scope="col">Items</th>
<th scope="col">Votes</th>
<th scope="col">Hashtags</th>
</tr>
</thead>
<tbody>
<% CHOICES.each do |id, text| %>
<tr>
<th><%= text %></th>
<td><%= @votes[id] || 0 %>
<td><%= '#' * (@votes[id] || 0) %></td>
</tr>
<% end %>
<tbody>
</table>

<p><a href='/'>Cast more votes!</a></p>
<div class="col text-center">
<button onclick="document.location='/'" class="btn btn-success">Cast more votes</button>
</div>
2 changes: 1 addition & 1 deletion votes.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
votes:
HAM: 1
NOO: 2
CUR: 1
2 changes: 1 addition & 1 deletion voting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
end

get '/results' do
@title = 'Results so far:'
@title = 'Results So Far'
@store = YAML::Store.new 'votes.yml'
@votes = @store.transaction { @store['votes'] }
erb :results
Expand Down

0 comments on commit 017d90c

Please sign in to comment.