Skip to content

Commit 5a67443

Browse files
committed
Ops: Setup CI & testing
1 parent d8187c3 commit 5a67443

File tree

5 files changed

+70
-14
lines changed

5 files changed

+70
-14
lines changed

.github/workflows/ci.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
on: [push, pull_request]
2+
3+
jobs:
4+
test:
5+
runs-on: ubuntu-latest
6+
name: OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}}
7+
strategy:
8+
matrix:
9+
otp: ['26']
10+
elixir: ['1.16.0']
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: erlef/setup-beam@v1
14+
with:
15+
otp-version: ${{matrix.otp}}
16+
elixir-version: ${{matrix.elixir}}
17+
- run: mix deps.get
18+
- run: mix test

lib/daisy_ui.ex

+24-10
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,32 @@
11
defmodule DaisyUi do
2-
@moduledoc """
3-
Documentation for `DaisyUi`.
4-
"""
2+
@moduledoc ~S"""
3+
<p>
4+
An implementation of <a href="https://daisyui.com" target="blank">DaisyUI</a> for Phoenix LiveView.
5+
</p>
6+
7+
<p>
8+
All DaisyUi components accept the <code>class</code> attribute for customisations (and often the <code>classes</code> struct to address inner elements). <a href="https://tailwindcss.com/docs/installation" target="blank">TailwindCSS utility classes</a> allow a wide range of customisations without having to write custom styles.
9+
</p>
510
6-
@doc """
7-
Hello world.
11+
<p>
12+
DaisyUi components can be used in <a href="https://github.com/phoenixframework/phoenix_live_view" target="_blank">Phoenix LiveView pages</a> and regular (non-LiveView) views in Phoenix applications.
13+
</p>
814
9-
## Examples
15+
## Documentation
1016
11-
iex> DaisyUi.hello()
12-
:world
17+
- [Component documentation](`DaisyUi.Component`)
1318
19+
## Resources
20+
21+
- [DaisyUI Website](https://daisyui.com)
22+
- [DaisyUI Storybook and Demo](daisyui.luhagel.com)
23+
- [Source code](https://github.com/luhagel/daisy_ui)
1424
"""
15-
def hello do
16-
:world
25+
26+
defmacro __using__(_) do
27+
quote do
28+
import DaisyUi.Component
29+
alias DaisyUi.Theme
30+
end
1731
end
1832
end

test/components/label_test.exs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
defmodule Components.LabelTest do
2+
use ComponentCase
3+
4+
describe "label/1" do
5+
test "renders a label" do
6+
assigns = %{}
7+
8+
assert "<div class=\"label\">\n <span class=\"label-text\">E-Mail Address</span>\n</div>" =
9+
rendered_to_string(~H"<.label>E-Mail Address</.label>")
10+
end
11+
end
12+
end

test/daisy_ui_test.exs

-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
defmodule DaisyUiTest do
22
use ExUnit.Case
33
doctest DaisyUi
4-
5-
test "greets the world" do
6-
assert DaisyUi.hello() == :world
7-
end
84
end

test/support/component_case.ex

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
defmodule ComponentCase do
2+
@moduledoc """
3+
Base test case for DaisyUi components.
4+
"""
5+
6+
use ExUnit.CaseTemplate
7+
8+
using do
9+
quote do
10+
use DaisyUi
11+
12+
import Phoenix.Component
13+
import Phoenix.LiveViewTest
14+
end
15+
end
16+
end

0 commit comments

Comments
 (0)