Skip to content

Commit

Permalink
First release
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre Burel committed Dec 8, 2016
0 parents commit fd482e7
Show file tree
Hide file tree
Showing 5 changed files with 154 additions and 0 deletions.
35 changes: 35 additions & 0 deletions README.md
@@ -0,0 +1,35 @@
# Direction

Sass mixins and functions to help creating bi-directional stylesheets.

Compatibility: [Sass](https://github.com/sass/sass) and [LibSass](https://github.com/sass/libsass)

---

## Install

Download [`_direction.scss`](https://raw.githubusercontent.com/pierreburel/sass-direction/master/_direction.scss) or install with [npm](https://www.npmjs.com/) or [Bower](http://bower.io/) :

### npm

```
npm install sass-direction
```

### Bower

```
bower install sass-direction
```

---

## Usage

Coming soon!

---

## Credits

Hugely based on [Tyson Matanich](http://matanich.com)’s [idea](https://github.com/tysonmatanich/directional-scss).
65 changes: 65 additions & 0 deletions _direction.scss
@@ -0,0 +1,65 @@
$direction: ltr !default;

@function direction($value) {
@if $direction == rtl and ($value == left or $value == right) {
@return if($value == left, right, left);
} @else {
@return $value;
}
}

@function direction-sides($values) {
@if $direction == rtl and length($values) == 4 {
@return nth($values, 1) nth($values, 4) nth($values, 3) nth($values, 2);
} @else {
@return $values;
}
}

@function direction-corners($values) {
@if $direction == rtl and length($values) > 1 {
@if length($values) == 2 {
@return nth($values, 2) nth($values, 1);
} @else if length($values) == 3 {
@return nth($values, 2) nth($values, 1) nth($values, 2) nth($values, 3);
} @else {
@return nth($values, 2) nth($values, 1) nth($values, 4) nth($values, 3);
}
} @else {
@return $values;
}
}

@function direction-if($condition, $if, $else: null) {
@return if($direction == $condition, $if, $else);
}

@function direction-ltr($if, $else: null) {
@return direction-if(ltr, $if, $else);
}

@function direction-rtl($if, $else: null) {
@return direction-if(rtl, $if, $else);
}

@mixin direction {
direction: $direction;
}

@mixin direction-if($condition) {
@if $direction == $condition {
@content;
}
}

@mixin direction-ltr {
@include direction-if(ltr) {
@content;
}
}

@mixin direction-rtl {
@include direction-if(rtl) {
@content;
}
}
22 changes: 22 additions & 0 deletions bower.json
@@ -0,0 +1,22 @@
{
"name": "sass-direction",
"description": "Sass mixins and functions to help creating bi-directional stylesheets.",
"version": "1.0.0",
"homepage": "https://github.com/pierreburel/sass-direction",
"main": "_direction.scss",
"authors": [
"Pierre Burel <pierre.burel@gmail.com>"
],
"keywords": [
"sass",
"direction",
"bidi",
"i18n"
],
"license": "MIT",
"ignore": [
"**/.*",
"sache.json",
"package.json"
]
}
21 changes: 21 additions & 0 deletions package.json
@@ -0,0 +1,21 @@
{
"name": "sass-direction",
"version": "1.0.0",
"description": "Sass mixins and functions to help creating bi-directional stylesheets.",
"keywords": [
"sass",
"direction",
"bidi",
"i18n"
],
"homepage": "https://github.com/pierreburel/sass-direction",
"bugs": {
"url": "https://github.com/pierreburel/sass-direction/issues"
},
"license": "MIT",
"author": "Pierre Burel <pierre.burel@gmail.com>",
"repository": {
"type": "git",
"url": "git://github.com/pierreburel/sass-direction.git"
}
}
11 changes: 11 additions & 0 deletions sache.json
@@ -0,0 +1,11 @@
{
"name": "sass-direction",
"description": "Sass mixins and functions to help creating bi-directional stylesheets.",
"tags": [
"sass",
"direction",
"bidi",
"i18n"
],
"website": "https://github.com/pierreburel/sass-direction"
}

0 comments on commit fd482e7

Please sign in to comment.