Comments (7)
I solved this by using sorted-map
.
from garden.
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.
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.
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.
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.
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.
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)
- defcssfn don't behave as documented HOT 2
- Incorrect CSS emitted for inner media queries HOT 6
- Link broken for Tutorial and example in Wiki HOT 6
- how to supply the value to grid-template-area? in css it is multiple strings... HOT 3
- Changelog since 1.3.6 HOT 1
- `as-hex` taking into account Alpha value
- No `fr` unit
- Question about defining multiple style maps HOT 6
- Add support for container queries HOT 3
- Incorrect CSS emitted for "&" parent selector
- defcssfn is not defined in cljs or cljc
- `ClassNotFoundException` thrown when running tests on Java 11
- Warning about `garden.color/abs` shadowing `clojure.core` output when using Clojure 1.11.0 HOT 1
- `::marker` pseudo element isn't supported HOT 2
- Release request, to prevent repeated shadowed-var warnings in the REPL HOT 13
- Incorrect handling of selectors HOT 1
- Incorrect css generation HOT 1
- content: " " produces wrong output HOT 5
- Feature request: Support for cascade layers HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from garden.