Packages
evision
0.1.27
1.0.1-rc.0
1.0.0
1.0.0-rc.0
0.2.17
0.2.17-rc2
0.2.17-rc1
0.2.16
0.2.16-pre.2
0.2.16-pre
0.2.15
0.2.14
0.2.13
0.2.12
0.2.11
0.2.9
0.2.8
0.2.7
0.2.6
0.2.5
0.2.4
0.2.3
0.2.2
0.2.2-rc2
0.2.1
0.2.0
0.1.39
0.1.38
0.1.37
0.1.36
0.1.35
0.1.34
0.1.33
0.1.32
retired
0.1.31
0.1.30
0.1.29
0.1.28
0.1.27
0.1.26
0.1.26-rc3
0.1.26-rc2
0.1.26-rc1
0.1.26-rc0
0.1.25
0.1.24
0.1.23
0.1.22
0.1.21
0.1.20
0.1.19
0.1.18
0.1.17
0.1.16
0.1.15
0.1.14
0.1.13
0.1.12
0.1.11
0.1.10
0.1.9
0.1.8
0.1.7
OpenCV-Erlang/Elixir binding.
Current section
Files
Jump to
Current section
Files
lib/smartcell/simple_list.ex
if !Code.ensure_loaded?(Kino.SmartCell) do
defmodule Evision.SmartCell.SimpleList do
end
else
defmodule Evision.SmartCell.SimpleList do
# code taken from
# https://github.com/livebook-dev/kino_bumblebee/blob/main/lib/kino/bumblebee/scored_list.ex
@moduledoc """
A kino for displaying a list of labels.
This kino is primarily used to present top classification predictions.
## Examples
predictions = [
"malamute",
"Siberian husky",
"Eskimo dog",
"Tibetan mastiff",
"German shepherd"
]
Evision.SmartCell.SimpleList.new(predictions)
"""
use Kino.JS
@type t :: Kino.JS.t()
@doc """
Creates a new kino displaying the given list of items.
Expects a list of tuples, each element being the label and its score.
"""
@spec new(list({String.t(), number()})) :: t()
def new(items) when is_list(items) do
Kino.JS.new(__MODULE__, items)
end
asset "main.js" do
"""
export function init(ctx, items) {
ctx.importCSS("main.css");
ctx.importCSS(
"https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap"
);
ctx.root.innerHTML = `
<div class="app">
<ol class="list">
${items.map((item) => (`
<li class="item">
<div class="label">
<div>${item}</div>
</div>
</li>
`)).join("")}
</ol>
</div>
`;
}
"""
end
asset "main.css" do
"""
.app {
font-family: "JetBrains Mono", monospace;
font-size: 14px;
color: #8BA2FF;
}
.list {
padding: 0;
margin: 0;
}
.item {
display: flex;
justify-content: space-between;
}
.item:not(:first-child) {
margin-top: 16px;
}
.label {
flex-grow: 1;
margin-right: 8px;
}
"""
end
end
end