defmodule MedicodeWeb.Storybook.ResultList do | |
use PhoenixStorybook.Story, :component | |
def function, do: &MedicodeWeb.Components.result_list/1 | |
@sample_rows [ | |
{ | |
0.0, | |
0.7, | |
" This 55-year-old man with known coronary artery disease comes for a follow-up visit today. " | |
}, | |
{ | |
0.8, | |
1.3, | |
"Last month he was admitted to our hospital with unstable angina. " | |
}, | |
{ | |
1.4, | |
2.0, | |
" He underwent heart catheterization on November 15th, 2007. " | |
}, | |
{ | |
2.1, | |
2.8, | |
"At that time he was found to have a tight 99% proxmost enosis, total occlusion and collateralization " | |
} | |
] | |
def variations do | |
[ | |
%Variation{ | |
id: :default, | |
attributes: %{ | |
rows: %Phoenix.LiveView.LiveStream{ | |
inserts: stream_inserts_for_sample_rows() | |
} | |
} | |
} | |
] | |
end | |
defp stream_inserts_for_sample_rows do | |
@sample_rows | |
|> Enum.with_index() | |
|> Enum.map(fn {{start_mark, end_mark, text}, index} -> | |
# `inserts` in %Phoenix.LiveView.LiveStream requires the following format: {index, at, item, limit} | |
# We don't need `at` or `limit` here. This helper aids in building up this data for us. | |
{ | |
index, | |
nil, | |
%{ | |
start_mark: start_mark, | |
end_mark: end_mark, | |
text: text | |
}, | |
nil | |
} | |
end) | |
end | |
end | |