GithubHelp home page GithubHelp logo

Comments (7)

Jarzka avatar Jarzka commented on June 8, 2024 2

I solved this by using sorted-map.

from garden.

aisamu avatar aisamu commented on June 8, 2024 1

There's also ordered-map https://github.com/clj-commons/ordered, which stores things as they're inserted.

Also note that you can use multiple maps, per #67

from garden.

noprompt avatar noprompt commented on June 8, 2024 1

FYI you can also use more maps if the order of properties is relevant:

(garden.core/css
 [:body
  {:font-family "open_sans, Verdana, Helvetica, sans-serif"
   :color "#121212"}
  {:background "black url('/images/background2.jpg')"}
  {:background-repeat "no-repeat"}
  {:background-position "center"}
  {:background-attachment "fixed"}
  {:background-size "cover"}
  {:margin 0
   :padding 0}])

Compiles to

body {
  font-family: open_sans, Verdana, Helvetica, sans-serif;
  color: #121212;
  background: black url('/images/background2.jpg');
  background-repeat: no-repeat;
  background-position: center;
  background-attachment: fixed;
  background-size: cover;
  margin: 0;
  padding: 0;
}

This used to be documented in the README but then all the stuff was moved from the README to the Wiki and then only partially back to the README. 🙄

from garden.

harold avatar harold commented on June 8, 2024

Interesting! Never thought about this (Clojure map keys are unordered, so this makes sense)

In this case sorted-map helps because alphabetical order happens to work. 😄

from garden.

Jarzka avatar Jarzka commented on June 8, 2024

Yes, in this case it works. However, if at some point I would need to define property order fully manually, this might be a bit problematic.

from garden.

Jarzka avatar Jarzka commented on June 8, 2024

Would it be possible to define style map as a vector in that case? Or... maybe the different order of properties causing problems is so rare that there is no need to add syntax support for defining properties in a vector. One can also use sorted-map-by to solve this.

from garden.

Jarzka avatar Jarzka commented on June 8, 2024

I also noticed that this is probably a problem only when using shorthands, as:

As with all shorthand properties, any omitted sub-values will be set to their initial value.

So, if I use background-color and background-image instead of background, the order does not matter.

from garden.

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.