Skip to content

ranggautama47/shadowDom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›‘οΈ Shadow DOM Web Component Project

This repository demonstrates how to build a custom, encapsulated component using Shadow DOM. The main feature is a element that provides a stylish, hoverable informational tooltip while keeping its styles isolated from the rest of the application.

πŸš€ Key Features

Encapsulated Shadow DOM: Uses attachShadow({ mode: 'open' }) to ensure that component styles do not leak out and external styles do not interfere with the component.

Custom Attributes: The component accepts dynamic inputs through img and description attributes.

Interactive Tooltip: Built-in hover and focus states that reveal additional information smoothly.

Fallback Mechanism: Includes a default icon if no image URL is provided.

πŸ“Έ Preview

Component Implementation popup-info

The custom element integrated into a standard HTML form. Tooltip Interaction popup-info

The tooltip appearing when the user hovers over or focuses on the info icon.

πŸ“ Project Structure

.
β”œβ”€β”€ screenshot/             # Application visual documentation

β”‚   β”œβ”€β”€ popup-info.png      # Tooltip interaction preview

β”‚   └── shadow_dom.png      # Component structure preview

β”œβ”€β”€ src/                    

β”‚   β”œβ”€β”€ css/

β”‚   β”‚   └── style.css       # Global application styles

β”‚   β”œβ”€β”€ main.js             # Main entry point importing the component

β”‚   └── popup-info.js       # The Web Component logic (Shadow DOM)

β”œβ”€β”€ index.html              # Main HTML file using the custom element

└── README.md               # Project documentation

πŸ› οΈ Technologies Used

HTML5 & CSS3: For the structural layout and interactive animations.

Vanilla JavaScript (ES6+): Utilized for Custom Elements and Shadow DOM API.

Web Components API: Defining reusable HTMLElement classes.

βš™οΈ How to Run

Clone the Repository:
Bash

git clone https://github.com/ranggautama47/shadowDom.git

Open the Project: Open index.html directly in any modern web browser that supports Web Components.

Note on Modules: Since the project uses type="module" in the script tag, you may need to run it via a local server (like Live Server in VS Code) to avoid CORS issues.

πŸ‘€ Author

Developed by ranggautama47 as part of the Dicoding Indonesia learning path for Front-End Web Development.

About

belajar membuat shadow dom

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published