Deployed App URL: https://assignment-4-deploy.vercel.app/ Name: Ishraq Oheen
Weight: 20%
Submission: Via GitHub Classroom (starter files provided)
Deployed App URL:
Clone this repo to your computer and then follow the specs below to complete this assignment. When you are done, submit your solution. Also be sure to put your name in the required parts of your assignment submission.
Follow these instructions to clone this repository to your computer.
- Open Visual Studio Code.
- Open the command palette and type
clone. Select theGit: Cloneoption.- Press either F1 or ctrl + shift + p to open the command palette.
- Click
Clone from GitHuband follow the prompts. - When a pop-up appears in VS Code to open the repository, open it in the current window.
Note: Unless your instructor explicitly offers different submission instructions, you are expected to follow the process outlined here.
All your work for this assignment should be done on a local copy of the assignment that exists on your computer.
To submit your work, perform the git commit and push process demonstrated by your instructor.
Do not upload your assignment submission using GitHub's file-upload feature. Your instructor may assign a mark of zero (0%) for this assignment if you upload file(s) instead of using the git commit and push process.
In this final assignment, you will build a fully functional front-end web application using custom web components. You will build a multi-page front-end application that allows users to browse and explore the Hyrule Compendium. You will deploy your application to a cloud platform such as Vercel or Netlify.
- Apply advanced JavaScript techniques to manipulate data and the DOM.
- Implement meaningful user interactions using event handling and dynamic DOM updates.
- Integrate a provided API backend to exchange data.
- Design and implement reusable web components with encapsulated styling and state management.
A multi-page front-end application that includes:
- Reusable, modular custom web components.
- Dynamic content updates based on API data.
- Encapsulated styling using Shadow DOM and CSS custom properties.
- Internal state management within components.
- API Integration with the Hyrule Compendium API.
- Deployment to a cloud platform.
- You must create and use the following custom elements:
<entry-card>– Self-contained component that displays summary and expandable detail view of an entry.<app-button>– Reusable, customizable button component used throughout the application.<app-header>– Simple navigation header for page layout and branding.
- Implement key UI sections using the three custom components listed above. Use slots, attributes, or properties to ensure reusability and configuration flexibility where appropriate or directed.
The required styling and markup required for the component are as follows:
nav {
background-color: #222;
color: #fff;
padding: 1rem;
display: flex;
align-items: center;
justify-content: space-between;
}
a {
color: #fff;
text-decoration: none;
font-weight: bold;
}
a:hover {
text-decoration: underline;
} <nav>
<a href="index.html">Home Text</a>
</nav>- Create the
app-header.jsfile for the app-header component in thejs/components/directory. - Create an
AppHeaderclass for the custom component. - Build a template for the component.
- Make use of a
slotwith the namehome-textso the link text (i.e., "Home Text") can be dynamically assigned.
- Make use of a
- Ensure that the styles are scoped within the component.
- Utilize the appropriate lifecycle method to render the component.
- Register the component for use in the DOM.
The required styling and markup required for the component are as follows:
a, button {
display: inline-block;
padding: 0.5rem 1rem;
border: none;
border-radius: 4px;
background-color: #eee;
color: #000;
cursor: pointer;
font-size: initial;
text-decoration: none;
}
a:hover, button:hover {
background-color: #333;
color: #fff;
} <button>
Click Me
</button>- Create the
app-button.jsfile for the component in thejs/components/directory. - Create an
AppButtonclass for the custom element. - Build a template for the component.
- Make use of a
slotwith the namelabelso the button text (i.e., "Click Me") can be dynamically assigned.
- Make use of a
- Use an observed
hrefattribute to determine if the component renders as a<button>or<a>link.- If the
hrefattribute is present, replace thebuttonin the shadow DOM with anatag.
- If the
- Ensure styles are scoped within the component. This step will require some planning.
- Utilize the appropriate lifecycle method to render the component, and also render on observed attribute changes (i.e.,
href). - Utilize CSS vars for custom styling the following:
--app-button-bgfor thea, buttonbackground colour with default#eee--app-button-colorfor thea, buttoncolour with default#000--app-button-bg-hoverfor thea:hover, button:hoverbackground colour with default#333--app-button-color-hoverfor thea:hover, button:hovercolour with default#fff
- Register the component for use in the DOM.
The required styling and markup required for the component are as follows:
.card {
border: 1px solid #ccc;
padding: 1rem;
margin: 0.5rem 0;
border-radius: 4px;
background-color: #fff;
}
.card img {
max-width: 200px;
display: block;
margin-bottom: 0.5rem;
}
.extra {
display: block;
}
.extra.extra-hidden {
display: none;
}
button {
margin-top: 0.5rem;
}<div class="card">
<h3>NAME</h3>
<img src="IMAGE_URL" alt="IMAGE_ALT">
<p><strong>Category:</strong> CATEGORY</p>
<!-- Use an app-button here with id="toggle-btn" and label slot "Toggle Details" -->
<div id="details" class="extra extra-hidden">
<p><strong>Description:</strong> DESCRIPTION</p>
<p><strong>Common Locations:</strong> LOCATIONS</p>
<p><strong>Drops:</strong> DROPS</p>
</div>
</div>- Create the
entry-card.jsfile for the component in thejs/components/directory. - Include the required
app-buttoncomponent. - Create an
EntryCardclass for the custom element. - Build a template for the component.
- Make use of
slots for all output values:- Slot named
namefor "NAME" - Slot named
imagefor "IMAGE" - Slot named
categoryfor "CATEGORY" - Slot named
descriptionfor "DESCRIPTION" - Slot named
locationsfor "LOCATIONS" - Slot named
dropsfor "DROPS"
- Slot named
- Make use of
- Assign slot values dynamically based on incoming
entrydata.- You will need to replace the
imageslot child with animgelement.
- You will need to replace the
- You cannot render an
<entry-card>without setting it's data- Throw an
Errorwith the message "No data has been set".
- Throw an
- Use internal private Boolean state
#expanded(withexpandedproperty get and set) to toggle the visibility of additional information insidediv#detailsof the card.- Use the
<app-button>component to trigger the toggle behavior (add an event listener). - Setting the
expandedproperty will have the effect of either adding or removing theextra-hiddenclass from thediv#detailselement.
- Use the
- Use internal state to hold the data for the entry (i.e., the returned entry data from the API).
- Include an internal private object state
#data(withdataproperty get and set) that, when set, assigns the incoming data value to the internal#datastate. Be sure to render the component when the data is set.
- Include an internal private object state
- Ensure styles are scoped within the component.
- Utilize the appropriate lifecycle method to render the component.
- Register the component for use in the DOM.
Display app-buttons for each category (Creatures, Monsters, Materials, Equipment, Treasure). You may use a hard-coded array of categories to programatically add them to the page in main.js.
- Include an
app-headercomponent in the required location (see the existing comment)- Use the slot to update the home text to: "Hyrule Compendium".
- Render
app-buttons for each category (Creatures, Monsters, Materials, Equipment, Treasure) in thesection#category-buttonselement. Eachapp-buttonmust have a uniqe label (the category name) andhrefattribute linking to the category page.- Use the following href format for each category:
category.html?category=<CATEGORY>where<CATEGORY>should be replaced with the unique category value. - Use any means available to you to include the components on the page.
- OPTION 1: Manually enter the components into
index.html - OPTION 2: You may use a hard-coded array of categories and programatically add them to the page from
main.js.
- OPTION 1: Manually enter the components into
- Use the following href format for each category:
- Ensure the required custom components are included for use.
- If you have chosen to programatically render all app-buttons to the page, do so here.
The page should now render the app-header with appropriate text, and the five app-buttons with functional navigation.
- Include an
app-headercomponent in the required location (see the existing comment)- Use the slot to update the home text to: "Hyrule Compendium".
- Ensure the required custom components are included for use.
Test your entry-card component by rendering one with hard-coded data in the section#entries-list element.
Use the Hyrule Compendium API:
GET /category/{category}– Fetch entries by category
The category.js file is responsible for dynamically loading the correct entries for the selected category and rendering them on the page using your <entry-card> component.
Follow these steps to complete this file:
-
Get Selected Category
- Extract the selected category from the query string in the URL.
- Use the URLSearchParams API to retrieve the category from the URL.
-
Fetch Entries by Category
- Use the fetch API to retrieve the entry data.
-
Render
<entry-card>Components- For each entry returned from the API:
- Create a new
<entry-card>element. - Assign the
entrydata property. - Append the element to the container.
- Create a new
- For each entry returned from the API:
-
Test Your Work
- Ensure that when you visit
category.html?category=monstersor another category, the corresponding entries appear and display correctly inside your<entry-card>components.
- Ensure that when you visit
- Deploy your completed front-end application to Vercel, Netlify, or another platform.
- Ensure that the deployed application mirrors your local development version.
- Update this README file with the URL of your deployed app for grading (See the placeholder at the top of the file).
NOTE: CSS vars have been applied to alter the colors in the sample run
You will receive a GitHub Classroom repository that includes:
src/– Starter files for the frontend application.src/css/styles.css– Global styles for the application.src/js/main.js– Starter for initializing the home page.src/js/category.js– Starter for initializing the category page.src/js/components/– Folder for custom web components.README.md– Assignment overview and instructions.
Your repository also includes GitHub Actions to automatically run tests on your code and provide feedback.
NOTE: You must demonstrate incremental development of your solution. This means that you must begin work on your solution as soon as possible and commit often to the assignment repository. Each commit must demonstrate functional improvements to the solution. If you submit code that differs greatly from what was demonstrated in class, it must be documented (e.g. comments) and you may be asked to provide a verbal explanation of how the code works to your instructor. Failure to show incremental work during the assignment period, or failure to document techniques used that were not shown in class, will result in loss of marks of up to 20%.
| Criteria | Marks | Description |
|---|---|---|
| Web Component Architecture | 6 | Components are modular, functional, and reusable across the application. |
| Styling & Shadow DOM | 4 | Encapsulated styles and CSS custom properties are implemented effectively. |
| State Management & Dynamic Behavior | 4 | Components track internal state (e.g., expanded/collapsed detail views) and update the UI dynamically based on user interactions. |
| API Integration | 2 | Application fetches data from the required API and renders it dynamically. |
| Deployment | 2 | Application is successfully deployed to a public hosting platform (e.g., Netlify, Vercel). |
| Code Quality | 2 | Code is modular, well-commented, consistently formatted, and easy to follow. Naming conventions and structure support maintainability. |
- Plan your component structure early and keep it modular.
- Test your data integration with the provided API before deployment.
- Document your custom elements and any reusable logic.
- Comment your code and commit your progress frequently.
- Validate your final deployed app for full functionality.
- Complete your project in your GitHub Classroom repository.
- Push commits regularly with clear messages during development to track progress.
- Submit your deployed application URL in the repository
README.md. - GitHub Actions will run tests to evaluate your solution.
- Your instructor will assess the repository and deployment.
