Giter Site home page Giter Site logo

sass-extend's Introduction

sass-extend

Extends sass built-in modules with additional useful functions.

How to use

Add sass-extend to your scss project and import the modules you want to use using @use, just like native sass modules.

If you are using native sass modules within the same namespace, use an alias for sass-extend to prevent namespace conflicts.

Modules

These are the modules included in sass-extend.

string

@use "sass-extend/string";

replace

Function used to replaces a substring in a string.

string.replace($string, $search, $replace: "")

The following snippet shows an example on how to use it.

@use "sass-extend/string";

$string: "Lorem ipsum";
$replaced-string: string.replace($string, "ipsum", "dolor sit"); // Lorem dolor sit

To use with an unquoted string, you need to interpolate it.

@use "sass-extend/string";

$hex: #f5f5f5;
$hex-digits: string.replace(#{$hex}, "#", ""); // f5f5f5

math

@use "sass-extend/math";

strip-unit

Function used to remove the unit from a CSS value (number).

math.strip-unit($number)

The following snippet shows an example on how to use it.

@use "sass-extend/math";

$strip-unit: math.strip-unit(16px); // 16

Import all modules at once

It is also possible to import all modues at once. To do so, import sass-extend directly.

@use "sass-extend";

All modules will be namespaced with sass-extend instead of the module category name. It is possible to change the namespace adding an alias to the import.

@use "sass-extend" as se;

Demo

This repository includes a demo used to test the functions. Run the demo using the following command. The output will be logged in the terminal.

npm run demo

Work in this repository

Guidelines for working in this repository.

Before you start

Install dependencies.

npm install

Code formatting

This project uses Prettier to format the code. To format all files, run the following command.

npm run prettier

Lint

This project uses Stylelint to lint the scss. The settings is based on stylelint-config-standard-scss. To run the lint, run the following command.

npm run stylelint

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.