Git Product home page Git Product logo

directional-scss's Introduction

Directional-SCSS

Makes supporting both left-to-right (LTR) and right-to-left (RTL) easy.

Article: http://www.matanich.com/2013/09/06/rtl-css-with-sass/

Demos:

##Features

###Variables

  • $dir - defaults to ltr but can be set to rtl
  • $left - set to left when $dir equals ltr and right when $dir equals rtl
  • $right - set to right when $dir equals ltr and left when $dir equals rtl

###Functions

  • if-ltr($if) - returns $if param when $dir equals ltr otherwise returns nothing
  • if-ltr($if, $else) - returns $if param when $dir equals ltr otherwise returns $else param
  • if-rtl($if) - returns $if param when $dir equals rtl otherwise returns nothing
  • if-rtl($if, $else) - returns $if param when $dir equals rtl otherwise returns $else param
  • dir-values($values) - switches the 2nd and 4th positions of the $values list when $dir equals rtl

###Mixins

  • @include if-ltr { /*content*/ } - returns the @content when $dir equals ltr otherwise returns nothing
  • @include if-rtl { /*content*/ } - returns the @content when $dir equals rtl otherwise returns nothing

##Example

// Override default value for $dir in directional.scss
$dir: rtl;

// Import helpers from directional.scss
@import "directional";

// Use the helpers to make CSS for LTR or RTL
body {
	text-align: $left;
}

p {
	padding-#{$right}: 1em;
	margin: dir-values(0 2em 0 1em) if-ltr(!important);
	background-image: url(sprite#{if-rtl('-rtl')}.png);

	&:before {
		content: if-ltr('<', '>');
	}

	&:after {
		content: if-rtl('>', '<');
	}

	@include if-ltr {
		strong {
			padding-left: 0.5em;
		}
	}

	@include if-rtl {
		em {
			margin-right: 0.5em;
		}
	}
}

.icon.icon-star {
	background-image: url(sprite-#{$dir}.png);
}

directional-scss's People

Contributors

superman32432432 avatar

Watchers

Ahmed El Gabri avatar James Cloos avatar  avatar

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.