Skip to content

A small SCSS/SASS library to add essential functionality and make working with maps easier.

License

Notifications You must be signed in to change notification settings

caseydwayne/Sassy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sassy

Sassy eases the pain for object-oriented programmers and makes getting around in SASS a little easier.

Sassy v1.5 will be released soon!

Changes: All methods and mixins will now start with sassy-, with aliasing optional.

Overview

Sassy provides some essential functionality and makes working with maps much easier.

It also includes a debugging utility for unit-testing (see notes at the bottom).

Methods:

Note: 'methods and uses' must be expanded to jump to a specific function

Mapping Tools Essentials Extras Administrative Other
get compare explode thru types
set type implode print types-same
has contains increase apply -
- - decrease - -

Method Uses:

All methods that use a ( map, key, ... ) signature allow for nested maps using a key list!

( list, of, keys )

View Sassy methods and uses.

get

gets an value from a map key. for nested maps, use a list of keys

Signatures and Supported Types

Signature:

  • get( map, key )
  • get( map, ( nested, key ) )

Supported types: map

top


set

sets a key:value pair in a map. for nested maps, use a key list

Signatures and Supported Types

Signature:

  • set( map, key, value )
  • set( map, ( nested, key ), value )

@note Remember SASS objects are immutable. Replace your map reference each time!

Supported types: map

top


has

checks if a map has a key. optionally returns the value

Signatures and Supported Types

Signature: has( map, key, [return], [default] )

Optional default value IF NO KEY (otherwise returns null).

Supported types: map

top


compare

compares 2 things

Signatures and Supported Types

Signature: compare( A, B )

Supported types: any

top


type

gets the type of an object (optional check string to compare and return bool)

Signatures and Supported Types

Signature: type( var, [against] )

Supported types: any

top


types

returns the types of all args provided in a new list

Signatures and Supported Types

Signature: types ( varN... )

Supported types: any

top


types-same

checks that all vars provided are the same type

Signatures and Supported Types

Signature: types-same ( varN... )

Supported types: any

top


contains

checks if one thing contains another

Signatures and Supported Types

Signature: contains( haystack, needle )

Supported types: map, list, string

top


explode

breaks a string by {delimiter}, returns as list

Signatures and Supported Types

Signature: explode( string, [delimiter='-'] )

Supported types: string

top


implode

joins list items between glue, returning as a string

Signatures and Supported Types

Signature: implode( list, [wrap=false], [glue=', '] )

@note wrap is optional. if true, adds ( ) to string before returning

Supported types: list

top


thru( any )

returns the first argument straight thru (useful for testing purposes)

Signatures and Supported Types

Signature: thru( any )

Supported types: any

top


print

prints a map as a string representation (similar to native "inspect" function)

Signatures and Supported Types

Signature: print( map )

Supported types: map

top


apply

essentially 'calls' a function. values will be fed as call unless they are a list or map. if list, passed as multiple args. if you need to pass a single list, use an "argsmap" ( args: ( your, list ) ) as the arguments param. used by debugger

Signatures and Supported Types

Signature:

  • apply( method_name, argslist... )
  • apply( method_name, ( list, of, args ) )
  • apply( method_name, argsmap )

Supported types: function

top


increase

increases a number [in a map] by X

Signatures and Supported Types

Signature:

  • increase( number, [x=1] )
  • increase( map, key, [x=1] )

Supported types: number, map with number as value to a key

top


decrease

decreases a number [in a map] by X

Signatures and Supported Types

Signature:

  • decrease( number, [x=1] )
  • decrease( map, key, [x=1] )

Supported types: number, map with number as value to a key

top


pluck

pulls a shared key from multiple maps

Signatures and Supported Types

Signature: pluck( key, maps.. )

@note also accepts a list of maps

Supported types: map

top

top


Sassy Debugger

I put together a SASS debug utility based loosely on my much more robust JS debugger.

There are only 3 mixins you need (really only "test", but it's better to use all 3).

View Sassy debug mixins

Mixin: start

starts a debugger

Signature: @include start(debug_name)


Mixin: test

performs a unit test and echos result

Signatures and Uses

Signature:

  • @include test( method_name, arguments, [expect=true] )
  • @include test( name, result, [expect=true] )

You should always use a list of arguments instead of a result boolean.

The result boolean option is there for edge cases where comparing the result isn't so easy.

If you need to pass a single list, use an argsmap

( args: ( your, list ) )

You can add a variation string as the 4th parameter. Useful if debugging similar signatures.

top


Mixin: complete

reports a summary of pass | fail.

Signature: @include complete;

Include this after your last test. It will tell you that all tests passed or which ones failed (and why).

top


That's all! Enjoy the software!

About

A small SCSS/SASS library to add essential functionality and make working with maps easier.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published