Socket
Socket
Sign inDemoInstall

@littlemissrobot/sass-spacing

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@littlemissrobot/sass-spacing

Little Miss Robot spacing setup for defining spacing variables


Version published
Weekly downloads
48
increased by65.52%
Maintainers
1
Weekly downloads
 
Created
Source

Little Miss Robot - Sass Spacing

This repository contains the logic and functionality to define and insert consistent spacings based on an iteratable amount.

Info

This repository does not generate any CSS. It simply makes functions and mixins available to be used in combination with a configuration object to manage your spacing.

Install

$ npm install --save-dev @littlemissrobot/sass-spacing

Dependencies

  • @littlemissrobot/sass-functions/lib/main

Usage

  1. Create a .scss file
  2. Import the library from the node_modules folder.
@import
	// Dependency
	"@littlemissrobot/sass-functions/lib/main",
	// Library
	"@littlemissrobot/sass-spacing/lib/main";
  1. Create a map-variable $lmr-sass-spacing and pass it a map with a settings and source key. The settings key should have a baseline key which contains the base iteratable spacing.
$lmr-sass-spacing: (
	settings: (
		baseline: 1rem,
	),
	source: (
		x1: 1,
		x2: 2,
		x3: 3,
		x4: 4,
		x5: 5,
		x6: 6,
		x7: 7,
		micro: 1rem,
		tiny: 2rem,
		small: 3rem,
		base: 4rem,
		large: 5rem,
		huge: 6rem,
		giant: 7rem
	)
);

Source

There are two ways to add keys to the source:

Pass a number without a unit

Passing a number without a unit will make use of the baseline defined in the settings key. The number will be multiplied with the baseline value to define a certain spacing. You can give you iterator a name to make it contextual or reusable.

For example:

$lmr-sass-spacing: (
	settings: (
		baseline: 1rem,
	),
	source: (
		1x: 1, // 1rem
		2x: 2 // 2rem
	)
);

Pass a number with a unit

Passing a number with a unit will simply ignore the baseline and make use of the value you have passed to the key.

For example:

$lmr-sass-spacing: (
	settings: (
		baseline: 1rem,
	),
	source: (
		micro: 2.5rem, // 2.5rem
		giant: 70px // 70px
	)
);

Functions

set-spacing($name)

The set-spacing function accepts a path that it will follow and will look through the source defined in the $lmr-sass-spacing map and retrieve the value from the passed path.

Parameters:

  • path: The path to the spacing value in the source key of the map $lmr-sass-spacing. It accepts the formats:

    • A string, like "section small" (we like this)
    • A space-separated list, like "section" "small"
    • A comma-separated list, like ("section", "small")
// =============================================================================
// Configuration
// =============================================================================
$lmr-sass-colors: (
	settings: (
		baseline: 1rem
	),
	source: (
		section: (
			small: 1rem, // 1rem
			base: 5, // 5rem
			large: 9rem // 9rem
		)
	)
);

// =============================================================================
// Examples
// =============================================================================

// As a string
// -----------------------------------------------------------------------------
div {
	margin-top: set-color("section small");
	margin-top: set-color("section base");
}

// As a list of space-separated strings
// -----------------------------------------------------------------------------
div {
	margin-top: set-color("section" "small");
	margin-top: set-color("section" "base");
}

// As a list of comma-separated strings
// -----------------------------------------------------------------------------
div {
	margin-top: set-color(("section", "small"));
	margin-top: set-color(("section", "base"));
}

Keywords

FAQs

Package last updated on 16 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc