ash_hq/lib/ash_hq_web/components/right_nav.ex

62 lines
1.7 KiB
Elixir
Raw Normal View History

2022-04-01 05:36:44 +13:00
defmodule AshHqWeb.Components.RightNav do
@moduledoc "The right nav shown for functions in a module."
2022-04-01 05:36:44 +13:00
use Surface.Component
prop functions, :list, default: []
prop module, :string, required: true
2022-04-01 05:36:44 +13:00
def render(assigns) do
~F"""
<style>
a[aria-current] {
2023-01-31 03:21:42 +13:00
@apply text-primary-light-600 dark:text-primary-dark-400;
}
</style>
<div id="right-nav" class="scroll-parent hidden lg:flex flex-col pb-12" phx-hook="RightNav">
2023-01-31 07:53:34 +13:00
<a
id="right-nav-module-docs"
class="hover:text-primary-light-300 hover:dark:text-primary-dark-300 right-nav"
href="#module-docs"
>
2022-04-01 09:59:53 +13:00
{@module}
</a>
2022-09-16 10:35:33 +12:00
{#for %{type: :type} = function <- @functions}
2023-01-31 03:21:42 +13:00
<.nav_link function={function} />
2022-09-16 10:35:33 +12:00
{/for}
2022-04-01 14:29:58 +13:00
{#for %{type: :callback} = function <- @functions}
2023-01-31 03:21:42 +13:00
<.nav_link function={function} />
2022-04-01 14:29:58 +13:00
{/for}
{#for %{type: :function} = function <- @functions}
2023-01-31 03:21:42 +13:00
<.nav_link function={function} />
2022-04-01 14:29:58 +13:00
{/for}
{#for %{type: :macro} = function <- @functions}
2023-01-31 03:21:42 +13:00
<.nav_link function={function} />
2022-04-01 05:36:44 +13:00
{/for}
</div>
"""
end
2023-01-31 03:21:42 +13:00
def nav_link(assigns) do
~F"""
<style>
a[aria-current] {
@apply text-primary-light-600 dark:text-primary-dark-400;
}
</style>
<a
id={"right-nav-#{@function.type}-#{@function.sanitized_name}-#{@function.arity}"}
class="hover:text-primary-light-300 hover:dark:text-primary-dark-300 right-nav"
href={"##{@function.type}-#{@function.sanitized_name}-#{@function.arity}"}
>
{"#{@function.name}/#{@function.arity}"}
{#if @function.deprecated}
<span class="text-xs italic text-yellow-500 dark:text-yellow-400">deprecated</span>
{/if}
2023-01-31 03:21:42 +13:00
</a>
"""
end
2022-04-01 05:36:44 +13:00
end