Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/dtriana18/NFT-card-web-component

NFT gallery created using Web components Inspired by the "NFT preview card component" challenge on Frontend Mentors.
https://github.com/dtriana18/NFT-card-web-component

frontend-mentor-challenge html-css-javascript nft-gallery web-components

Last synced: 2 months ago
JSON representation

NFT gallery created using Web components Inspired by the "NFT preview card component" challenge on Frontend Mentors.

Awesome Lists containing this project

README

        

# NFT CARD WEB COMPONENT GALLERY

This project is a mini-gallery of fake NFT collections where you can show and hide the NFTs with a toggle switch. I created the cards and the toggle switch as reusable [Web Components](https://developer.mozilla.org/en-US/docs/Web/Web_Components) for putting into practice what I've learned.


PREVIEW AND DEPLOYMENT

[Go to Live Site!](https://nft-card-web-component.netlify.app/)

![If the gift doesn't appear, please reload the page](https://res.cloudinary.com/docbyxdd1/image/upload/r_12/e_loop/v1671423118/projects/Github/NFT-card-web-component-gallery/nft-card-blur.webp)


BUILT WITH

- HTML
- CSS
- Vanilla JavaScript
- Web Component APIs
- Vite


WORK FLOW

I started with a mobile-first approach, completing the HTML structure and styles for both of the components. Then I used the Web Components APIs to create my custom elements (tags) and set their attributes and CSS custom properties to make them highly customizable. After that, I added the show/hide functionality and finally started to optimize the page for deployment.


FEATURES

- Responsive Design

Highly optimized

####

![If the gift doesn't appear, please reload the page](https://res.cloudinary.com/docbyxdd1/image/upload/v1671438099/r_12/e_loop/projects/Github/NFT-card-web-component-gallery/speed-insights_njjm9n.webp)

toggle-button

####

You could add a new toggle switch by adding the custom tag ``.

```html

```

The default view is this, then you could tweak it with specific CSS custom properties and HTML attributes.

![Toogle switch](https://res.cloudinary.com/docbyxdd1/image/upload/r_12/v1671426351/projects/Github/NFT-card-web-component-gallery/default-toggle-button_kqd2vn.webp)
![Toggle switch active](https://res.cloudinary.com/docbyxdd1/image/upload/r_12/v1671427372/projects/Github/NFT-card-web-component-gallery/default-active_c9jyk1.webp)

For having something like this, the code would be

![Toogle switch cutomized](https://res.cloudinary.com/docbyxdd1/image/upload/r_12/v1671427118/projects/Github/NFT-card-web-component-gallery/custom-toggle-button_e6vzaz.webp)
![Toggle switch cutomized active](https://res.cloudinary.com/docbyxdd1/image/upload/r_12/v1671427118/projects/Github/NFT-card-web-component-gallery/custom-toggle-button-active_baohgl.webp)

```html

```

```css
.toggle-btn {
--bar-width: 70px;
--bar-height: 32px;
--circle-dimensions: 20px;
--circle-left-margin-adjustment: 10px;
--translate-x-adjustment: 32px;
--bar-bg: #14263d;
--bar-bg-checked: white;
--circle-bg: white;
--circle-bg-checked: black;
}
```

Also, it has a custom-checked attribute with its respective getter and setter methods. That way, it can actually be useful and used for interactivity.
Here is what happens in the browser when the toggle switch is clicked "On" and "Off".

![If the gift doesn't appear, please reload the page](https://res.cloudinary.com/docbyxdd1/image/upload/r_12/e_loop/v1671432081/projects/Github/NFT-card-web-component-gallery/cheked-gif_uluvdc.webp)

nft-card

####

The nft-card component is not as customizable as the toggle switch component, but you can modify its content with the following HTML attributes

```html

```

For having something like this, you'll just need the following code

![Astronaut card](https://res.cloudinary.com/docbyxdd1/image/upload/r_12/v1671433446/projects/Github/NFT-card-web-component-gallery/astronaut-screen_cizcej.webp)

```html

```