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/range

v1.0.6

Published

Mirai Designs Framework: Range module

Downloads

4

Readme

Range Sliders

Range sliders allow users to pick between a minimum and maximum value.


HTML

It is very important to set the input's min, max and step attribute for this module to work properly.
Otherwise when executed the script will set the values below by default.

<div class="mdf-range">
    <input class="mdf-range__input" type="range" min="0" max="100" step="10" aria-label="Slider">
</div>

Sass

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

@include range.styles();

TypeScript

import { MDFRange } from '@miraidesigns/range';

new MDFRange(document.querySelector('.mdf-range'));

Examples

Some basic examples on how the module can be used.

Label

Lead the slider with a label.

<div class="mdf-range">
    <div id="slider-label" class="mdf-range__leading">
        Label
    </div>

    <div class="mdf-range__track">
        <input class="mdf-range__input" type="range" min="0" max="100" step="10" aria-labelledby="slider-label">
    </div>
</div>

Icons

Icons can be leading and trailing, here demonstrated as a volume slider.

<div class="mdf-range">
    <div class="mdf-range__leading">
        <svg class="mdf-icon" viewBox="0 0 24 24" aria-hidden="true">
            <use href="icons.svg#volume-mute"></use>
        </svg>
    </div>

    <div class="mdf-range__track">
        <input class="mdf-range__input" type="range" min="0" max="100" step="10" aria-label="Volume slider">
    </div>

    <div class="mdf-range__trailing">
        <svg class="mdf-icon" viewBox="0 0 24 24" aria-hidden="true">
            <use href="icons.svg#volume-up"></use>
        </svg>
    </div>
</div>

Value

Shows the current value trailing the slider.

<div class="mdf-range">
    <div class="mdf-range__track">
        <input class="mdf-range__input" type="range" min="0" max="100" step="10" aria-label="Slider">
    </div>

    <div class="mdf-range__trailing"></div>
</div>
new MDFRange(document.querySelector('.mdf-range'), {
	value: true,
});

Editable

Allows for the editing of the displayed value with an immediate response from the slider.

<div class="mdf-range mdf-range--editable">
    <div id="slider-label" class="mdf-range__leading">
        Editable slider
    </div>

    <div class="mdf-range__track">
        <input class="mdf-range__input" type="range" min="0" max="100" step="10" aria-labelledby="slider-label">
    </div>

    <div class="mdf-range__trailing">
        <input class="mdf-range__value" type="number" aria-label="Slider value">
    </div>
</div>
new MDFRange(document.querySelector('.mdf-range'), {
	editable: true,
});

Ticks

Ticks visualize the slider snapping points.
You may display numbers underneath the ticks as well.\

// Without numbers
new MDFRange(document.querySelector('.mdf-range'), {
    ticks: true,
});

// With numbers
new MDFRange(document.querySelector('.mdf-range'), {
    ticks: true,
    numbers: true,
});

Implementation

Classes

| Name | Type | Description | | --------------------- | ---------------- | ---------------------------------------------------------------------------------------------------------- | | mdf-range | Parent | Range container element | | mdf-range--disabled | Modifier | Fades out the element and disabled all interaction | | mdf-range--editable | Modifier | Setup the range slider for the editable value input | | mdf-range__track | Parent / Child | Range track, holds the input and ticks elements. Child to .mdf-range | | mdf-range__input | Child | Range slider input element. Child to .mdf-range__track | | mdf-range__leading | Child | The leading element. Can be used for icons or as a label. Child to .mdf-range | | mdf-range__trailing | Parent / Child | The trailing element. Can be used for icons or show the current value. Child to .mdf-range | | mdf-range__ticks | Parent / Child | Container element holding the ticks. Created through JavaScript. Child to .mdf-range__trailing | | mdf-range__tick | Child | Single tick element. Created through JavaScript. Child to .mdf-range__ticks | | mdf-range__value | Child | Value input element. Offers another way to change the current range value. Child to .mdf-range__trailing |

Properties

| Name | Type | Description | | ------------- | ------------------ | ---------------------------------------- | | .input | HTMLInputElement | Returns the input element | | .leading | HTMLElement | Returns the leading element | | .track | HTMLElement | Returns the track element | | .trailing | HTMLElement | Returns the trailing element | | .valueInput | HTMLInputElement | Returns the editable value input element | | .disabled | boolean | Get or set the input's disabled state | | .value | string | Get or set the input's value | | .min | string | Get or set the input's min | | .max | string | Get or set the input's max | | .step | string | Get or set the input's step |

Options

| Name | Type | Default | Description | | ---------- | --------- | ------- | ------------------------------------------------------------------- | | value | boolean | false | Show the current value trailing the slider | | editable | boolean | false | Allow for the editing of the current value through a separate input | | ticks | boolean | false | Show ticks underneath the slider visualizing snapping points | | numbers | boolean | false | Show value numbers underneath the ticks |