Commit
•
7fc32c8
1
Parent(s):
2893bb5
docs: `result_heading` doc, attributes, and story
Browse files
lib/medical_transcription_web/components/components.ex
CHANGED
@@ -64,6 +64,13 @@ defmodule MedicalTranscriptionWeb.Components do
|
|
64 |
"""
|
65 |
end
|
66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
def result_heading(assigns) do
|
68 |
if Enum.member?([:loading, :streaming_audio, :success], assigns.status) do
|
69 |
~H"""
|
@@ -117,7 +124,8 @@ defmodule MedicalTranscriptionWeb.Components do
|
|
117 |
end
|
118 |
end
|
119 |
|
120 |
-
|
|
|
121 |
~H"""
|
122 |
<button phx-click="toggle_recording" class="mr-6 px-4 py-3 bg-red-200 rounded-lg">
|
123 |
<.icon name="hero-microphone" class="animate-pulse" />
|
@@ -125,7 +133,7 @@ defmodule MedicalTranscriptionWeb.Components do
|
|
125 |
"""
|
126 |
end
|
127 |
|
128 |
-
|
129 |
~H"""
|
130 |
<button phx-click="toggle_recording" class="mr-6 px-4 py-3 bg-emerald-200 rounded-lg">
|
131 |
<.icon name="hero-microphone" />
|
@@ -133,7 +141,8 @@ defmodule MedicalTranscriptionWeb.Components do
|
|
133 |
"""
|
134 |
end
|
135 |
|
136 |
-
|
|
|
137 |
keyword_predictions
|
138 |
|> List.flatten()
|
139 |
|> Enum.sort_by(& &1.score, :desc)
|
|
|
64 |
"""
|
65 |
end
|
66 |
|
67 |
+
attr :status, :atom, required: true
|
68 |
+
attr :filename, :string, default: nil
|
69 |
+
attr :summary_keywords, :list, default: []
|
70 |
+
|
71 |
+
@doc """
|
72 |
+
Shows the status and keywords for the current session.
|
73 |
+
"""
|
74 |
def result_heading(assigns) do
|
75 |
if Enum.member?([:loading, :streaming_audio, :success], assigns.status) do
|
76 |
~H"""
|
|
|
124 |
end
|
125 |
end
|
126 |
|
127 |
+
# Renders the record button within the result_heading component
|
128 |
+
defp record_button_in_heading(assigns) when assigns.status == :streaming_audio do
|
129 |
~H"""
|
130 |
<button phx-click="toggle_recording" class="mr-6 px-4 py-3 bg-red-200 rounded-lg">
|
131 |
<.icon name="hero-microphone" class="animate-pulse" />
|
|
|
133 |
"""
|
134 |
end
|
135 |
|
136 |
+
defp record_button_in_heading(assigns) do
|
137 |
~H"""
|
138 |
<button phx-click="toggle_recording" class="mr-6 px-4 py-3 bg-emerald-200 rounded-lg">
|
139 |
<.icon name="hero-microphone" />
|
|
|
141 |
"""
|
142 |
end
|
143 |
|
144 |
+
# Formats keywords for display in the result_heading component
|
145 |
+
defp format_keywords(keyword_predictions) do
|
146 |
keyword_predictions
|
147 |
|> List.flatten()
|
148 |
|> Enum.sort_by(& &1.score, :desc)
|
storybook/components/result_heading.story.exs
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
defmodule MedicalTranscriptionWeb.Storybook.ResultHeading do
|
2 |
+
use PhoenixStorybook.Story, :component
|
3 |
+
|
4 |
+
def function, do: &MedicalTranscriptionWeb.Components.result_heading/1
|
5 |
+
|
6 |
+
def variations do
|
7 |
+
[
|
8 |
+
%Variation{
|
9 |
+
id: :loading,
|
10 |
+
attributes: %{
|
11 |
+
status: :loading,
|
12 |
+
filename: "uploaded_audio.mp3"
|
13 |
+
}
|
14 |
+
},
|
15 |
+
%Variation{
|
16 |
+
id: :streaming_audio,
|
17 |
+
attributes: %{
|
18 |
+
status: :streaming_audio,
|
19 |
+
summary_keywords: [
|
20 |
+
%{score: 1.0, label: "heart"},
|
21 |
+
%{score: 0.9, label: "patient"},
|
22 |
+
%{score: 0.88, label: "diagnosis"}
|
23 |
+
]
|
24 |
+
}
|
25 |
+
},
|
26 |
+
%Variation{
|
27 |
+
id: :success,
|
28 |
+
attributes: %{
|
29 |
+
status: :success,
|
30 |
+
filename: "uploaded_audio.mp3",
|
31 |
+
summary_keywords: [
|
32 |
+
%{score: 1.0, label: "heart"},
|
33 |
+
%{score: 0.9, label: "patient"},
|
34 |
+
%{score: 0.88, label: "diagnosis"}
|
35 |
+
]
|
36 |
+
}
|
37 |
+
}
|
38 |
+
]
|
39 |
+
end
|
40 |
+
end
|