Spaces:
Running
Running
hugobarauna
commited on
Adds a spinner
Browse files
public-apps/smart_cells.livemd
CHANGED
@@ -12,6 +12,32 @@ Mix.install([
|
|
12 |
|
13 |
## Section
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
```elixir
|
16 |
defmodule GitHubAPI do
|
17 |
def headers(),
|
@@ -55,20 +81,29 @@ defmodule GitHubAPI do
|
|
55 |
end
|
56 |
```
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
```elixir
|
59 |
items = GitHubAPI.new() |> GitHubAPI.get_all()
|
60 |
nil
|
61 |
```
|
62 |
|
63 |
```elixir
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
|
|
|
|
|
|
72 |
```
|
73 |
|
74 |
-
<!-- livebook:{"offset":
|
|
|
12 |
|
13 |
## Section
|
14 |
|
15 |
+
```elixir
|
16 |
+
defmodule Kino.Spinner do
|
17 |
+
def new() do
|
18 |
+
Kino.HTML.new("""
|
19 |
+
<div class="loader"></div>
|
20 |
+
|
21 |
+
<style>
|
22 |
+
.loader {
|
23 |
+
border: 16px solid #f3f3f3; /* Light grey */
|
24 |
+
border-top: 16px solid #3498db; /* Blue */
|
25 |
+
border-radius: 50%;
|
26 |
+
width: 30px;
|
27 |
+
height: 30px;
|
28 |
+
animation: spin 2s linear infinite;
|
29 |
+
}
|
30 |
+
|
31 |
+
@keyframes spin {
|
32 |
+
0% { transform: rotate(0deg); }
|
33 |
+
100% { transform: rotate(360deg); }
|
34 |
+
}
|
35 |
+
</style>
|
36 |
+
""")
|
37 |
+
end
|
38 |
+
end
|
39 |
+
```
|
40 |
+
|
41 |
```elixir
|
42 |
defmodule GitHubAPI do
|
43 |
def headers(),
|
|
|
81 |
end
|
82 |
```
|
83 |
|
84 |
+
```elixir
|
85 |
+
frame = Kino.Frame.new() |> Kino.render()
|
86 |
+
|
87 |
+
Kino.Frame.append(frame, Kino.Spinner.new())
|
88 |
+
```
|
89 |
+
|
90 |
```elixir
|
91 |
items = GitHubAPI.new() |> GitHubAPI.get_all()
|
92 |
nil
|
93 |
```
|
94 |
|
95 |
```elixir
|
96 |
+
table =
|
97 |
+
for repo <- items, repo["repository"]["owner"]["login"] != "livebook-dev" do
|
98 |
+
%{
|
99 |
+
"Name" => repo["repository"]["name"],
|
100 |
+
"Description" => repo["repository"]["description"],
|
101 |
+
"URL" => repo["repository"]["html_url"]
|
102 |
+
}
|
103 |
+
end
|
104 |
+
|> Kino.DataTable.new(name: "Smart cells")
|
105 |
+
|
106 |
+
Kino.Frame.render(frame, table)
|
107 |
```
|
108 |
|
109 |
+
<!-- livebook:{"offset":2330,"stamp":{"token":"XCP.M4F9Mu9JmVN3zo1H252A6D_XZK0YF0q6oNOcG5Ddz3jQuIiKPSiqgM0qdcv3ETVMC5DzgJA0o9GSnps38eVzGwJNhy27ZAr3o9Junmz98dkNvYcBQAiJ","version":2}} -->
|