Skip to content

Commit b8aa497

Browse files
tkoolenPietro Vertechi
authored and
Pietro Vertechi
committed
Fixes for 0.7 and add some basic tests (#6)
* Add some basic tests. Node -> node. * v0.7 compatibility * CI updates. * Address comments. * Address more comments.
1 parent b73d647 commit b8aa497

8 files changed

+70
-28
lines changed

.travis.yml

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
# Documentation: http://docs.travis-ci.com/user/languages/julia/
1+
## Documentation: http://docs.travis-ci.com/user/languages/julia/
22
language: julia
33
os:
44
- linux
55
- osx
66
julia:
7-
- release
7+
- 0.6
8+
- 0.7
9+
- 1.0
810
- nightly
11+
matrix:
12+
allow_failures:
13+
- julia: nightly
14+
branches:
15+
only:
16+
- master
17+
- /^v[0-9]+\.[0-9]+\.[0-9]+$/ # version tags
918
notifications:
1019
email: false
11-
# uncomment the following lines to override the default test script
12-
#script:
13-
# - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
14-
# - julia -e 'Pkg.clone(pwd()); Pkg.build("CSSUtil"); Pkg.test("CSSUtil"; coverage=true)'
1520
after_success:
16-
# push coverage results to Coveralls
17-
- julia -e 'cd(Pkg.dir("CSSUtil")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'
18-
# push coverage results to Codecov
19-
- julia -e 'cd(Pkg.dir("CSSUtil")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'
21+
- julia coverage.jl

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# CSSUtil
22

33
CSSUtil provides utilities to create and align
4-
various web elements on the DOM.
4+
various web elements on the DOM.
55

6-
## Example Usage
6+
## Example Usage
77
```julia
88
using WebIO
99
using CSSUtil
1010

11-
el1 = Node(:div, "Hello world!")
12-
el2 = Node(:div, "Goodbye world!")
11+
el1 = node(:div, "Hello world!")
12+
el2 = node(:div, "Goodbye world!")
1313

1414
el3 = hbox(el1, el2) # aligns horizontally
1515
el4 = hline() # draws horizontal line

REQUIRE

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
julia 0.6
2+
Compat 0.61.0 # for uppercasefirst
23
Measures
34
Colors
4-
WebIO
5+
WebIO 0.2.6 # for node
56
JSON

coverage.jl

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import Pkg
2+
Pkg.add("Coverage")
3+
using Coverage
4+
Codecov.submit(Codecov.process_folder())

src/CSSUtil.jl

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
module CSSUtil
22

3-
import Base: @md_str
3+
using Compat
4+
using Compat.Markdown
5+
6+
import Compat.Markdown: @md_str
47

58
export style, empty
69
export @md_str
710

811
using WebIO
912
using JSON
10-
import WebIO: render, Node
13+
import WebIO: render
1114

1215
using Measures
1316
using Colors
@@ -28,11 +31,11 @@ function style(elem, p::Pair...)
2831
render(elem)(style(p...))
2932
end
3033

31-
function style(::Void, arg::Pair...)
34+
function style(::Nothing, arg::Pair...)
3235
style(arg...)
3336
end
3437

35-
function style(::Void, arg::Dict)
38+
function style(::Nothing, arg::Dict)
3639
style(arg)
3740
end
3841

src/layout.jl

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ function flex(elem=nothing)
2323
style(elem, "display"=>"flex")
2424
end
2525

26-
function container(xs...)
26+
function container(xs::AbstractVector)
2727
dom"div"(xs...)
2828
end
2929

30+
container(xs...) = container([xs...])
31+
3032
"""
3133
hbox(el...)
3234

src/theme.jl

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export border, borderstyle, bordercolor, borderwidth, hline, vline,
33

44
function _border_prefix(side::Union{Symbol, String})
55
assertoneof(side, ["top", "bottom", "left", "right"], "side")
6-
"border$(ucfirst(side))"
6+
"border$(uppercasefirst(side))"
77
end
88

99
function assertstyle(style)
@@ -39,11 +39,11 @@ end
3939
"""
4040
hline()
4141
42-
Draw a horizonal line.
42+
Draw a horizonal line.
4343
4444
Keyword Arguments:
4545
=================
46-
- style: Indicates whether line should be solid or dotted.
46+
- style: Indicates whether line should be solid or dotted.
4747
Defaults to "solid"
4848
- w: Specifies line width. Defaults to 1px
4949
- color: specifies color in hex code RGB. Defaults to "#dedede".
@@ -55,11 +55,11 @@ end
5555
"""
5656
vline()
5757
58-
Draw a vertical line.
58+
Draw a vertical line.
5959
6060
Keyword Arguments:
6161
=================
62-
- style: Indicates whether line should be solid or dotted.
62+
- style: Indicates whether line should be solid or dotted.
6363
Defaults to "solid"
6464
- w: Specifies line width. Defaults to 1px
6565
- color: specifies color in hex code RGB. Defaults to "#dedede".

test/runtests.jl

+33-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,35 @@
11
using CSSUtil
2-
using Base.Test
2+
using WebIO
3+
using Compat.Test
34

4-
# write your own tests here
5-
@test 1 == 1
5+
@testset "hbox" begin
6+
el1 = node(:div, "Hello world!")
7+
el2 = node(:div, "Goodbye world!")
8+
box = hbox(el1, el2)
9+
@test props(box)[:style]["display"] == "flex"
10+
@test props(box)[:style]["flex-direction"] == "row"
11+
@test el1 children(box)
12+
@test el2 children(box)
13+
end
14+
15+
@testset "vbox" begin
16+
el1 = node(:div, "Hello world!")
17+
el2 = node(:div, "Goodbye world!")
18+
box = vbox(el1, el2)
19+
@test props(box)[:style]["display"] == "flex"
20+
@test props(box)[:style]["flex-direction"] == "column"
21+
@test el1 children(box)
22+
@test el2 children(box)
23+
end
24+
25+
@testset "hline" begin
26+
line = hline()
27+
@test haskey(props(line)[:style], "borderBottom")
28+
@test props(line)[:style]["align-self"] == "stretch"
29+
end
30+
31+
@testset "vline" begin
32+
line = vline()
33+
@test haskey(props(line)[:style], "borderLeft")
34+
@test props(line)[:style]["align-self"] == "stretch"
35+
end

0 commit comments

Comments
 (0)