Giter Club home page Giter Club logo

stencil-portal's Introduction

Stencil Portal

This component is developed with StencilJS and provides a first-class option for rendering children in a DOM node that exists outside the DOM hierarchy of the parent or reference component.

A typical use case for portals is when a main component has an overflow style: hidden or z-index, but needs the element to "come out" visually from its container. For example, dialog boxes, hovercards and tooltips.

How does it work?

The component portal component requires us to pass a component reference from which it will calculate the position (see in the example the component tooltip component has a reference on the Host tab)

<Host ref={(el) => (this.tooltipRef = el)}>

In this same component we can see that there is a label <Slot />. This is used for the example, and is the place where the parent's child component will be drawn (in this case a where it will be possible to hover and show the content that is in the portal)

Example tooltip hover

When the cursor is placed over the element, the portal is positioned absolutely on top of the referenced element by default

How to run the example

  1. Install nodejs 14.5.0 from this link or using Node Version Manager.
  2. Install yarn 1.22.5 globally executing the following command:
npm install -g [email protected]
  1. Install all project dependencies from SPA root folder:
yarn
  1. Start the project in local development mode with:
yarn start

stencil-portal's People

Contributors

tomas-teston avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.