From 155eabf7918308942f12e488972eeefad152793b Mon Sep 17 00:00:00 2001 From: Twan Koolen Date: Tue, 14 Aug 2018 11:12:07 -0400 Subject: [PATCH 1/5] Add some basic tests. Node -> node. --- README.md | 8 ++++---- REQUIRE | 1 + test/runtests.jl | 36 +++++++++++++++++++++++++++++++++--- 3 files changed, 38 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 8d36a73..87ceb30 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,15 @@ # CSSUtil CSSUtil provides utilities to create and align -various web elements on the DOM. +various web elements on the DOM. -## Example Usage +## Example Usage ```julia using WebIO using CSSUtil -el1 = Node(:div, "Hello world!") -el2 = Node(:div, "Goodbye world!") +el1 = node(:div, "Hello world!") +el2 = node(:div, "Goodbye world!") el3 = hbox(el1, el2) # aligns horizontally el4 = hline() # draws horizontal line diff --git a/REQUIRE b/REQUIRE index 67abb6c..d684f0b 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,4 +1,5 @@ julia 0.6 +Compat Measures Colors WebIO diff --git a/test/runtests.jl b/test/runtests.jl index d490f4b..5959842 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,5 +1,35 @@ using CSSUtil -using Base.Test +using WebIO +using Compat.Test -# write your own tests here -@test 1 == 1 +@testset "hbox" begin + el1 = node(:div, "Hello world!") + el2 = node(:div, "Goodbye world!") + box = hbox(el1, el2) + @test props(box)[:style]["display"] == "flex" + @test props(box)[:style]["flex-direction"] == "row" + @test el1 ∈ children(box)[1] + @test el2 ∈ children(box)[1] +end + +@testset "vbox" begin + el1 = node(:div, "Hello world!") + el2 = node(:div, "Goodbye world!") + box = vbox(el1, el2) + @test props(box)[:style]["display"] == "flex" + @test props(box)[:style]["flex-direction"] == "column" + @test el1 ∈ children(box)[1] + @test el2 ∈ children(box)[1] +end + +@testset "hline" begin + line = hline() + @test haskey(props(line)[:style], "borderBottom") + @test props(line)[:style]["align-self"] == "stretch" +end + +@testset "vline" begin + line = vline() + @test haskey(props(line)[:style], "borderLeft") + @test props(line)[:style]["align-self"] == "stretch" +end From d4c3e860a6300dc31a99a7205f194c6b8c3a5446 Mon Sep 17 00:00:00 2001 From: Twan Koolen Date: Tue, 14 Aug 2018 11:22:35 -0400 Subject: [PATCH 2/5] v0.7 compatibility --- README.md | 4 ++-- REQUIRE | 2 +- src/CSSUtil.jl | 16 +++++++++++++--- src/layout.jl | 2 +- src/theme.jl | 10 +++++----- test/runtests.jl | 15 +++++++++++---- 6 files changed, 33 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 87ceb30..bd23b45 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ various web elements on the DOM. using WebIO using CSSUtil -el1 = node(:div, "Hello world!") -el2 = node(:div, "Goodbye world!") +el1 = Node(:div, "Hello world!") +el2 = Node(:div, "Goodbye world!") el3 = hbox(el1, el2) # aligns horizontally el4 = hline() # draws horizontal line diff --git a/REQUIRE b/REQUIRE index d684f0b..26ed4ae 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,5 +1,5 @@ julia 0.6 -Compat +Compat 0.61.0 # for uppercasefirst Measures Colors WebIO diff --git a/src/CSSUtil.jl b/src/CSSUtil.jl index 6a115b5..5333c42 100644 --- a/src/CSSUtil.jl +++ b/src/CSSUtil.jl @@ -1,6 +1,9 @@ module CSSUtil -import Base: @md_str +using Compat +using Compat.Markdown + +import Compat.Markdown: @md_str export style, empty export @md_str @@ -9,6 +12,13 @@ using WebIO using JSON import WebIO: render, Node +if isdefined(WebIO, :node) # TODO: remove once a new WebIO tag is in + using WebIO: node +else + using WebIO: Node + const node = Node +end + using Measures using Colors @@ -28,11 +38,11 @@ function style(elem, p::Pair...) render(elem)(style(p...)) end -function style(::Void, arg::Pair...) +function style(::Nothing, arg::Pair...) style(arg...) end -function style(::Void, arg::Dict) +function style(::Nothing, arg::Dict) style(arg) end diff --git a/src/layout.jl b/src/layout.jl index 0c5d2ad..733e450 100644 --- a/src/layout.jl +++ b/src/layout.jl @@ -23,7 +23,7 @@ function flex(elem=nothing) style(elem, "display"=>"flex") end -function container(xs...) +function container(xs::AbstractVector) dom"div"(xs...) end diff --git a/src/theme.jl b/src/theme.jl index da11c01..919c099 100644 --- a/src/theme.jl +++ b/src/theme.jl @@ -3,7 +3,7 @@ export border, borderstyle, bordercolor, borderwidth, hline, vline, function _border_prefix(side::Union{Symbol, String}) assertoneof(side, ["top", "bottom", "left", "right"], "side") - "border$(ucfirst(side))" + "border$(uppercasefirst(side))" end function assertstyle(style) @@ -39,11 +39,11 @@ end """ hline() - Draw a horizonal line. + Draw a horizonal line. Keyword Arguments: ================= - - style: Indicates whether line should be solid or dotted. + - style: Indicates whether line should be solid or dotted. Defaults to "solid" - w: Specifies line width. Defaults to 1px - color: specifies color in hex code RGB. Defaults to "#dedede". @@ -55,11 +55,11 @@ end """ vline() - Draw a vertical line. + Draw a vertical line. Keyword Arguments: ================= - - style: Indicates whether line should be solid or dotted. + - style: Indicates whether line should be solid or dotted. Defaults to "solid" - w: Specifies line width. Defaults to 1px - color: specifies color in hex code RGB. Defaults to "#dedede". diff --git a/test/runtests.jl b/test/runtests.jl index 5959842..d5445a0 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -2,14 +2,21 @@ using CSSUtil using WebIO using Compat.Test +if isdefined(WebIO, :node) # TODO: remove once a new WebIO tag is in + using WebIO: node +else + using WebIO: Node + const node = Node +end + @testset "hbox" begin el1 = node(:div, "Hello world!") el2 = node(:div, "Goodbye world!") box = hbox(el1, el2) @test props(box)[:style]["display"] == "flex" @test props(box)[:style]["flex-direction"] == "row" - @test el1 ∈ children(box)[1] - @test el2 ∈ children(box)[1] + @test el1 ∈ children(box) + @test el2 ∈ children(box) end @testset "vbox" begin @@ -18,8 +25,8 @@ end box = vbox(el1, el2) @test props(box)[:style]["display"] == "flex" @test props(box)[:style]["flex-direction"] == "column" - @test el1 ∈ children(box)[1] - @test el2 ∈ children(box)[1] + @test el1 ∈ children(box) + @test el2 ∈ children(box) end @testset "hline" begin From 8a826be2b76911a9d7371454ac9106d58ee6adef Mon Sep 17 00:00:00 2001 From: Twan Koolen Date: Tue, 14 Aug 2018 11:30:53 -0400 Subject: [PATCH 3/5] CI updates. --- .travis.yml | 24 ++++++++++++++---------- coverage.jl | 4 ++++ 2 files changed, 18 insertions(+), 10 deletions(-) create mode 100644 coverage.jl diff --git a/.travis.yml b/.travis.yml index 49b8da2..58a4928 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,19 +1,23 @@ -# Documentation: http://docs.travis-ci.com/user/languages/julia/ + +## Documentation: http://docs.travis-ci.com/user/languages/julia/ language: julia os: - linux - osx julia: - - release + - 0.6 + - 0.7 + - 1.0 - nightly +matrix: + allow_failures: + - julia: nightly + - julia: 1.0 # for now +branches: + only: + - master + - /^v[0-9]+\.[0-9]+\.[0-9]+$/ # version tags notifications: email: false -# uncomment the following lines to override the default test script -#script: -# - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi -# - julia -e 'Pkg.clone(pwd()); Pkg.build("CSSUtil"); Pkg.test("CSSUtil"; coverage=true)' after_success: - # push coverage results to Coveralls - - julia -e 'cd(Pkg.dir("CSSUtil")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())' - # push coverage results to Codecov - - julia -e 'cd(Pkg.dir("CSSUtil")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())' +- julia coverage.jl diff --git a/coverage.jl b/coverage.jl new file mode 100644 index 0000000..825a059 --- /dev/null +++ b/coverage.jl @@ -0,0 +1,4 @@ +import Pkg +Pkg.add("Coverage") +using Coverage +Codecov.submit(Codecov.process_folder()) From 3ae9b11fb7b761eb3b89e9d915c7a064da746ec3 Mon Sep 17 00:00:00 2001 From: Twan Koolen Date: Wed, 15 Aug 2018 10:39:02 -0400 Subject: [PATCH 4/5] Address comments. --- REQUIRE | 2 +- src/CSSUtil.jl | 9 +-------- src/layout.jl | 2 ++ test/runtests.jl | 7 ------- 4 files changed, 4 insertions(+), 16 deletions(-) diff --git a/REQUIRE b/REQUIRE index 26ed4ae..8e568b7 100644 --- a/REQUIRE +++ b/REQUIRE @@ -2,5 +2,5 @@ julia 0.6 Compat 0.61.0 # for uppercasefirst Measures Colors -WebIO +WebIO 0.2.6 # for node JSON diff --git a/src/CSSUtil.jl b/src/CSSUtil.jl index 5333c42..5ea60a6 100644 --- a/src/CSSUtil.jl +++ b/src/CSSUtil.jl @@ -10,14 +10,7 @@ export @md_str using WebIO using JSON -import WebIO: render, Node - -if isdefined(WebIO, :node) # TODO: remove once a new WebIO tag is in - using WebIO: node -else - using WebIO: Node - const node = Node -end +import WebIO: render using Measures using Colors diff --git a/src/layout.jl b/src/layout.jl index 733e450..0f3e6cd 100644 --- a/src/layout.jl +++ b/src/layout.jl @@ -27,6 +27,8 @@ function container(xs::AbstractVector) dom"div"(xs...) end +container(xs...) = container([xs...]) + """ hbox(el...) diff --git a/test/runtests.jl b/test/runtests.jl index d5445a0..99323c0 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -2,13 +2,6 @@ using CSSUtil using WebIO using Compat.Test -if isdefined(WebIO, :node) # TODO: remove once a new WebIO tag is in - using WebIO: node -else - using WebIO: Node - const node = Node -end - @testset "hbox" begin el1 = node(:div, "Hello world!") el2 = node(:div, "Goodbye world!") From 60b405291065706a1590267e655cd251dee4ceae Mon Sep 17 00:00:00 2001 From: Twan Koolen Date: Wed, 15 Aug 2018 11:29:53 -0400 Subject: [PATCH 5/5] Address more comments. --- .travis.yml | 2 -- README.md | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 58a4928..647681d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,3 @@ - ## Documentation: http://docs.travis-ci.com/user/languages/julia/ language: julia os: @@ -12,7 +11,6 @@ julia: matrix: allow_failures: - julia: nightly - - julia: 1.0 # for now branches: only: - master diff --git a/README.md b/README.md index bd23b45..87ceb30 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ various web elements on the DOM. using WebIO using CSSUtil -el1 = Node(:div, "Hello world!") -el2 = Node(:div, "Goodbye world!") +el1 = node(:div, "Hello world!") +el2 = node(:div, "Goodbye world!") el3 = hbox(el1, el2) # aligns horizontally el4 = hline() # draws horizontal line