-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve formatting of game views using bootstrap and layout file
- Loading branch information
1 parent
5bf8bf0
commit b6c4f31
Showing
4 changed files
with
39 additions
and
64 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,28 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<!-- fun exercise: make it so that the individual numbers in the squares are | ||
clickable, and each player moves by clicking the number instead of typing | ||
in a form field. | ||
--> | ||
<head> | ||
<style type="text/css"> | ||
* { font-family: sans-serif; font-size: 28pt; } | ||
body { padding: 1em; } | ||
table,td { border: 2px solid red; border-collapse: collapse; padding: 1em; } | ||
.emptySquare { color: grey; } | ||
.x { color: green; font-weight: bold; font-size: 110%; } | ||
.o { color: blue; font-weight: bold; font-size: 110%; } | ||
</style> | ||
</head> | ||
<body> | ||
<% if session[:message] %> | ||
<div class="alert alert-danger"> | ||
<%= session[:message] %> | ||
<% if session[:message] %> | ||
<div class="alert alert-danger"> | ||
<%= session[:message] %> | ||
</div> | ||
<% end %> | ||
<div id="board"> | ||
|
||
<% row = col = 0 %> | ||
<% 0.upto(2) do |row| %> | ||
<div class="row "> | ||
<% 0.upto(2) do |col| %> | ||
<div class="col-3 text-center h1 border-primary | ||
<%= 'border-bottom' if row != 2 %> | ||
<%= 'border-right' if col != 2 %>"> | ||
<% square_num = row * 3 + col %> | ||
<%= if (val = @game.board[square_num]).empty? then square_num else val end %> | ||
</div> | ||
<% end %> | ||
<div id="board"> | ||
<table> | ||
<thead></thead> | ||
<tbody> | ||
<% i = 0 %> | ||
<% 3.times do %> | ||
<tr> | ||
<% 3.times do %> | ||
<td> | ||
<% val = @game.board[i] %> | ||
<% if val.empty? %> | ||
<span class="emptySquare"> <%= i %> </span> | ||
<% else %> | ||
<span class="<%= val %>"> <%= val %> </span> | ||
<% end %> | ||
<% i += 1 %> | ||
</td> | ||
<% end %> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
<% end %> | ||
</div> | ||
|
||
<form method="post" action="/move"> | ||
<p><%= @game.turn %>'s move</p> | ||
<p>Enter square 0-8</p> | ||
<input type="text" name="square"> | ||
<input type="submit" value="Make Move"> | ||
</form> | ||
</body> | ||
</html> | ||
<form method="post" action="/move"> | ||
<p><%= @game.turn %>'s move</p> | ||
<p>Enter square 0-8</p> | ||
<input type="text" name="square"> | ||
<input type="submit" value="Make Move"> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-4bw+/aepP/YC94hEpVNVgiZdgIC5+VKNBQNGCHeKRQN+PtmoHDEXuppvnDJzQIu9" crossorigin="anonymous"> | ||
<title>Tic Tac Toe</title> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<%= yield %> | ||
</div> | ||
</body> | ||
</html> |