← Back to gallery
Army Of One poster

Project walkthrough

Army Of One

Explore the concept, hints, and starter code for this Nic Cage inspired build.

Title: Mission Impossible with Army of One and Web Components

Description:

Inspired by Nicolas Cage’s humorous and determined role in Army of One, this project uses Web Components to create a modular and reusable web application. The application allows users to experience a series of interactive missions, each represented by a custom web component. The design and functionality reflect the quirky and singular mission of Cage’s character, Gary Faulkner, providing a unique and engaging user experience.

Features:

  • Custom Web Components: Create reusable and modular web components for different missions.
  • Interactive Missions: Allow users to engage with and complete missions using the custom components.
  • Thematic Design: Reflect the humor and determination of Army of One through the application’s design and interactions.

Starting Code:

Beginner Hints:

  • Create a single index.html file.
  • Copy the full HTML code block into that file.
  • Open index.html in your browser. If something doesn’t work, try a local server like python -m http.server.
  • Open DevTools Console to spot errors and typos quickly.
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Mission Impossible with Army of One and Web Components</title>
<style>
    body {
        font-family: Arial, sans-serif;
        background-color: #f0f0f0;
        color: #333;
        text-align: center;
        padding: 50px;
    }
    .container {
        max-width: 800px;
        margin: 0 auto;
        padding: 20px;
        background-color: #fff;
        border: 1px solid #ccc;
        border-radius: 10px;
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    }
    h1 {
        margin-bottom: 20px;
    }
    .mission {
        margin: 20px 0;
        padding: 10px;
        background-color: #f9f9f9;
        border: 1px solid #ddd;
        border-radius: 5px;
    }
    button {
        padding: 10px 20px;
        margin: 10px;
        border-radius: 5px;
        border: none;
        font-size: 16px;
        background-color: #007bff;
        color: white;
        cursor: pointer;
    }
    button:hover {
        background-color: #0056b3;
    }
</style>
</head>
<body>
    <div class="container">
        <h1>Mission Impossible</h1>
        <p>Complete the missions inspired by Army of One.</p>

        <mission-component mission-name="Find the Sword"></mission-component>
        <mission-component mission-name="Cross the Desert"></mission-component>
        <mission-component mission-name="Capture the Flag"></mission-component>
    </div>
<script>
    class MissionComponent extends HTMLElement {
        constructor() {
            super();
            this.attachShadow({ mode: 'open' });
            const wrapper = document.createElement('div');
            wrapper.setAttribute('class', 'mission');

            const title = this.getAttribute('mission-name');
            const titleElement = document.createElement('h2');
            titleElement.textContent = title;

            const button = document.createElement('button');
            button.textContent = 'Complete Mission';
            button.addEventListener('click', () => {
                alert(`${title} mission completed!`);
            });

            wrapper.appendChild(titleElement);
            wrapper.appendChild(button);
            this.shadowRoot.append(wrapper);

            const style = document.createElement('style');
            style.textContent = `
                .mission {
                    padding: 20px;
                    margin: 20px 0;
                    background-color: #f9f9f9;
                    border: 1px solid #ddd;
                    border-radius: 5px;
                    text-align: center;
                }
                h2 {
                    margin: 0 0 10px 0;
                }
                button {
                    padding: 10px 20px;
                    border-radius: 5px;
                    border: none;
                    font-size: 16px;
                    background-color: #007bff;
                    color: white;
                    cursor: pointer;
                }
                button:hover {
                    background-color: #0056b3;
                }
            `;
            this.shadowRoot.appendChild(style);
        }
    }

    customElements.define('mission-component', MissionComponent);
</script>
</body>
</html>

References:

Project Overview:

This project captures the humorous and determined atmosphere of Army of One using Web Components to create a modular and interactive web application. Users can engage with custom missions, each represented by a web component, reflecting the singular focus and quirky nature of Cage’s character. The application provides a hands-on demonstration of how Web Components can be used to create reusable and dynamic elements in web development. Embrace the unique mission and creativity of Nicolas Cage’s character to master the use of Web Components. Praise Cage!