Add comments
This commit is contained in:
parent
8ea17ecd82
commit
61302f2183
2 changed files with 14 additions and 3 deletions
|
@ -1,4 +1,6 @@
|
|||
//// A view to the library, presenting artists, albums, or tracks.
|
||||
//// A view to the library, presenting artists, albums, or tracks. This
|
||||
//// component cannot be used directly, this should be extended by the actual
|
||||
//// components that focus on a specific type of view to the library.
|
||||
|
||||
import gleam/dynamic
|
||||
import gleam/list
|
||||
|
@ -15,17 +17,20 @@ import elekf/library/artist.{Artist}
|
|||
import elekf/library/track.{Track}
|
||||
import elekf/web/events/start_play
|
||||
|
||||
pub const start_play_event = "start-play"
|
||||
|
||||
/// An item in the library with its ID.
|
||||
pub type LibraryItem(a) =
|
||||
#(Int, a)
|
||||
|
||||
/// Function to get the data of the view from the library.
|
||||
pub type DataGetter(a) =
|
||||
fn(Library) -> List(LibraryItem(a))
|
||||
|
||||
/// A view that renders a single item from the library.
|
||||
pub type ItemView(a) =
|
||||
fn(Library, List(LibraryItem(a)), Int, LibraryItem(a)) -> element.Element(Msg)
|
||||
|
||||
/// Shuffler takes all of the items, finds all of the tracks in them, and
|
||||
/// shuffles them for playback.
|
||||
pub type Shuffler(a) =
|
||||
fn(List(LibraryItem(a))) -> List(LibraryItem(Track))
|
||||
|
||||
|
@ -59,6 +64,7 @@ pub type Model(a) {
|
|||
)
|
||||
}
|
||||
|
||||
/// Register the component as a custom element in the app.
|
||||
pub fn register(
|
||||
name: String,
|
||||
data_getter: DataGetter(a),
|
||||
|
@ -74,6 +80,7 @@ pub fn register(
|
|||
)
|
||||
}
|
||||
|
||||
/// Render the component using a custom element.
|
||||
pub fn render(name: String, library: Library) {
|
||||
element.element(name, [attribute.property("library", library)], [])
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//// A library view to all of the tracks in the library.
|
||||
|
||||
import gleam/int
|
||||
import gleam/list
|
||||
import gleam/map
|
||||
|
@ -11,10 +13,12 @@ import elekf/web/components/library_view.{LibraryItem, StartPlay}
|
|||
|
||||
const component_name = "tracks-view"
|
||||
|
||||
/// Register the tracks view as a custom element.
|
||||
pub fn register() {
|
||||
library_view.register(component_name, data_getter, item_view, shuffler)
|
||||
}
|
||||
|
||||
/// Render the tracks view.
|
||||
pub fn render(library: Library) {
|
||||
library_view.render(component_name, library)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue