Giter Site home page Giter Site logo

less-bidi's Introduction

LESS-bidi - Direction agnostic stylesheets

LESS-bidi is a set of LESS mixins that allows creating bi-directional styling without significant code duplication.
By using LESS-bidi mixins, it’s possible to create direction agnostic CSS stylesheets, which are faster to write and much easier to maintain. Moreover, the naming convention used throughout the mixins makes it easier to comprehend by keeping the naming of properties as close as possible to the original CSS property names.

Documentation

Paradigm shift

Direction agnostic styling is made possible by using a new approach of referring to both sides of a document as the “start” and “end” of the text as opposed to “left” or “right” of the document. This approach is similar to what is done in flex-box specification (although LESS-bidi does not use or depend on flex-box). The interpretation of the terms start and end depends on the value of the variable @bidi. When @bidi: ltr; than start compiles to left, and end compiles to right, and when @bidi: rtl; it will be exactly the opposite. For example:

@bidi: ltr;
.bidi-text-align(start); // output: text-align: left;

and:

@bidi: rtl;
.bidi-text-align(start); // output: text-align: right;

Basic usage demo

Becouse of the fact that LESS-bidi mixins evalueting to opposite directioned styles depending on the value of @bidi, it enables you to write your styles ones, and have it evaluated under two scopes; one for ltr and one for rtl.

LESS-bidi CSS
@import "bidi";

.ltr { .style(ltr); } .rtl { .style(rtl); } .style(@bidi) { .bidi-direction();

h1 {
    .bidi-margin-start(20px);
	margin-bottom: 10px;
}
.two-col article {
    .bidi-float(start);
}
.two-col nav {
    .bidi-float(end);
}

}

.ltr {
  direction: ltr;
}
.ltr h1 {
  margin-left: 20px;
  margin-bottom: 10px;
}
.ltr .two-col article {
  float: left;
}
.ltr .two-col nav {
  float: right;
}
.rtl {
  direction: rtl;
}
.rtl h1 {
  margin-right: 20px;
  margin-bottom: 10px;
}
.rtl .two-col article {
  float: right;
}
.rtl .two-col nav {
  float: left;
}

less-bidi's People

Contributors

danielkatz avatar

Watchers

 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.