Skip to content

Commit 1be9efe

Browse files
NguyenThanhHaNguyenThanhHa
authored andcommitted
chapter_3_4_5
1 parent 12182eb commit 1be9efe

File tree

7,411 files changed

+1248803
-10
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

7,411 files changed

+1248803
-10
lines changed

Gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,6 @@ group :test do
7373
gem "selenium-webdriver"
7474
gem "webdrivers"
7575
end
76+
77+
gem 'sassc-rails'
78+

Gemfile.lock

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ GEM
9090
irb (>= 1.5.0)
9191
reline (>= 0.3.1)
9292
erubi (1.12.0)
93+
ffi (1.17.1-x86_64-linux-gnu)
9394
globalid (1.1.0)
9495
activesupport (>= 5.0)
9596
i18n (1.14.1)
@@ -199,6 +200,14 @@ GEM
199200
rubocop (>= 1.7.0, < 2.0)
200201
ruby-progressbar (1.13.0)
201202
rubyzip (2.3.2)
203+
sassc (2.4.0)
204+
ffi (~> 1.9)
205+
sassc-rails (2.1.2)
206+
railties (>= 4.0.0)
207+
sassc (>= 2.0)
208+
sprockets (> 3.0)
209+
sprockets-rails
210+
tilt
202211
selenium-webdriver (4.10.0)
203212
rexml (~> 3.2, >= 3.2.5)
204213
rubyzip (>= 1.2.2, < 3.0)
@@ -213,6 +222,7 @@ GEM
213222
stimulus-rails (1.2.2)
214223
railties (>= 6.0.0)
215224
thor (1.2.2)
225+
tilt (2.6.0)
216226
timeout (0.4.0)
217227
turbo-rails (1.4.0)
218228
actionpack (>= 6.0.0)
@@ -253,6 +263,7 @@ DEPENDENCIES
253263
rubocop (~> 1.26)
254264
rubocop-checkstyle_formatter
255265
rubocop-rails (~> 2.14.0)
266+
sassc-rails
256267
selenium-webdriver
257268
sprockets-rails
258269
stimulus-rails
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
@import "bootstrap/scss/bootstrap";
2+
3+
.navbar-brand {
4+
text-transform: uppercase;
5+
letter-spacing: 0.1em;
6+
font-weight: bold;
7+
}
8+
9+
/* Tăng kích cỡ chữ cho h1 */
10+
h1 {
11+
font-size: 2.5rem;
12+
}
13+
14+
@import "custom";

app/assets/stylesheets/custom.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// app/assets/stylesheets/custom.scss
2+
body {
3+
background-color: #f8f9fa;
4+
}
5+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class PagesController < ApplicationController
2+
def home
3+
end
4+
5+
def help
6+
end
7+
8+
def contact
9+
end
10+
end

app/helpers/pages_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module PagesHelper
2+
end

app/javascript/application.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
2-
import "@hotwired/turbo-rails"
3-
import "controllers"
1+
2+
import "bootstrap";
3+
import "bootstrap/dist/css/bootstrap.min.css";
4+
import "popper.js";
5+
Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,50 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<title>RailsTutorial</title>
5-
<meta name="viewport" content="width=device-width,initial-scale=1">
4+
<title><%= yield(:title) || "Sample App" %></title>
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
66
<%= csrf_meta_tags %>
77
<%= csp_meta_tag %>
88

9+
<!-- Gọi file CSS (đã bundle) -->
910
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
10-
<%= javascript_importmap_tags %>
11+
<!-- Gọi file JS (đã bundle) -->
12+
<%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %>
13+
14+
<!-- Bootstrap CDN -->
15+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
16+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
1117
</head>
1218

1319
<body>
14-
<%= yield %>
20+
<!-- Navbar Bootstrap 5 -->
21+
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
22+
<div class="container-fluid">
23+
<%= link_to "SAMPLE APP", root_path, class: "navbar-brand" %>
24+
25+
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent">
26+
<span class="navbar-toggler-icon"></span>
27+
</button>
28+
29+
<div class="collapse navbar-collapse" id="navbarSupportedContent">
30+
<ul class="navbar-nav ms-auto mb-2 mb-lg-0">
31+
<li class="nav-item">
32+
<%= link_to "Home", root_path, class: "nav-link" %>
33+
</li>
34+
<li class="nav-item">
35+
<%= link_to "Help", pages_help_path, class: "nav-link" %>
36+
</li>
37+
<li class="nav-item">
38+
<%= link_to "Log in", "#", class: "nav-link" %>
39+
</li>
40+
</ul>
41+
</div>
42+
</div>
43+
</nav>
44+
45+
<!-- Phần nội dung của từng trang con -->
46+
<div class="container mt-4">
47+
<%= yield %>
48+
</div>
1549
</body>
1650
</html>

app/views/pages/help.html.erb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<h1>Pages#help</h1>
2+
<p>Find me in app/views/pages/help.html.erb</p>

app/views/pages/home.html.erb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<% provide(:title, "Home") %>
2+
3+
<!-- Phần nền xám nhạt + căn giữa -->
4+
<div class="bg-light w-100 py-5">
5+
<div class="text-center">
6+
<h1 class="display-4 fw-bold">Welcome to the Sample App</h1>
7+
<p>
8+
This is the home page for the
9+
<a href="https://www.railstutorial.org/">Ruby on Rails Tutorial</a>
10+
sample application.
11+
</p>
12+
<%= link_to "Sign up now!", "#", class: "btn btn-primary btn-lg" %>
13+
</div>
14+
</div>

0 commit comments

Comments
 (0)