Skip to content

Commit

Permalink
feat: Add new Home page to document page. (#9)
Browse files Browse the repository at this point in the history
* feat: Consider to build a page header.

* feat: Add new wc_page_header, wc_page_footer and home page.

* feat: Refactor home page.

* chore: Fix ci version.

* fix: Fix class attr to any, it can be binary, false or list.

* fix: Fix class attr to any, it can be binary, false or list.

---------

Co-authored-by: Jonathan Gao <gsmlg.com@gmail.com>
  • Loading branch information
gsmlg and GSMLG-BOT committed Mar 10, 2023
1 parent bed02c7 commit 9f813c7
Show file tree
Hide file tree
Showing 20 changed files with 533 additions and 77 deletions.
18 changes: 12 additions & 6 deletions .github/workflows/ci.yml
Expand Up @@ -12,18 +12,18 @@ jobs:
strategy:
matrix:
include:
- elixir: 1.12
otp: 24.1
- elixir: 1.13
otp: 24
lint: lint
- elixir: 1.14.0
otp: 25.0
- elixir: 1.14
otp: 25
lint: lint

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Set up Elixir
uses: erlef/setup-elixir@v1
Expand All @@ -32,7 +32,7 @@ jobs:
otp-version: ${{ matrix.otp }}

- name: Restore deps and _build cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
deps
Expand All @@ -43,10 +43,14 @@ jobs:
- name: Install dependencies
run: mix deps.get --only test
env:
MIX_ENV: test

- name: Check source code format
run: mix format --check-formatted
if: ${{ matrix.lint }}
env:
MIX_ENV: test

- name: Remove compiled application files
run: mix clean
Expand All @@ -65,3 +69,5 @@ jobs:

- name: Run tests
run: mix test
env:
MIX_ENV: test
6 changes: 6 additions & 0 deletions .github/workflows/test-and-release.yml
Expand Up @@ -46,10 +46,14 @@ jobs:
- name: Install dependencies
run: mix deps.get --only test
env:
MIX_ENV: test

- name: Check source code format
run: mix format --check-formatted
if: ${{ matrix.lint }}
env:
MIX_ENV: test

- name: Remove compiled application files
run: mix clean
Expand All @@ -68,6 +72,8 @@ jobs:

- name: Run tests
run: mix test
env:
MIX_ENV: test

release:
name: semantic release
Expand Down
4 changes: 4 additions & 0 deletions apps/phoenix_webcomponent/lib/phoenix_webcomponent.ex
Expand Up @@ -51,6 +51,8 @@ defmodule Phoenix.WebComponent do
alias Phoenix.WebComponent.Modal
alias Phoenix.WebComponent.Pagination
alias Phoenix.WebComponent.Table
alias Phoenix.WebComponent.PageHeader
alias Phoenix.WebComponent.PageFooter
end
end

Expand All @@ -77,6 +79,8 @@ defmodule Phoenix.WebComponent do
import Phoenix.WebComponent.Pagination
import Phoenix.WebComponent.Table
import Phoenix.WebComponent.Icons
import Phoenix.WebComponent.PageHeader
import Phoenix.WebComponent.PageFooter
end
end

Expand Down
Expand Up @@ -29,7 +29,7 @@ defmodule Phoenix.WebComponent.Actionbar do
"""
)

attr(:class, :string,
attr(:class, :any,
default: "",
doc: """
html attribute class
Expand Down
4 changes: 2 additions & 2 deletions apps/phoenix_webcomponent/lib/phoenix_webcomponent/appbar.ex
Expand Up @@ -36,7 +36,7 @@ defmodule Phoenix.WebComponent.Appbar do
"""
)

attr(:class, :string,
attr(:class, :any,
default: "",
doc: """
html attribute class
Expand Down Expand Up @@ -129,7 +129,7 @@ defmodule Phoenix.WebComponent.Appbar do
"""
)

attr(:class, :string,
attr(:class, :any,
default: "",
doc: """
html attribute class
Expand Down
Expand Up @@ -21,7 +21,7 @@ defmodule Phoenix.WebComponent.Breadcrumb do
"""
)

attr(:class, :string,
attr(:class, :any,
default: "",
doc: """
html attribute class
Expand Down
4 changes: 2 additions & 2 deletions apps/phoenix_webcomponent/lib/phoenix_webcomponent/card.ex
Expand Up @@ -30,7 +30,7 @@ defmodule Phoenix.WebComponent.Card do
"""
)

attr(:class, :string,
attr(:class, :any,
default: "",
doc: """
html attribute class
Expand All @@ -43,7 +43,7 @@ defmodule Phoenix.WebComponent.Card do
Render a card title.
"""
) do
attr(:class, :string, doc: "title class")
attr(:class, :any, doc: "title class")
end

def wc_card(assigns) do
Expand Down
4 changes: 2 additions & 2 deletions apps/phoenix_webcomponent/lib/phoenix_webcomponent/icons.ex
Expand Up @@ -42,7 +42,7 @@ defmodule Phoenix.WebComponent.Icons do
"""
)

attr(:class, :string,
attr(:class, :any,
default: "",
doc: """
html attribute class
Expand Down Expand Up @@ -119,7 +119,7 @@ defmodule Phoenix.WebComponent.Icons do
"""
)

attr(:class, :string,
attr(:class, :any,
default: "",
doc: """
html attribute class
Expand Down
Expand Up @@ -24,7 +24,7 @@ defmodule Phoenix.WebComponent.LeftMenu do
"""
)

attr(:class, :string,
attr(:class, :any,
default: "",
doc: """
html attribute class
Expand Down Expand Up @@ -103,7 +103,7 @@ defmodule Phoenix.WebComponent.LeftMenu do
"""
)

attr(:class, :string,
attr(:class, :any,
default: "",
doc: """
html attribute class
Expand Down
Expand Up @@ -32,7 +32,7 @@ defmodule Phoenix.WebComponent.Markdown do
"""
)

attr(:class, :string,
attr(:class, :any,
default: "",
doc: """
html attribute class
Expand Down
118 changes: 118 additions & 0 deletions apps/phoenix_webcomponent/lib/phoenix_webcomponent/page_footer.ex
@@ -0,0 +1,118 @@
defmodule Phoenix.WebComponent.PageFooter do
@moduledoc """
render Page footer
"""
use Phoenix.WebComponent, :html

@doc """
Generates a Page footer.
## Example
<.wc_page_footer>
<:section class="">
ABC
</:section>
<:copyright>
(^_^)
</:copyright>
</.wc_page_footer>
"""
@doc type: :component
attr(:id, :any,
default: false,
doc: """
html attribute id
"""
)

attr(:class, :any,
default: "",
doc: """
html attribute class
"""
)

slot(:section,
required: false,
doc: """
Page footer section
"""
) do
attr(:class, :string)
attr(:title, :string)
attr(:title_class, :string)
attr(:body_class, :string)
end

slot(:copyright,
required: false,
doc: """
Page footer right side copyright.
"""
) do
attr(:class, :string)
attr(:title, :string)
attr(:title_class, :string)
attr(:body_class, :string)
end

def wc_page_footer(assigns) do
~H"""
<footer class={[
"w-full min-h-fit",
"flex flex-col",
"py-20",
@class
]}>
<div class={[
"container mx-auto",
"flex flex-col",
]}>
<div class={[
"flex flex-row",
"justify-between items-start",
"w-full"
]}>
<div
:for={section <- @section}
class={[
"flex flex-col",
Map.get(section, :class, "")
]}
>
<%= if Map.get(section, :title, "") != "" do %>
<h4 class={["font-bold my-2", Map.get(section, :title_class, "")]}>
<%= Map.get(section, :title, "") %>
</h4>
<% end %>
<div class={["flex flex-col", Map.get(section, :body_class, "")]}>
<%= render_slot(section) %>
</div>
</div>
<div
:for={copyright <- @copyright}
class={[
"flex flex-col self-center",
Map.get(copyright, :class, "")
]}
>
<%= if Map.get(copyright, :title, "") != "" do %>
<h4 class={["font-bold my-2", Map.get(copyright, :title_class, "")]}>
<%= Map.get(copyright, :title, "") %>
</h4>
<% end %>
<div class={["flex flex-col", Map.get(copyright, :body_class, "")]}>
<%= render_slot(copyright) %>
</div>
</div>
</div>
</div>
</footer>
"""
end
end

0 comments on commit 9f813c7

Please sign in to comment.