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

@factorial/drupal-breakpoints-css

v0.3.3

Published

Drupal breakpoints to css customProperties

Downloads

221

Readme

Drupal breakpoints to CSS

To eliminate the need for different places for breakpoints and only maintain a single source of truth for those, this node_module extracts the breakpoints defined in the currently used Drupal themes breakpoint file and generates grouped customProperties and a separate js object with all necessary parameters.

If the draft @custom-media or PostCSS with Custom Media plugin is already used, media queries can be written with customProperties. So any declaration of media queries within stylesheets is omitted and maintainability is increased.

Installation

Install as a devDependency with yarn or npm like:

yarn add --dev @factorial/drupal-breakpoints-css
# or
npm install --sav-dev @factorial/drupal-breakpoints-css

Configuration

In your themes root folder, besides your already defined breakpoints file from Drupal, add a breakpoints.config.yml configuration file. The following properties are mandatory:

// ./lib/types.d.ts
export interface UserConfig {
  drupal: {
    breakpointsPath: string;
    themeName: string;
  };
  prettier?: {
    configPath: string;
  };
  js?: {
    enabled?: boolean;
    path?: string;
    type?: "commonjs" | "module";
  };
  css?: {
    enabled?: boolean;
    path?: string;
    element?: string;
    customMedia?: boolean;
    customProperty?: boolean;
  };
  options?: {
    mediaQuery?: boolean;
    resolution?: boolean;
    minWidth?: boolean;
    maxWidth?: boolean;
  };
}

Schema Validation

You could validate your configuration files with the help of JSON Schema Store and e.g Visual Studio Code YAML Extension.

Prettier

To respect your local Prettier formatting rules please add the path to the configuration file to prettier.path.

Usage

Just run yarn drupal-breakpoints-css start or npm run drupal-breakpoints-css start. Thats it :)

Examples

# Durpal breakpoints file
theme_name.s:
  label: small
  mediaQuery: "only screen and (max-width: 47.9375rem)"
  weight: 0
  multipliers:
    - 1x
    - 2x
theme_name.md:
  label: medium
  mediaQuery: "only screen and (min-width: 48rem) and (max-width: 63.9375rem)"
  weight: 2
  multipliers:
    - 1x
    - 2x
theme_name.lg:
  label: large
  mediaQuery: "only screen and (min-width: 64rem) and (max-width: 89.9375rem)"
  weight: 3
  group: theme_name.group
  multipliers:
    - 1x
    - 2x
/* Generated CSS file */
@custom-media --Themename-small-mediaQuery (only screen and (max-width: 47.9375rem));
@custom-media --Themename-small-resolution (resolution: 2x);
@custom-media --Themename-small-maxWidth (max-width: 47.9375rem);

:root {
  --ThemeName-small-mediaQuery: "only screen and (max-width: 47.9375rem)";
  --ThemeName-small-resolution: "2x";
  --ThemeName-small-maxWidth: "47.9375rem";
}
// Generated JS file
const BREAKPOINTS = {
  "ThemeName-small-mediaQuery--raw": "only screen and (max-width: 47.9375rem)",
  "ThemeName-small-resolution--raw": "2x",
  "ThemeName-small-resolution": "resolution: 2x",
  "ThemeName-small-maxWidth--raw": "47.9375rem",
  "ThemeName-small-maxWidth": "max-width: 47.9375rem",
};
export default BREAKPOINTS;

Acknowledgements

This Script uses open source software and would not have been possible without the excellent work of the Drupal, Eslint, deepmerge and Prettier teams! Thanks a lot!

Sponsored by