Week 12 Styling Rails with Bootstrap - Code-the-Dream-School/rails-guidebook GitHub Wiki
Week | Topic | Learning Objectives | Key Resources |
---|---|---|---|
12 | Styling Rails with Bootstrap |
|
Lesson Materials Coding Assignment |
In this lesson, students will style their Ruby on Rails application using Bootstrap and Font Awesome. They will also implement responsive design and interactive elements such as navigation bars, cards, alerts, and modal windows.
- Bootstrap Installation and Configuration: Students will install and configure Bootstrap in their Rails application and verify the changes.
- Styling Elements: Students will use Bootstrap classes to style backgrounds, banners, navigation bars, links, buttons, and tables.
- Responsive Design: Students will create a responsive grid of cards for displaying orders.
- Alert Styling: Students will integrate Bootstrap alert divs for flash messages.
- Font Awesome Integration: Students will add Font Awesome glyphs to their application.
- Modal Windows: Students will optionally implement modal windows for delete confirmations.
-
Install and Configure Bootstrap:
- Run
bin/bundle add bootstrap
- Update
Gemfile
and runbundle install
- Rename
application.css
toapplication.scss
and add@import "bootstrap";
- Update
app/javascript/application.js
andconfig/importmap.rb
- Edit
config/initializers/assets.rb
- Restart the server and verify Bootstrap is active
- Run
-
Change Background Color:
- Add light color background in
application.scss
- Wrap the yield statement in a
container-fluid
div inapplication.html.erb
- Verify color change in the browser
- Add light color background in
-
Add a Banner:
- Create a banner with title and text using Bootstrap’s jumbotron equivalent
- Verify the banner is displayed correctly
-
Add an Image to the Banner:
- Store an image in
app/assets/images
- Update
application.scss
to set the image as the background for the banner - Verify the image appears in the banner
- Store an image in
-
Add and Apply a Font:
- Create a
fonts
directory and add a font file - Update
config/application.rb
andapplication.scss
to include the font - Verify the font is applied to the banner
- Create a
-
Add a Navigation Bar:
- Create a navigation bar with dropdown menus for Customers and Orders
- Verify the navigation bar and dropdowns work correctly
-
Style Links, Buttons, and Tables:
- Apply Bootstrap classes to links and buttons in the Customers index view
- Optionally style other links and buttons
- Style tables using Bootstrap classes
- Verify the styles are applied correctly
-
Display Orders as Cards in a Grid:
- Create a responsive grid of cards for Orders
- Ensure cards stack responsively and include necessary information and buttons
- Verify the cards display correctly and buttons are functional
-
Style Alerts:
- Replace existing alert styling with Bootstrap danger and success alerts
- Add alert divs to the layout and test with flash messages
-
Add Font Awesome Glyphs:
- Install Font Awesome and add glyphs to the application
- Verify glyphs are displayed correctly
-
Implement Modal Windows (Optional):
- Optionally implement modal windows for delete confirmations
- Ensure modals function as expected and integrate with delete actions
-
Get Creative (Optional):
- Apply additional Bootstrap features or styling to enhance the application
- Ensure all changes are visually appealing and functional
-
Submit Work:
- Follow the submission process for the
lesson11
branch
- Follow the submission process for the