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

ng-screen-size

v0.0.8

Published

This is a utility library based on Angular Material's [Component Dev Kit](https://material.angular.io/cdk) that provides a simple solution for managing responsive design both within scss and html structure.

Downloads

5

Readme

NgScreenSize

This is a utility library based on Angular Material's Component Dev Kit that provides a simple solution for managing responsive design both within scss and html structure.

Setup

Manual

Install the library by running npm i ng-screen-size.

Default

If you want to use the default settings simply import NgScreenSizeModule in your root module.

Custom

If you wish to customize the breakpoints of your screen sizes you will need to create a styling file with your screen sizes, such as the following:

screen-size.scss

$smScreenWidth: 600px;
$mdScreenWidth: 960px;
$lgScreenWidth: 1280px;
$xlgScreenWidth: 1920px;

@import '~ng-screen-size/styles/screen-size';

Note: Only provide the screen widths in pixels

Add this file to your assets in your angular.json, like so:

"assets": [
	"src/favicon.ico",
	"src/assets",
	"src/styles/screen-size.scss",

Once that is done, the last step is to provide the library with that file's location in your root module:

import { NgScreenSizeModule, ScreenSizeBreakpointVariables } from 'ng-screen-size';

<----------------------------------------------------------------->

providers: [{
	provide: ScreenSizeBreakpointVariables,
	useValue: 'styles/screen-size.scss',
},

Now you can modify the breakpoints of different screen sizes and your changes will persist for both the directive and the mixins.

Schematic

You can also quickly install the library using a schematic, simply run the command

ng add ng-screen-size --path src/styles/screen-size.scss

With the --path argument being the location at which to generate your custom breakpoints file. Do not provide this argument if you wish to use the default configuration.

Usage

SCSS

The library provides simple mixins (xs, sm, md and lg) to control the style changes for different screens, you can look at the mixins in the source code.

To use the mixins simply import them in the required file with:

@import '~ng-screen-size/styles/screen-size';

Or the location of your own custom breakpoints file. If you used the schematics to setup the library, you will have your styles file added to the preproccessor, so you can easily import it with just the file's name, like so:

@import 'screen-size'

HTML

To provide control of the html structure that is consistent to the scss you can use the *ngScreenSize directive. The directive takes an array input of sizes for which to render, with ranges being possible using blank items.

Examples:

  • ['sm', 'md']: small and medium screens
  • ['xlg']: only extra large screen
  • ['', 'md']: medium screens and smaller
  • ['md', '']: medium screens and larger
  • ['sm', 'lg']: everything between medium and large screens, inclusive