Labeled text block (#1117)

* Make labeled text a block

* Add link
This commit is contained in:
José Valim 2022-04-15 14:23:41 +02:00 committed by GitHub
parent bfd47fd166
commit f451646d73
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 17 deletions

View file

@ -345,7 +345,7 @@ defmodule LivebookWeb.LiveHelpers do
## Examples
<.labeled_text label="Name" text="Sherlock Holmes" />
<.labeled_text label="Name">Sherlock Holmes</.labeled_text>
"""
def labeled_text(assigns) do
assigns = assign_new(assigns, :one_line, fn -> false end)
@ -356,7 +356,7 @@ defmodule LivebookWeb.LiveHelpers do
<%= @label %>
</span>
<span class={"text-gray-800 text-sm font-semibold #{if @one_line, do: "whitespace-nowrap overflow-auto tiny-scrollbar"}"}>
<%= @text %>
<%= render_slot(@inner_block) %>
</span>
</div>
"""

View file

@ -427,7 +427,7 @@ defmodule LivebookWeb.SessionLive do
<div class="flex flex-col mt-2 space-y-4">
<div class="flex flex-col space-y-3">
<%= for {label, value} <- Runtime.describe(@data_view.runtime) do %>
<.labeled_text label={label} text={value} one_line={true} />
<.labeled_text label={label} one_line><%= value %></.labeled_text>
<% end %>
</div>
<div class="flex space-x-2">

View file

@ -51,19 +51,22 @@ defmodule LivebookWeb.SettingsLive do
<div class="flex items-center justify-between border border-gray-200 rounded-lg p-4">
<div class="flex items-center space-x-12">
<%= if app_name = Livebook.Config.app_service_name() do %>
<div class="flex flex-col space-y-1">
<span class="text-sm text-gray-500">Application</span>
<span class="text-gray-800 text-sm font-semibold">
<%= if app_url = Livebook.Config.app_service_url() do %>
<a href={app_url} target="_blank"><%= app_name %></a>
<% else %>
<.labeled_text label="Application">
<%= if app_url = Livebook.Config.app_service_url() do %>
<a href={app_url} class="underline hover:no-underline" target="_blank">
<%= app_name %>
<% end %>
</span>
</div>
</a>
<% else %>
<%= app_name %>
<% end %>
</.labeled_text>
<% end %>
<.labeled_text label="Livebook" text={"v#{Application.spec(:livebook, :vsn)}"} />
<.labeled_text label="Elixir" text={"v#{System.version()}"} />
<.labeled_text label="Livebook">
v<%= Application.spec(:livebook, :vsn) %>
</.labeled_text>
<.labeled_text label="Elixir">
v<%= System.version() %>
</.labeled_text>
</div>
<%= live_redirect to: Routes.live_dashboard_path(@socket, :home),

View file

@ -41,14 +41,14 @@ defmodule LivebookWeb.SettingsLive.FileSystemsComponent do
defp file_system_info(%{file_system: %FileSystem.Local{}} = assigns) do
~H"""
<.labeled_text label="Type" text="Local disk" />
<.labeled_text label="Type">Local disk</.labeled_text>
"""
end
defp file_system_info(%{file_system: %FileSystem.S3{}} = assigns) do
~H"""
<.labeled_text label="Type" text="S3" />
<.labeled_text label="Bucket URL" text={@file_system.bucket_url} />
<.labeled_text label="Type">S3</.labeled_text>
<.labeled_text label="Bucket URL"><%= @file_system.bucket_url %></.labeled_text>
"""
end
end