sebastiaanvisser / clay Goto Github PK
View Code? Open in Web Editor NEWA CSS preprocessor as embedded Haskell.
License: Other
A CSS preprocessor as embedded Haskell.
License: Other
This code:
fontFamily [] [sansSerif]
Compiles to this:
font-family : , sans-serif;
This doesn't work like: font-family: sans-serif;
. ,
should not be there, when deleted it works as expected.
I think this is a bug.
Why is the border stuff in a different order to normal order? Instead of
border-left: 1px solid #aaa
in Clay you instead write:
borderLeft solid (px 1) "#aaa"
For convenient partial application? It's rather jarring to have the args swapped from normal.
Hello! Quite enjoying your framework! Very easy to use!
When trying to set a margin using a percentage (example: margin (pct 25) 0 0 0) I get a compile error stating:
Couldn't match expected type 'Abs' with actual type 'Rel'
Looks like margins have been implemented as something you have to specify an exact width for rather than a width relative to the parent container. Quite straightforward to work around for the moment.
Thank you!
AFAIK hsl/hsla values are meant to be expressed using percentages, as described: http://www.w3schools.com/cssref/css_colors_legal.asp
But Clay.Color.hsl :: Integer -> Integer -> Integer -> Color
, which seems to output raw integers in every case, e.g. hsl 0 70 40
compiles to hsl(0,70,40)
which is an invalid CSS value.
e.g.
do borderWidth 0
-->
border-width : 0px;
If I remember correctly 0px is not common for css. It's better when 0 is just 0.
Downloaded the latest 13293a2, cabal-dev install'd and loaded up cabal-dev ghci and examples/Main.hs
and get:
examples/Main.hs:10:8: Not in scope: `css' …
Perhaps you meant one of these:
`cs' (line 15), `cos' (imported from Prelude)
examples/Main.hs:41:17: Not in scope: data constructor `FontOptional'
examples/Main.hs:42:17: Not in scope: data constructor `FontMandatory'
examples/Main.hs:70:33: Not in scope: `with' …
Seems like it's expecting an older API?
I would have loved if Selector was a full monoid. I could have written mconcat
instead of using a auxilary function like selectors
as in
https://github.com/piyush-kurur/pottery/blob/master/Pottery/Reset.hs
While it is understandable that there is no such thing as an empty list of selector, may be we can invent one called EmptySelector and report error in the css monad instead
when we try some thing like
EmptySelector ? do
background black
This EmptySelector
can then be the mzero
http://hackage.haskell.org/packages/archive/clay/0.6/doc/html/Clay-Font.html#v:fontFamily says the type of fontFamily
is [Text] -> [Text] -> Css
. It's unclear to me why this is the case, so if this is intentional I think it should be documented what these parameters mean. 'a' and 'b' in the source code does not go far to clarify this either.
I wanted to set outline-style:none
for both a:active
and a:visited
, and thought I could do (":active" <> ":hover") & outlineStyle none
, but Refinement
is not a Monoid
or Semigroup
instance. In the end I did:
forM_ [":active", ":focus"] (& outlineStyle none)
Which does the job, but it is a tad verbose.
It also doesn't produce a:active, a:focus
as I wanted, but instead gives me two separate blocks.
serif
, sansSerif
, and monospace
are Literal types, hence broken. I.e.,
fontFamily [serif]
gets compiled into
font-family:"serif"
and the double quotes in "serif" make it become interpreted as a font description, not a font-family. The correct result should be
font-family:serif
without the double quotes.
what am I trying to do:
{-# LANGUAGE OverloadedStrings #-}
import Clay
import Prelude hiding (div,span,(**))
import Data.Monoid
generalcss = foldl1 (Clay.**) [html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, address, code, del, dfn, img, q, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td]
main = putCss $
do generalcss ?
do fontSize (em 0.6)
what do I get:
html body div span object iframe h1 h2 h3 h4 h5 h6 p blockquote pre a abbr address code del dfn img q dl dt dd ol ul li fieldset form label legend table caption tbody tfoot thead tr th td
{
font-size : 0.6em;
}
How to make it proper? Though there should be comas...
How can I skip invoking elements as div, and use just "." ?
Currently I have following code:
carouselS :: Css
carouselS = ".carousel" & do
border solid (px 10) white
boxShadow (em 0) (em 0.3) (em 0.8) black
margin (px 0) auto auto auto
padding (px 0) auto auto auto
Printning with:
putCss $ div ? carouselS
Gives ouput as:
div.carousel
{
border : solid 10px rgb(255,255,255);
-webkit-box-shadow : 0.0em 0.3em 0.8em rgb(0,0,0);
-moz-box-shadow : 0.0em 0.3em 0.8em rgb(0,0,0);
-ms-box-shadow : 0.0em 0.3em 0.8em rgb(0,0,0);
-o-box-shadow : 0.0em 0.3em 0.8em rgb(0,0,0);
box-shadow : 0.0em 0.3em 0.8em rgb(0,0,0);
margin : 0px auto auto auto;
padding : 0px auto auto auto;
}
but I want:
.carousel
{
...
Hi guys
First, thanks for this cool project! :)
I'm new to Haskell, so excuse me if I'm asking a silly question here.
With SCSS I can use the @import
function to split my SCSS into multiple files and then reimport them back into the files I want.
Here's an example project directory. I keep mixins, variables, etc in the modules
directory, and my code that directly compiles to CSS in the partials
directory.
The main.scss
file contains nothing but @import
statements, and it's the file that I point my scss compiler at to output main.css
_scss/
├── modules
│ └── _variables.scss
│ └── _clearfix.scss
├── partials
│ ├── _buttons.scss
│ └── _forms.scss
└── vendor
│ └── _something.scss
└── main.scss
I'm keen to replicate this modular way of working with clay, as I find it much more manageable than one giant file. Is there a recommended method for doing this sort of thing?
Thanks,
Louis
Just question... as I don't know where to ask it. When I'm doing
"#hello" & world
or
".hello" & world
on top level
I'm getting "this should be fixed soon"
Maybe I should be just safe with
"#hello" ? world
and
*#hello ...
I guess but I'm not that good in css and maybe there other ways to make it?
Hi, this is a question rather than a bug, but might be a feature request. In sass you can do the following (example in sass homepage):
.error {
border: 1px #f00;
background: #fdd;
}
.error.intrusion {
font-size: 1.3em;
font-weight: bold;
}
.badError {
@extend .error;
border-width: 3px;
}
Which results in the following:
.error, .badError {
border: 1px #f00;
background: #fdd;
}
.error.intrusion,
.badError.intrusion {
font-size: 1.3em;
font-weight: bold;
}
.badError {
border-width: 3px;
}
Is there any facility for that with clay? I managed to do something similar (inclusion perhaps) by factorizing out the .error css in a function, but that wouldn't compact the css like sass does.
Hi, in the homepage there's a reference to "the todo list" which is a 404.
The idea is that the tool would take files that have Clay code in them, generate a file with the correct trivial import, main
, and extensions added, and compile and run this (or just use runhaskell
).
I don't see anything to deal with this. Is there any way to write @font-face rules in the DSL, or should I just prepend this kind of thing to clay's output?
I was trying to generate this CSS code:
border-radius: 3px 3px 0 0;
But borderRadius :: Size a -> Css
type is just not allowing this. I thought maybe it's type should be like margin :: Size Abs -> Size Abs -> Size Abs -> Size Abs -> Css
,
Any ideas?
letterSpacing ((-0.05) `em`)
compiles to
letter-spacing : -5.0e-2em;
I'm using the latest version...
According to this, the verticle-align property has the following valid values:
baseline | sub | super | text-top | text-bottom | middle | top | bottom | <percentage> | <length>
Unforchunently, currently in clay there is no way to specify the property:
vertical-align: super;
This is because VerticleAlignValue isn't exported (and it should remain this way). Anyways, the fix (to Clay.Display) is as simple as:
vAlignSuper :: VerticalAlignValue Value
vAlignSuper = VerticalAlignValue "super"
A workaround is to use the "-:" combinator like so:
p ? do
"vertical-align" -: "super"
@sebastiaanvisser opinion on this? It's only a breaking change in users' types and it's a trivial fix.
Motivation: minimal pollution of namespace, idiomatic naming (other libraries with a central monad often use the library name), and it's not really a Css data structure until it gets rendered.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.