npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@evanminto/full-screen-element

v0.5.0

Published

Simple custom elements for triggering fullscreen mode in supported browsers.

Downloads

11

Readme

<full-screen> and <full-screen-toggle> Elements

Simple custom elements for triggering fullscreen mode in supported browsers.

Getting Started

Installing

npm install @evanminto/full-screen-element --save

or

yarn add @evanminto/full-screen-element

Alternatively, download the bundled browser-ready file at dist/index.js.

Importing

Load the file via ES imports or a script tag:

import '@evanminto/full-screen-element`;

or

<script src="/path/to/full-screen-element/index.js"></script>

This will automatically register the custom elements with the names full-screen and full-screen-toggle.

How to Use

Simple default usage:

<full-screen>
  <p>Fullscreenable content</p>
  <full-screen-toggle></full-screen-toggle>
</full-screen>

Customizing HTML & CSS

By default the toggle button is rendered inside <full-screen-toggle>'s Shadow DOM. You can style the button via the element’s CSS parts:

<full-screen-toggle></full-screen-toggle>

<style>
  full-screen-toggle::part(toggle) {
    background-color: white;
    color: red;
  }

  full-screen-toggle[active]::part(toggle) {
    background-color: red;
    color: white;
  }
</style>

Or if you need more control you can provide a button in the Light DOM, which overrides this behavior and allows you to use your own markup and styles:

<full-screen-toggle>
  <button type="button">Toggle Fullscreen</button>
</full-screen-toggle>

<style>
  full-screen-toggle button {
    background-color: white;
    color: red;
  }

  full-screen-toggle[active] button {
    background-color: red;
    color: white;
  }
</style>

Customizing Behavior

Behavior Attribute

By default the first <button> child of <full-screen-toggle> will be treated as a toggle button, so clicking it will turn fullscreen on and off.

To select a different button, attach the data-behavior="toggle" attribute:

<full-screen-toggle>
  <button type="button">Does nothing</button>
  <button type="button" data-behavior="toggle">Toggle Fullscreen</button>
</full-screen-toggle>

If instead of a single toggle you’d like two separate buttons, one for entering and one for exiting fullscreen, you can assign the data-behavior="enter" and data-behavior="exit" attributes:

<full-screen-toggle>
  <button type="button" data-behavior="enter">Enter Fullscreen</button>
  <button type="button" data-behavior="exit">Exit Fullscreen</button>
</full-screen-toggle>

CAUTION: While you can assign the data-behavior attribute to any element you want, using an element other than <button> can introduce semantic and accessibility issues. In almost all cases you should use <button> for triggering fullscreen.

Methods on <full-screen>

toggle()

Toggles fullscreen on or off for the target element.

NOTE: This will fail unless called in the context of a user action

Attributes on <full-screen-toggle>

active

Boolean. Will be present if fullscreen is currently active.

supported

Boolean. Will be present if fullscreen is supported in the current browser.

Properties on <full-screen-toggle>

active

Read-only. Mirrors the state of the active attribute.

supported

Read-only. Mirrors the state of the supported attribute.

Events

full-screen-toggle

Fired by <full-screen-toggle>.

Built-in Events

<full-screen> has no custom events, but you can listen for the built-in fullscreen events, fullscreenchange and fullscreenerror.