Git Product home page Git Product logo

Comments (14)

OsamaAbbas avatar OsamaAbbas commented on May 21, 2024

Bootstrap has many rules like that previous example.

@media (min-width: 768px) {
  .navbar-left {
    float: left !important;
  }
  .navbar-right {
    float: right !important;
    margin-right: -15px;
  }
  .navbar-right ~ .navbar-right {
    margin-right: 0;
  }
}

After conversion:

@media (min-width: 768px) {
  .navbar-left {
    float: right !important;
  }
  .navbar-right {
    float: left !important;
    margin-left: -15px;
  }
  .navbar-right ~ .navbar-right {
    margin-left: 0;
  }
}

from rtlcss.

MohammadYounes avatar MohammadYounes commented on May 21, 2024

This is the default behavior, see Why Auto Rename?

The rules you listed contain directional declarations and should not be auto renamed, I don't see why you need them both to be either renamed or ignored ?

from rtlcss.

MohammadYounes avatar MohammadYounes commented on May 21, 2024

Also see RTL-bootstrap, A complete RTL version generated using this tool (with autoRename enabled).

from rtlcss.

OsamaAbbas avatar OsamaAbbas commented on May 21, 2024

Thank you for the quick response!

Becase it doesn't make sence to have a rule with name .text-left which do the opposite text-align: right. It is not just .text-left, Bootstrap has many of these *-left *-right classes. We need them to do what they are supposed to do. navbar-left, for example, is supposed to align an element to the left, not right.

.

Regarding RTL-bootstrap, I'm trying to process Bootstrap.css v3.3.6 using rtlcss cli with autoRename: true. But I get this error:

Saving: /path/to/bootstrap.rtl.css
rtlcss: error processing file /path/to/bootstrap.css
TypeError: Cannot read property 'replace' of undefined

Also, see here. .navbar-left causes float: right. Which is weird.

from rtlcss.

OsamaAbbas avatar OsamaAbbas commented on May 21, 2024

The default behavior is better if all you want is to convert an existing bootstrap template with minimum modifications. Because you don't have to flip all *-left and *-right inside the html files.
But if you are building something from scratch, it is very annoying to use navbar-left when you want it to float: right!

from rtlcss.

MohammadYounes avatar MohammadYounes commented on May 21, 2024

Becase it doesn't make sence to have a rule with name .text-left which do the opposite text-align: right. It is not just .text-left, Bootstrap has many of these *-left *-right classes. We need them to do what they are supposed to do. navbar-left, for example, is supposed to align an element to the left, not right.

It makes sense when you want to use the same HTML markup! Hence, Why Auto Rename?

The default behavior is better if all you want is to convert an existing bootstrap template with minimum modifications. Because you don't have to flip all *-left and *-right inside the html files.
But if you are building something from scratch, it is very annoying to use navbar-left when you want it to float: right!

The intended use of this tool is to automatically create the RTL counterpart from your LTR stylesheet! If you are creating an RTL version from scratch, then its not wise to use it!

Seems there is an error with the new CLI, I'll fix soon.

Thanks!

from rtlcss.

MohammadYounes avatar MohammadYounes commented on May 21, 2024

Moreover, to rename or ignore them both, you can use directives:

require("rtlcss").process(`/*rtl:rename*/.text-left {
  text-align: left;
}`, {
  autoRename: false
});
// ".text-right {\n text-align: right;\n}"

or

require("rtlcss").process(`/*rtl:ignore*/.text-left {
  text-align: left;
}`);
//".text-left {\n text-align: left;\n}"

from rtlcss.

OsamaAbbas avatar OsamaAbbas commented on May 21, 2024

Yes I'm creating an RTL version from scratch. But it is much more easier to use an RTL version of bootstrap itself. In this case, we need to use navbar-left and get float: left and so on.

Directives seem good. But I think there is something better to be done. Maybe a new option to ignore rules with left, right, rtl, ltr... etc and have directional declarations.

Thank you again :) .

from rtlcss.

MohammadYounes avatar MohammadYounes commented on May 21, 2024

I can't reproduce the CLI issue on my development machine, would you please provide me with node/npm/rtlcss versions:

npm -v
node -v
rtlcss -v

from rtlcss.

OsamaAbbas avatar OsamaAbbas commented on May 21, 2024
npm -v
3.3.12
rtlcss -v
rtlcss version: 2.0.0

Node.js: both v4.3.0 and v5.5.0. I'm using Ubuntu 14.04.

And here is .rtcssrc file:

{
  "options": {
    "autoRename": true,
    "autoRenameStrict": true,
    "blacklist": {},
    "clean": true,
    "greedy": false,
    "processUrls": false,
    "stringMap": []
  },
  "plugins": [],
  "map": false
}

from rtlcss.

MohammadYounes avatar MohammadYounes commented on May 21, 2024

Thanks for the config, the bug was caused by @font-face { ... } as it contains decl nodes, autoRename assumed declarations only existed inside rule nodes.

Fix released in 2.0.1

from rtlcss.

MohammadYounes avatar MohammadYounes commented on May 21, 2024

Maybe a new option to ignore rules with left, right, rtl, ltr... etc and have directional declarations.

@OsamaAbbas You can do another rename by adding your own plugin, see https://tonicdev.com/mohammad/rtlcss-rename-all

from rtlcss.

OsamaAbbas avatar OsamaAbbas commented on May 21, 2024

Thank you for the last commit. It works now.

And I've used one of the default directives, It worked too!

/*rtl:begin:rename*/

/*
* here goes the whole bootstrap file!
*/

/*rtl:end:rename*/

from rtlcss.

MohammadYounes avatar MohammadYounes commented on May 21, 2024

Yup! that gives the same result 👍

from rtlcss.

Related Issues (20)

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.