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

v1.2.2

Published

Mirai Designs Framework: Base module

Downloads

17

Readme

Base

Base serves as the core foundation for a lot of the components, both in Sass and TypeScript.


Sass

Base includes a CSS reset we load first to create a standardized look for our apps and websites.

// Apply the CSS reset.
@forward '@miraidesigns/base/styles';

// Make use of the Base model with all its components.
@use '@miraidesigns/base';

Prefix

The prefix variable is generally applied to every given class for consistency sake.

.#{base.$prefix}-class__name {
    color: #fff;
}

Breakpoints

To serve content appropriately to a variety of devices, we use breakpoints (media queries) to set rules for various display dimensions.

Media queries are stored in the $breakpoints map and are called through the mixin of the same name.

.#{base.$prefix}-class__name {
    color: #fff;

    @include base.breakpoint('tablet-landscape') {
        color: #000;
    }
}

Layers

Layers are indicator for the elevation and/or importance of a given element.

All layers are stored inside the $layers map and are called through the mixin and function of the same name.

.#{base.$prefix}-class__name {
    // Using the mixin.
    @include base.layer('sidebar');

    // OR through the function.
    z-index: base.layer('sidebar');
}

TypeScript

Prototypes

For ease of access and readability we use prototypes to extend the functions of native JS objects.

Element

| Function | Type | Description | | ------------------------------------- | ------------------------ | ------------------------------------------------------------------------ | | .addClass(...classes) | (string[]): void | Add a class or a set of classes | | .removeClass(...classes) | (string[]): void | Remove a class or a set of classes | | .removeClassByPrefix(prefix) | (string): void | Remove a class with a specific prefix | | .toggleClass(className, condition?) | (string, any): void | Toggle the given class on the Element, optionally based on a condition | | .replaceClass(oldClass, newClass) | (string, string): void | Replace one class with another | | .hasClass(className) | (string): boolean | Returns wether or not the Element has the given class | | .show() | (): void | Remove the mdf-hidden class to show the Element | | .hide() | (): void | Adds the mdf-hidden class to hide the Element |

String

| Function | Type | Description | | ------------------ | ------------------ | ---------------------------------------------------------------------------- | | .truncate(limit) | (number): string | Stop the String from exceeding the set length and adds ellipses at the end |

A quick example on how to use the prototypes.

// Simply importing the base module is enough
import '@miraidesigns/base';

// We get the element we want to manipulate
const elem = document.querySelector('.example');

// Aaaand we added a class. It's just that easy
elem.addClass('class-name');