This repository provides a versatile template designed for mockup designs, with the potential for adaptation to actual implementation. If users intend to modify the template for actual implementation, it's important to note that this process will require extensive adjustments to javascript modules and stylesheets inside src
, and various other components. The template, initially intended for mockup designs, offers the flexibility for adaptation to real-world usage. Note that the styling of this page in style.css
inside src
directory is not responsive to all devices except laptops and desktops
This is my own generated website using the template: Jaizzer Restaurant
- Node.js installed on your system.
- Visual Studio Code (or any code editor of your choice) for development.
-
Clone this repository to your local machine:
git clone https://github.com/Jaizzer/restaurant.git
-
Navigate to the project directory:
cd jaizzer-restaurant
-
Install the project dependencies:
npm install
The Card
class is used to create card components throughout the website. It has the following properties:
Card(id, imagePath, heading, description, buttonCaption)
: Creates a new card instance.id
: The ID of the card element.imagePath
: The path to the card's image.heading
: The main heading of the card.description
: The card's description.buttonCaption
: The caption for the button on the card.
You can easily modify the content and appearance of cards on different sections of the website, such as the homepage, about us, and contact us pages. Here's how you can do it:
- Open the corresponding rendering file.
- To add a new card, create a new
Card
instance and add it to thecards
array. - To remove a card, locate the corresponding
Card
instance in thecards
array and remove it.
See the instructions below for specific steps for editing cards in Homepage, About Us, Contact Us, Gallery Page, and Menu Page.
- Open the
renderHome.js
file located in thesrc
directory. - Locate the section you want to modify, such as the hero section or food teaser sections.
- Edit the properties of the
Card
instances to update the text, images, and button captions.
- Open the
renderAboutUs.js
file located in thesrc
directory. - Find the corresponding section you want to modify, such as "Our Story" or "Meet the Team."
- Edit the properties of the
Card
instances to update the text and images.
- Open the
renderContactUs.js
file located in thesrc
directory. - Look for the
combinedCard
instance that represents the "Contact Us" section. - Edit the properties of the
Card
instance to update the contact information.
Note that you do not need to modify the renderGallery.js
. You only need to update the images/gallery
directory to reflect the changes. By simply dropping all your images you want to appear in the "Gallery" page.
Just like modifying the Gallery page, you do not need to modify renderMenu.js
for images, however you will need to only update it if you wish to change the food category buttons
(see Updating Menu Page Food Category Buttons). You only need to update the images/menu
directory. However, read the naming conventions first and understand how modifying the file structure and renaming the directories will require additional work. Read Naming Convention for Images and Updating Image File Structure below.
To update the food category buttons, go to renderMenu.js
and find:
// Render dish category buttons that show corresponding selections when clicked.
const foodCategories = ["classics", "desserts", "drinks", "ramen", "rolls", "sushiAndSashimi", "salad"];
foodCategories.forEach(foodCategory => {
// Create button.
let button = document.createElement("button");
// Add a special case for 'sushiAndSashimi'.
button.textContent = (foodCategory === "sushiAndSashimi") ? "sushi and sashimi" : `${foodCategory}`;
// Load corresponding dishes based on type/category when clicked.
button.addEventListener("click", () => showSelection(`${foodCategory}`));
// Append the button to the container.
buttonContainer.appendChild(button);
});
Then modify const foodCategories = ["classics", "desserts", "drinks", "ramen", "rolls", "sushiAndSashimi", "salad"];
base on the changes you like. Note that they should matched the directories you will use for the menu. Lastly see this:
// Add special case for 'sushiAndSashimi'.
button.textContent = (foodCategory === "sushiAndSashimi") ? "sushi and sashimi" : `${foodCategory}`;
This code is just a way to make the button caption a spaced separated value.
Open the images
directory in src
to see how the images are stored. Images for the menu follow the naming convention: dishName_price.extension
. For example, sushi_12.56.jpg
(using whitespaces in the dish name like spicy sushi_12.56.jpg
would work).
When you modify the image file structure, it's important to ensure that the require.context
function inside the handleImages.js
module is updated accordingly. The require.context
function allows you to dynamically import multiple files from a directory based on a specified pattern. This is crucial for loading images dynamically in your application.
Here's how you can update the require.context
calls:
-
Open the
handleImages.js
file: This file is responsible for handling the dynamic import of images based on the file structure. -
Locate the
images
object: Inside thehandleImages.js
file, you'll find animages
object that contains different properties representing different image categories or directories. Each property has arequire.context
function that specifies the directory path and a regular expression pattern to match the image files. -
Update the directory path: If you modify the directory structure where your images are stored, you'll need to update the directory path in the
require.context
function. The first argument of the function is the directory path, and the second argument is the flag to indicate if subdirectories should be searched.For example, if you had images stored in
src/images/new-directory
, you would update therequire.context
function like this:const newDirectoryImages = require.context('./images/new-directory', false, /\.(png|jpg|jpeg|gif)$/);
-
Add new properties for new directories: If you're adding new directories for images, you need to create new properties in the images object. Each property should have its own require.context function that corresponds to the location of the new directory.
const newDirectoryImages = require.context('./images/new-directory', false, /\.(png|jpg|jpeg|gif)$/); const images = { gallery: galleryImages, menu: menuImages, newDirectory: newDirectoryImages, // Add this line for the new directory };
By updating the require.context calls in the handleImages.js file, you ensure that your application can still dynamically import images from the correct directories, even if you've restructured or added new image directories.
Remember that the regular expression pattern in the require.context function specifies the file types to be matched (e.g., png, jpg, jpeg, gif). Make sure to include all the file extensions that your images use.
To Update HTML page title, just go to index-template.html
located in src
directory and find <title>Restaurant</title>
and replace Restaurant
with the new title.
To preview the website in your browser:
-
Run the development server:
npm start
-
Open your browser and navigate to http://localhost:8080/.
Feel free to customize the content, images, and styles to match your restaurant's branding. If you have any questions or need further assistance, please don't hesitate to reach out. Enjoy creating your restaurant's website!
We welcome contributions to enhance and improve this template. If you have ideas or suggestions, feel free to create pull requests.
If you encounter any issues or bugs while using this template, please report them to us at florenzjaizzer.calderon@gmail.com.
This template is available under the MIT License.