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

@miraidesigns/sidebar

v1.0.2

Published

Mirai Designs Framework: Sidebar module

Downloads

4

Readme

Sidebars

Sidebars provide site navigation and can be permanent or called on-screen.


HTML

Make sure to put this as high in your <body> element as possible.

<div class="mdf-sidebar-container" aria-hidden="true">
    <aside class="mdf-sidebar mdf-sidebar--left" aria-labelledby="sidebar-title">
        <header class="mdf-sidebar__header">
            <h2 id="sidebar-title" class="mdf-sidebar__title">Sidebar</h2>

            <button class="mdf-sidebar__close" aria-label="Close sidebar">
                <svg class="mdf-icon" viewBox="0 0 24 24" aria-hidden="true">
                    <use href="icons.svg#clear"></use>
                </svg>
            </button>
        </header>

        <div class="mdf-sidebar__content">
            <nav role="navigation" aria-label="Site navigation">
                <a class="mdf-sidebar__link" href="#1">
                    Link #1
                </a>

                <a class="mdf-sidebar__link" href="#2">
                    Link #2
                </a>

                <a class="mdf-sidebar__link" href="#3">
                    Link #3
                </a>
            </nav>
        </div>

        <footer class="mdf-sidebar__footer">
            <p>Sidebar footer text</p>
        </footer>
    </aside>

    <div class="mdf-sidebar-backdrop"></div>
</div>

Sass

// Include default styles without configuration
@forward '@miraidesigns/sidebar/styles';
// Configure appearance
@use '@miraidesigns/sidebar' with (
    $variable: value
);

@include sidebar.styles();

TypeScript

import { MDFSidebar } from '@miraidesigns/sidebar';

new MDFSidebar(document.querySelector('.mdf-sidebar'), {
    anchor: document.getElementById('sidebar-anchor')
});

Implementation

Classes

| Name | Type | Description | | -------------------------------- | -------------- | -------------------------------------------------------------------------------- | | mdf-sidebar-container | Parent | Contains the sidebar and backdrop. Used for off-screen sidebars | | mdf-sidebar-container--active | Modifier | 1. Prepares the sidebar to be visible. Used for off-screen sidebars | | mdf-sidebar-container--move-in | Modifier | 2. Fades-in the sidebar and allows for interaction. Used for off-screen sidebars | | mdf-sidebar | Parent | Contains the header, content and footer | | mdf-sidebar--left | Modifier | Moves the sidebar to the left of the screen. Used for off-screen sidebars | | mdf-sidebar--right | Modifier | Moves the sidebar to the right of the screen. Used for off-screen sidebars | | mdf-sidebar__header | Parent / Child | Contains the title and close button. Child to .mdf-sidebar | | mdf-sidebar__title | Child | Title element. Child to .mdf-sidebar__header | | mdf-sidebar__close | Child | Closes the sidebar. Child to .mdf-sidebar__header | | mdf-sidebar__content | Parent / Child | Contains the navigation links or other content. Child to .mdf-sidebar | | mdf-sidebar__link | Child | Navigation link element. Child to .mdf-sidebar__content | | mdf-sidebar__footer | Parent / Child | Footer element. Child to .mdf-sidebar | | mdf-sidebar-backdrop | Child | Sidebar backdrop. Child to .mdf-sidebar-container |

Events

| Name | Data | Description | | ------------------- | ------ | ----------------------------- | | MDFSidebar:opened | null | Fires when the sidebar opens | | MDFSidebar:closed | null | Fires when the sidebar closes |

Properties

| Name | Type | Description | | ------------------------- | ----------------- | --------------------------------------------------------- | | .anchor | HTMLElement | Returns the anchor element | | .container | HTMLElement | Returns the sidebar container element | | .content | HTMLElement | Returns the sidebar main content element | | .sidebar | HTMLElement | Returns the sidebar element | | .isActive() | (): boolean | Returns wether or not the sidebar is active | | .openSidebar(setFocus?) | (boolean): void | Open the sidebar (optionally set focus on the first item) | | .closeSidebar() | (): void | Close the sidebar |

Options

| Name | Type | Default | Description | | ------------- | ------------ | ------- | ---------------------------------------------------------- | | anchor | Element | null | The anchor element that will call the sidebar | | onOpen | () => void | null | Function will run when the sidebar is opened | | onClose | () => void | null | Function will run when the sidebar is closed | | hideOnClick | boolean | true | Close the sidebar when a click is registered outside of it |