All Projects → KittyGiraudel → Sassyjson

KittyGiraudel / Sassyjson

Licence: mit
[UNMAINTAINED] A Sass API for JSON.

Labels

Projects that are alternatives of or similar to Sassyjson

Newparent
给忙碌者的育儿攻略
Stars: ✭ 162 (-6.36%)
Mutual labels:  scss
Vant React
Lightweight 2kb Mobile UI Components built on React and TS, inspired by [email protected]://github.com/youzan/vant
Stars: ✭ 166 (-4.05%)
Mutual labels:  scss
Browser Hack Sass Mixins
Browser hack sass mixin - Apply your SCSS to a specific browser - CSS hacks for: IE, Chrome, Firefox, Edge, Opera
Stars: ✭ 170 (-1.73%)
Mutual labels:  scss
Editorial
A free, open source theme for Ghost
Stars: ✭ 164 (-5.2%)
Mutual labels:  scss
Adam Blog
Adam Blog is a minimal clear theme for Jekyll
Stars: ✭ 167 (-3.47%)
Mutual labels:  scss
7.css
A tiny CSS framework for building faithful recreations of the Windows 7 UI.
Stars: ✭ 169 (-2.31%)
Mutual labels:  scss
React Timelines
React Timelines Library
Stars: ✭ 161 (-6.94%)
Mutual labels:  scss
Elixir Examples.github.io
A collection of elixir programming language examples.
Stars: ✭ 171 (-1.16%)
Mutual labels:  scss
Sassessentials
Repository for my tutorial course: Sass Essential Training on LinkedIn Learning and Lynda.com.
Stars: ✭ 167 (-3.47%)
Mutual labels:  scss
Asciidoctor Stylesheet Factory
🎨 A utility project for producing the default stylesheet for the HTML converter in Asciidoctor. All other uses are deprecated. Assembled using Compass, Sass and Foundation.
Stars: ✭ 169 (-2.31%)
Mutual labels:  scss
Css Vars
Sass mixin to use CSS Custom Properties with Sass
Stars: ✭ 164 (-5.2%)
Mutual labels:  scss
Fem Easybank
Easybank landing page from Frontend Mentor
Stars: ✭ 164 (-5.2%)
Mutual labels:  scss
Tuicss
Text-based user interface CSS library
Stars: ✭ 167 (-3.47%)
Mutual labels:  scss
Theme Chalk
Element theme chalk
Stars: ✭ 163 (-5.78%)
Mutual labels:  scss
Toucaan
Intrinsic Web Design.
Stars: ✭ 170 (-1.73%)
Mutual labels:  scss
Hitchens
An inarguably well-designed Jekyll theme.
Stars: ✭ 162 (-6.36%)
Mutual labels:  scss
Hugo Serif Theme
Serif is a modern business theme for Hugo.
Stars: ✭ 168 (-2.89%)
Mutual labels:  scss
Hexo Theme Memory
A minimal hexo theme.
Stars: ✭ 173 (+0%)
Mutual labels:  scss
Fresh
Fresh shiny themes
Stars: ✭ 170 (-1.73%)
Mutual labels:  scss
Compile Hero
🔰Visual Studio Code Extension For Compiling Language
Stars: ✭ 169 (-2.31%)
Mutual labels:  scss

SassyJSON NPM version Gem Version

⚠️ SassyJSON was an experimental project. It is not meant to be used in production. If you need to transit JSON data from and to your Sass layer, have a look into Eyeglass and Sassport.

SassyJSON is a Sass-powered API for JSON. It provides you the classic json-encode and json-decode directly from your Sass files. We'll leave you the only judges of the point of this.

Install

SassyJSON is available on npm or as a Ruby Gem.

Git

git clone https://github.com/KittyGiraudel/SassyJSON.git && cd SassyJSON

npm

npm install sassyjson --save-dev

Compass extension

  1. gem install SassyJSON
  2. Add require 'SassyJSON' to your config.rb
  3. Import it in your stylesheets with @import 'SassyJSON'

Sass

If you only want to play around the code without cloning the repo or using npm, you can find a single file containing the whole API in the dist folder.

Also, SassyJSON is available at Sassmeister.

Example

Encoding Sass to JSON

Sass

$map: ((a: (1 2 ( b : 1 )), b: ( #444444, false, ( a: 1, b: test ) ), c: (2 3 4 string)));

@include json-encode($map);

CSS

/*! json-encode: '{"a": [1, 2, {"b": 1}], "b": ["#444444", false, {"a": 1, "b": "test"}], "c": [2, 3, 4, "string"]}' */

body::before {
  display:block;
  width:0;height:0;
  overflow:hidden;
  content: '{"a": [1, 2, {"b": 1}], "b": ["#444444", false, {"a": 1, "b": "test"}], "c": [2, 3, 4, "string"]}';
}

head {
  font-family: '{"a": [1, 2, {"b": 1}], "b": ["#444444", false, {"a": 1, "b": "test"}], "c": [2, 3, 4, "string"]}';
}

@media -json-encode {
  json {
    json: '{"a": [1, 2, {"b": 1}], "b": ["#444444", false, {"a": 1, "b": "test"}], "c": [2, 3, 4, "string"]}';
  }
}

If you want to restrict the output to only one of the three drivers (comment, media query or regular output) you can pass a flag as the second parameter with one of the four following keywords: all, comment, media or regular. Default is all.

Decoding JSON to Sass

$json-decode: json-decode('{"a": [1, 2, {"b": 1}], "b": ["#444444", false, {"a": 1, "b": "test"}], "c": [2, 3, 4, "string"]}');
// ("a": 1 2 ("b": 1), "b": #444444 false ("a": 1, "b": "test"), "c": 2 3 4 "string")

Importing and decoding a JSON file

To importe and decode an external .json file directly into a Sass variable:

@import 'SassyJSON'; // Import SassyJSON first!
@import 'relative/path/to/file.json?variable-name';
// Do something with $variable-name

Important:

  • the path to the JSON file is relative to importing file
  • the get parameter is the variable name to use it in Sass

Requirements

All you need is a clean version of Sass 3.3. Otherwise it's just pure Sass madness.

Development

You need

  • NodeJS
  • Ruby
  • Sass 3.3 via gem install sass --pre
  • grunt-cli via npm install -g grunt-cli

How to

  1. Fork this repository
  2. Run npm install
  3. grunt dev
  4. Make your changes + write tests
  5. Commit + Pull request

Credits

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].