diff --git a/src/Css/Styles.elm b/src/Css/Styles.elm index cf0cca4b..764c6a2f 100644 --- a/src/Css/Styles.elm +++ b/src/Css/Styles.elm @@ -129,7 +129,8 @@ stylesLocal = ] , class InsulationContent [ flex (int 1) - , overflow scroll + , overflowX hidden + , overflowY auto ] ------------------------------------------------------ diff --git a/src/Css/Tracks/Styles.elm b/src/Css/Tracks/Styles.elm index d2a44ef1..f5979825 100644 --- a/src/Css/Tracks/Styles.elm +++ b/src/Css/Tracks/Styles.elm @@ -30,7 +30,8 @@ styles = ] , class TracksChild [ flex (int 1) - , overflow scroll + , overflowX hidden + , overflowY scroll , property "user-select" "none" , position relative , zIndex (int 2) -- 2.51.2 From 58e1528cc7dfdd900802ea400167e8e929927e91 Mon Sep 17 00:00:00 2001 From: Steven Vandevelde Date: Mon, 17 Jul 2017 13:57:44 +0200 Subject: [PATCH 2/5] Add extra info about CORS and do some light refactoring --- src/App/Sources/State.elm | 2 +- src/App/Sources/View.elm | 10 +++ src/App/Tracks/View.elm | 127 ++++++++++++++++++++++---------------- src/Css/Styles.elm | 7 +++ 4 files changed, 92 insertions(+), 54 deletions(-) diff --git a/src/App/Sources/State.elm b/src/App/Sources/State.elm index 4067af2e..e89adc35 100644 --- a/src/App/Sources/State.elm +++ b/src/App/Sources/State.elm @@ -236,7 +236,7 @@ update msg model = ($) { model | collection = newCollection - , newSource = makeSource AmazonS3 AmazonS3.initialData + , newSource = makeSource Ipfs Ipfs.initialData } [] [ do TopLevel.ProcessSources diff --git a/src/App/Sources/View.elm b/src/App/Sources/View.elm index b3b2f86a..b26b316e 100644 --- a/src/App/Sources/View.elm +++ b/src/App/Sources/View.elm @@ -228,6 +228,16 @@ pageNewForm newSource = Make sure CORS is enabled for IPFS and Amazon S3 repositories. """ ] + , br + [] + [] + , text "You can find the instructions over " + , a + [ href "https://gist.github.com/icidasset/c1883d594574a958ae4b4a5a91db1070#cors" + , target "blank" + ] + [ text "here" ] + , text "." ] -- Select the type of the source diff --git a/src/App/Tracks/View.elm b/src/App/Tracks/View.elm index bace07f6..013a2396 100644 --- a/src/App/Tracks/View.elm +++ b/src/App/Tracks/View.elm @@ -164,28 +164,30 @@ tracksTable tracks activeSortBy sortDirection = (Color.rgb 207 207 207) 16 in - table - [ cssClass TracksTable ] - [ thead - [] - [ th - [ style [ ( "width", "4.50%" ) ] ] + table + [ cssClass TracksTable ] + [ thead [] - , th - [ style [ ( "width", "37.5%" ) ], onClick (sortBy Title) ] - [ text "Title", maybeShowSortIcon activeSortBy Title sortIcon ] - , th - [ style [ ( "width", "29.0%" ) ], onClick (sortBy Artist) ] - [ text "Artist", maybeShowSortIcon activeSortBy Artist sortIcon ] - , th - [ style [ ( "width", "29.0%" ) ], onClick (sortBy Album) ] - [ text "Album", maybeShowSortIcon activeSortBy Album sortIcon ] + [ th + [ style [ ( "width", "4.50%" ) ] ] + [] + , th + [ style [ ( "width", "37.5%" ) ], onClick (sortBy Title) ] + [ text "Title", maybeShowSortIcon activeSortBy Title sortIcon ] + , th + [ style [ ( "width", "29.0%" ) ], onClick (sortBy Artist) ] + [ text "Artist", maybeShowSortIcon activeSortBy Artist sortIcon ] + , th + [ style [ ( "width", "29.0%" ) ], onClick (sortBy Album) ] + [ text "Album", maybeShowSortIcon activeSortBy Album sortIcon ] + ] + , Html.Keyed.node + "tbody" + [ on "dblclick" playTrack + , on "click" toggleFavourite + ] + (List.indexedMap tracksTableItem tracks) ] - , Html.Keyed.node - "tbody" - [ on "dblclick" playTrack, on "click" toggleFavourite ] - (List.indexedMap tracksTableItem tracks) - ] tracksTableItem : Int -> IdentifiedTrack -> ( String, Html TopLevel.Msg ) @@ -194,22 +196,22 @@ tracksTableItem index ( identifiers, track ) = key = toString index in - ( key - , tr - [ rel key - , attribute "data-missing" (boolToAttr identifiers.isMissing) - , attribute "data-nowplaying" (boolToAttr identifiers.isNowPlaying) - ] - [ td [ attribute "data-favourite" (boolToAttr identifiers.isFavourite) ] [] - , td [] [ text track.tags.title ] - , td [] [ text track.tags.artist ] - , td [] [ text track.tags.album ] - ] - ) + ( key + , tr + [ rel key + , attribute "data-missing" (boolToAttr identifiers.isMissing) + , attribute "data-nowplaying" (boolToAttr identifiers.isNowPlaying) + ] + [ td [ attribute "data-favourite" (boolToAttr identifiers.isFavourite) ] [] + , td [] [ text track.tags.title ] + , td [] [ text track.tags.artist ] + , td [] [ text track.tags.album ] + ] + ) --- Events and stuff +-- Events {1} playTrack : Decode.Decoder TopLevel.Msg @@ -219,26 +221,23 @@ playTrack = tableTrackDecoder : Decode.Decoder String tableTrackDecoder = - Decode.oneOf - [ Decode.at [ "target", "parentNode", "attributes", "data-missing", "value" ] Decode.string - , Decode.at [ "target", "attributes", "data-missing", "value" ] Decode.string - ] - |> Decode.andThen - (\isMissing -> - case isMissing of - "f" -> - Decode.oneOf - [ Decode.at - [ "target", "parentNode", "attributes", "rel", "value" ] - Decode.string - , Decode.at - [ "target", "attributes", "rel", "value" ] - Decode.string - ] - - _ -> - Decode.fail "Can't play a missing track" - ) + Decode.andThen + (\isMissing -> + case isMissing of + "f" -> + Decode.oneOf + [ Decode.at + [ "target", "parentNode", "attributes", "rel", "value" ] + Decode.string + , Decode.at + [ "target", "attributes", "rel", "value" ] + Decode.string + ] + + _ -> + Decode.fail "Can't play a missing track" + ) + missingTrackDecoder toggleFavourite : Decode.Decoder TopLevel.Msg @@ -258,6 +257,28 @@ tableFavouriteDecoder = ) +showContextMenu : Decode.Decoder TopLevel.Msg +showContextMenu = + Decode.map TopLevel.PlayTrack tableTrackDecoder + + +tableContextDecoder : Decode.Decoder String +tableContextDecoder = + Decode.succeed "TODO" + + + +-- Events {2} + + +missingTrackDecoder : Decode.Decoder String +missingTrackDecoder = + Decode.oneOf + [ Decode.at [ "target", "parentNode", "attributes", "data-missing", "value" ] Decode.string + , Decode.at [ "target", "attributes", "data-missing", "value" ] Decode.string + ] + + sortBy : SortBy -> TopLevel.Msg sortBy = TopLevel.TracksMsg << SortBy diff --git a/src/Css/Styles.elm b/src/Css/Styles.elm index 764c6a2f..615973ad 100644 --- a/src/Css/Styles.elm +++ b/src/Css/Styles.elm @@ -193,6 +193,13 @@ stylesLocal = , lineHeight (num 1.55) , marginBottom (gr 6) , opacity (num 0.475) + + -- + , descendants + [ a + [ borderBottom3 (px 2) solid (cssColor colors.base0A) + ] + ] ] ------------------------------------------------------ -- 2.51.2 From 7a1e63693dadd18bc9c8c29673246dbeac5a3d66 Mon Sep 17 00:00:00 2001 From: Steven Vandevelde Date: Mon, 17 Jul 2017 21:00:18 +0200 Subject: [PATCH 3/5] Add context menu --- elm-package.json | 7 +-- src/App/Queue/State.elm | 15 ++++-- src/App/State.elm | 24 +++++++++ src/App/Tracks/ContextMenu.elm | 26 ++++++++++ src/App/Tracks/State.elm | 36 ++++++------- src/App/Tracks/Types.elm | 3 +- src/App/Tracks/View.elm | 93 ++++++++++++++++++++-------------- src/App/Types.elm | 43 ++++++++++++++-- src/App/View.elm | 51 ++++++++++++++++++- src/Css/ContextMenu/Styles.elm | 43 ++++++++++++++++ src/Css/Styles.elm | 19 +++++++ 11 files changed, 289 insertions(+), 71 deletions(-) create mode 100644 src/App/Tracks/ContextMenu.elm create mode 100644 src/Css/ContextMenu/Styles.elm diff --git a/elm-package.json b/elm-package.json index 7819e963..8913a108 100644 --- a/elm-package.json +++ b/elm-package.json @@ -19,6 +19,7 @@ "elm-lang/dom": "1.1.1 <= v < 2.0.0", "elm-lang/html": "2.0.0 <= v < 3.0.0", "elm-lang/http": "1.0.0 <= v < 2.0.0", + "elm-lang/mouse": "1.0.1 <= v < 2.0.0", "elm-lang/navigation": "2.1.0 <= v < 3.0.0", "elm-lang/svg": "2.0.0 <= v < 3.0.0", "eskimoblood/elm-color-extra": "5.0.0 <= v < 6.0.0", @@ -31,9 +32,9 @@ "rtfeldman/elm-css-util": "1.0.2 <= v < 2.0.0", "rtfeldman/hex": "1.0.0 <= v < 2.0.0", "scottcorgan/elm-css-normalize": "1.1.7 <= v < 2.0.0", - "spisemisu/elm-sha": "1.0.5 <= v < 2.0.0", - "spisemisu/elm-utf8": "1.0.1 <= v < 2.0.0", - "truqu/elm-base64": "1.0.5 <= v < 2.0.0" + "spisemisu/elm-sha": "1.0.5 <= v < 1.0.6", + "spisemisu/elm-utf8": "1.0.1 <= v < 1.0.2", + "truqu/elm-base64": "1.0.5 <= v < 1.0.6" }, "elm-version": "0.18.0 <= v < 0.19.0" } diff --git a/src/App/Queue/State.elm b/src/App/Queue/State.elm index ad249395..0ee6497b 100644 --- a/src/App/Queue/State.elm +++ b/src/App/Queue/State.elm @@ -62,15 +62,20 @@ update msg model = { manualEntry = True , track = track } + + manualItems = + model.future + |> List.filter (.manualEntry >> (==) True) + |> List.length in (!) { model | future = - model.future - |> List.findIndex (.manualEntry >> (==) True) - |> Maybe.map (\idx -> List.setAt idx item model.future) - |> Maybe.map (Maybe.withDefault model.future) - |> Maybe.withDefault model.future + List.concat + [ List.take manualItems model.future + , [ item ] + , List.drop manualItems model.future + ] } [] diff --git a/src/App/State.elm b/src/App/State.elm index 05782536..ab266611 100644 --- a/src/App/State.elm +++ b/src/App/State.elm @@ -26,6 +26,7 @@ import Queue.Ports import Queue.Types import Queue.Utils import Sources.Types +import Tracks.ContextMenu import Tracks.Types import Tracks.Utils @@ -36,6 +37,7 @@ import Tracks.Utils initialModel : ProgramFlags -> Navigation.Location -> Model initialModel flags location = { authenticatedUser = flags.user + , contextMenu = Nothing , showLoadingScreen = True ------------------------------------ @@ -81,6 +83,11 @@ update msg model = model [ Users.Auth.authenticate () ] + ClickAway -> + (!) + { model | contextMenu = Nothing } + [] + HideLoadingScreen -> (!) { model | showLoadingScreen = False } @@ -218,6 +225,23 @@ update msg model = |> do ] + ShowTrackContextMenu ( index, mousePos ) -> + let + maybeIdentifiedTrack = + index + |> String.toInt + |> Result.toMaybe + |> Maybe.andThen (\idx -> List.getAt idx model.tracks.collection.exposed) + + contextMenu = + maybeIdentifiedTrack + |> Maybe.map Tracks.ContextMenu.build + |> Maybe.map (\fn -> fn mousePos) + in + (!) + { model | contextMenu = contextMenu } + [] + ToggleFavourite index -> (!) model diff --git a/src/App/Tracks/ContextMenu.elm b/src/App/Tracks/ContextMenu.elm new file mode 100644 index 00000000..9c55c0fb --- /dev/null +++ b/src/App/Tracks/ContextMenu.elm @@ -0,0 +1,26 @@ +module Tracks.ContextMenu exposing (build) + +import Color +import Material.Icons.Av as Icons +import Mouse +import Queue.Types +import Tracks.Types exposing (..) +import Types exposing (..) + + +build : IdentifiedTrack -> (Mouse.Position -> ContextMenu) +build identifiedTrack = + let + track = + Tuple.second identifiedTrack + in + ContextMenu + [ ( Icons.queue_play_next (Color.rgb 0 0 0) 16 + , "Play next" + , QueueMsg (Queue.Types.InjectFirst track) + ) + , ( Icons.add_to_queue (Color.rgb 0 0 0) 16 + , "Add to queue" + , QueueMsg (Queue.Types.InjectLast track) + ) + ] diff --git a/src/App/Tracks/State.elm b/src/App/Tracks/State.elm index 4133a9c0..a5f7c6ef 100644 --- a/src/App/Tracks/State.elm +++ b/src/App/Tracks/State.elm @@ -201,6 +201,25 @@ update msg model = ------------------------------------ -- UI ------------------------------------ + -- Identify the active track + -- + IdentifyActiveTrack maybeTrack -> + let + mapFn = + case maybeTrack of + Just track -> + \( i, t ) -> ( { i | isNowPlaying = t == track }, t ) + + Nothing -> + \( i, t ) -> ( { i | isNowPlaying = False }, t ) + in + model + |> Collection.makeParcel + |> Collection.remap (List.map mapFn) + |> Collection.set + + -- Table-scroll event handler + -- ScrollThroughTable { scrolledHeight, contentHeight, containerHeight } -> case scrolledHeight >= (contentHeight - containerHeight - 50) of True -> @@ -220,23 +239,6 @@ update msg model = |> Maybe.map (scrollToIndex model) |> Maybe.withDefault (Response.withNone model) - -- Identify the active track - -- - IdentifyActiveTrack maybeTrack -> - let - mapFn = - case maybeTrack of - Just track -> - \( i, t ) -> ( { i | isNowPlaying = t == track }, t ) - - Nothing -> - \( i, t ) -> ( { i | isNowPlaying = False }, t ) - in - model - |> Collection.makeParcel - |> Collection.remap (List.map mapFn) - |> Collection.set - -- 🔥 / Functions diff --git a/src/App/Tracks/Types.elm b/src/App/Tracks/Types.elm index 333c7d86..1a4ec888 100644 --- a/src/App/Tracks/Types.elm +++ b/src/App/Tracks/Types.elm @@ -2,6 +2,7 @@ module Tracks.Types exposing (..) import Base64 import Json.Encode as Json +import Mouse import Regex exposing (HowMany(..), regex) @@ -133,9 +134,9 @@ type Msg | ToggleFavourite String | ToggleFavouritesOnly -- UI + | IdentifyActiveTrack (Maybe Track) | ScrollThroughTable ScrollPos | ScrollToActiveTrack Track - | IdentifyActiveTrack (Maybe Track) diff --git a/src/App/Tracks/View.elm b/src/App/Tracks/View.elm index 013a2396..fbf0d5ed 100644 --- a/src/App/Tracks/View.elm +++ b/src/App/Tracks/View.elm @@ -3,7 +3,7 @@ module Tracks.View exposing (entry) import Color import Html exposing (..) import Html.Attributes exposing (..) -import Html.Events exposing (on, onBlur, onClick, onInput, onSubmit) +import Html.Events exposing (on, onBlur, onClick, onInput, onSubmit, onWithOptions) import Html.Keyed import Html.Lazy exposing (lazy, lazy2, lazy3) import Json.Decode as Decode @@ -12,6 +12,7 @@ import Material.Icons.Av import Material.Icons.Content import Material.Icons.Navigation import Material.Icons.Toggle +import Mouse import Navigation.View as Navigation import Sources.Types exposing (IsProcessing, Source) import Styles exposing (Classes(Button, ContentBox)) @@ -185,6 +186,12 @@ tracksTable tracks activeSortBy sortDirection = "tbody" [ on "dblclick" playTrack , on "click" toggleFavourite + , onWithOptions + "contextmenu" + { stopPropagation = True + , preventDefault = True + } + showContextMenu ] (List.indexedMap tracksTableItem tracks) ] @@ -216,69 +223,79 @@ tracksTableItem index ( identifiers, track ) = playTrack : Decode.Decoder TopLevel.Msg playTrack = - Decode.map TopLevel.PlayTrack tableTrackDecoder + Decode.map TopLevel.PlayTrack playTrackDecoder -tableTrackDecoder : Decode.Decoder String -tableTrackDecoder = - Decode.andThen - (\isMissing -> - case isMissing of - "f" -> - Decode.oneOf - [ Decode.at - [ "target", "parentNode", "attributes", "rel", "value" ] - Decode.string - , Decode.at - [ "target", "attributes", "rel", "value" ] - Decode.string - ] - - _ -> - Decode.fail "Can't play a missing track" - ) - missingTrackDecoder +playTrackDecoder : Decode.Decoder String +playTrackDecoder = + presentTrackDecoder + |> Decode.andThen (always trackRelDecoder) toggleFavourite : Decode.Decoder TopLevel.Msg toggleFavourite = - Decode.map TopLevel.ToggleFavourite tableFavouriteDecoder + Decode.map TopLevel.ToggleFavourite toggleFavouriteDecoder -tableFavouriteDecoder : Decode.Decoder String -tableFavouriteDecoder = +toggleFavouriteDecoder : Decode.Decoder String +toggleFavouriteDecoder = Decode.string |> Decode.at [ "target", "attributes", "data-favourite", "value" ] - |> Decode.andThen - (\_ -> - Decode.at - [ "target", "parentNode", "attributes", "rel", "value" ] - Decode.string - ) + |> Decode.andThen (always trackRelDecoder) showContextMenu : Decode.Decoder TopLevel.Msg showContextMenu = - Decode.map TopLevel.PlayTrack tableTrackDecoder + Decode.map TopLevel.ShowTrackContextMenu showContextMenuDecoder -tableContextDecoder : Decode.Decoder String -tableContextDecoder = - Decode.succeed "TODO" +showContextMenuDecoder : Decode.Decoder ( String, Mouse.Position ) +showContextMenuDecoder = + presentTrackDecoder + |> Decode.andThen (always trackRelDecoder) + |> Decode.andThen (\x -> Decode.andThen (Decode.succeed << (,) x) mousePositionDecoder) -- Events {2} -missingTrackDecoder : Decode.Decoder String -missingTrackDecoder = +presentTrackDecoder : Decode.Decoder String +presentTrackDecoder = + Decode.andThen + (\missingValue -> + if missingValue == "f" then + Decode.succeed "Track is present" + else + Decode.fail "Track is missing, invalid operation" + ) + (Decode.oneOf + [ Decode.at [ "target", "parentNode", "attributes", "data-missing", "value" ] Decode.string + , Decode.at [ "target", "attributes", "data-missing", "value" ] Decode.string + ] + ) + + +trackRelDecoder : Decode.Decoder String +trackRelDecoder = Decode.oneOf - [ Decode.at [ "target", "parentNode", "attributes", "data-missing", "value" ] Decode.string - , Decode.at [ "target", "attributes", "data-missing", "value" ] Decode.string + [ Decode.at + [ "target", "parentNode", "attributes", "rel", "value" ] + Decode.string + , Decode.at + [ "target", "attributes", "rel", "value" ] + Decode.string ] +mousePositionDecoder : Decode.Decoder Mouse.Position +mousePositionDecoder = + Decode.map2 + Mouse.Position + (Decode.field "pageX" Decode.int) + (Decode.field "pageY" Decode.int) + + sortBy : SortBy -> TopLevel.Msg sortBy = TopLevel.TracksMsg << SortBy diff --git a/src/App/Types.elm b/src/App/Types.elm index 29e743f8..5dadb427 100644 --- a/src/App/Types.elm +++ b/src/App/Types.elm @@ -2,6 +2,8 @@ module Types exposing (..) import Date exposing (Date) import Json.Encode +import Mouse +import Svg exposing (Svg) import Time exposing (Time) import Users.Types exposing (..) @@ -15,11 +17,12 @@ import Sources.Types as Sources import Tracks.Types as Tracks --- Types +-- Messages type Msg = Authenticate + | ClickAway | HideLoadingScreen | SignOut -- Time @@ -38,13 +41,19 @@ type Msg | ResetQueue | PlayTrack String | ProcessSources + | ShowTrackContextMenu ( String, Mouse.Position ) | ToggleFavourite String -- Other | NoOp + +-- Model + + type alias Model = { authenticatedUser : Maybe User + , contextMenu : Maybe ContextMenu , showLoadingScreen : Bool ------------------------------------ @@ -63,10 +72,8 @@ type alias Model = } -type alias Settings = - { queue : Queue.Settings - , tracks : Tracks.Settings - } + +-- Flags type alias ProgramFlags = @@ -80,5 +87,31 @@ type alias ProgramFlags = } + +-- Settings + + +type alias Settings = + { queue : Queue.Settings + , tracks : Tracks.Settings + } + + + +-- Context Menu + + +type ContextMenu + = ContextMenu ContextMenuItems Mouse.Position + + +type alias ContextMenuItems = + List ( Svg Msg, String, Msg ) + + + +-- Other + + type alias Illumination model childMsg = model -> List (Cmd childMsg) -> List (Cmd Msg) -> ( model, Cmd Msg ) diff --git a/src/App/View.elm b/src/App/View.elm index 16eccceb..3568bd34 100644 --- a/src/App/View.elm +++ b/src/App/View.elm @@ -1,5 +1,6 @@ module View exposing (entry) +import ContextMenu.Styles as CTS import Color import Html exposing (..) import Html.Attributes exposing (style) @@ -32,14 +33,21 @@ import Tracks.View as Tracks entry : Model -> Html Msg entry model = div - [] - [ -- {override} Loading + [ onClick ClickAway ] + [ -- + -- {override} Loading + -- if model.showLoadingScreen then div [ cssClass InTheMiddle ] [ Spinner.entry ] + -- + -- Default + -- else case model.routing.currentPage of + -- # Doesn't need authentication + -- ErrorScreen err -> div [ cssClass Shell ] @@ -89,6 +97,25 @@ entry model = authenticated [ Sources.entry sourcePage model ] model + + -- + -- Context menu + -- + , Html.Lazy.lazy contextMenu model.contextMenu + + -- + -- Overlay + -- + , div + [ cssClass Overlay + , case model.contextMenu of + Just _ -> + style [ ( "opacity", "1" ) ] + + Nothing -> + style [] + ] + [] ] @@ -193,3 +220,23 @@ blockstackLogo = navColor : Color.Color navColor = Color.rgba 0 0 0 0.4 + + +contextMenu : Maybe ContextMenu -> Html Msg +contextMenu maybeContextMenu = + case maybeContextMenu of + Just (ContextMenu items mousePos) -> + div + [ cssClass CTS.ContextMenu + , style + [ ( "left", toString mousePos.x ++ "px" ) + , ( "top", toString mousePos.y ++ "px" ) + ] + ] + (List.map + (\( icon, label, msg ) -> a [ onClick msg ] [ icon, text label ]) + items + ) + + _ -> + text "" diff --git a/src/Css/ContextMenu/Styles.elm b/src/Css/ContextMenu/Styles.elm new file mode 100644 index 00000000..f87157af --- /dev/null +++ b/src/Css/ContextMenu/Styles.elm @@ -0,0 +1,43 @@ +module ContextMenu.Styles exposing (..) + +import Css exposing (..) +import Css.Elements exposing (a, svg) +import Traits exposing (..) + + +type Classes + = ContextMenu + + + +-- 🦄 + + +styles : List Snippet +styles = + [ class ContextMenu + [ backgroundColor (rgb 255 255 255) + , fontSize (Css.rem 0.8) + , position absolute + , property "box-shadow" "0 1px 3px 0 rgba(0, 0, 0, 0.225), 0 3px 15px 0 rgba(0, 0, 0, 0.1)" + , transform (translate2 (pct -50) (pct -50)) + , zIndex (int 1000) + + -- + , descendants + [ a + [ borderBottom3 (px 1) solid (rgba 0 0 0 0.075) + , cursor pointer + , display block + , lineHeight (num 1.35) + , padding2 (gr 2) (gr 3) + ] + , svg + [ marginRight (gr 1) + , marginTop (px -2) + , paddingRight (px 1) + , verticalAlign middle + ] + ] + ] + ] diff --git a/src/Css/Styles.elm b/src/Css/Styles.elm index 615973ad..3e01d786 100644 --- a/src/Css/Styles.elm +++ b/src/Css/Styles.elm @@ -8,6 +8,7 @@ import Variables exposing (..) -- Children +import ContextMenu.Styles as ContextMenu import Console.Styles as Console import Form.Styles as Form import List.Styles as List @@ -19,6 +20,7 @@ import Tracks.Styles as Tracks styles : List Snippet styles = stylesLocal + |> List.append ContextMenu.styles |> List.append Console.styles |> List.append Form.styles |> List.append List.styles @@ -48,6 +50,7 @@ type Classes | InsulationContent | InTheMiddle | Intro + | Overlay | Shell @@ -252,4 +255,20 @@ stylesLocal = ] ] ] + + ------------------------------------------------------ + -- Overlay + ------------------------------------------------------ + , class Overlay + [ backgroundColor (rgba 0 0 0 0.25) + , height (vh 100) + , left zero + , opacity zero + , position fixed + , property "pointer-events" "none" + , property "transition" "opacity 1s ease" + , top zero + , width (vw 100) + , zIndex (int 900) + ] ] -- 2.51.2 From b5a2e03126ceb3fb5ddda1d81f2c64f5fb4d3a76 Mon Sep 17 00:00:00 2001 From: Steven Vandevelde Date: Tue, 18 Jul 2017 14:38:02 +0200 Subject: [PATCH 4/5] Improve queue --- src/App/Queue/Fill.elm | 36 +++++++++++++++++++++++++++++++++--- src/App/Queue/State.elm | 18 ++++++++++++------ src/App/Queue/View.elm | 4 ++-- src/Css/List/Styles.elm | 4 ++++ 4 files changed, 51 insertions(+), 11 deletions(-) diff --git a/src/App/Queue/Fill.elm b/src/App/Queue/Fill.elm index 92df92a2..5dd05f85 100644 --- a/src/App/Queue/Fill.elm +++ b/src/App/Queue/Fill.elm @@ -1,4 +1,4 @@ -module Queue.Fill exposing (ordered, shuffled, queueLength) +module Queue.Fill exposing (cleanAutoGenerated, ordered, queueLength, shuffled) {-| These functions will return a new list for the `future` property. -} @@ -35,13 +35,26 @@ ordered model tracks = |> Maybe.map (\idx -> List.drop (idx + 1) tracks) |> Maybe.withDefault tracks |> List.take remaining - |> (\a -> a ++ List.take (remaining - List.length a) tracks) + |> (\a -> + let + actualRemaining = + remaining - List.length a + + n = + tracks + |> List.findIndex ((==) item.track) + |> Maybe.withDefault (List.length tracks) + in + a ++ List.take (min n actualRemaining) tracks + ) |> List.map (makeItem False) + |> List.append manualEntries Nothing -> tracks |> List.take remaining |> List.map (makeItem False) + |> List.append manualEntries @@ -80,7 +93,7 @@ shuffled model timestamp tracks = List.length usedIndexes >= amountOfTracks hasNoFuture = - List.length model.future < 1 + List.isEmpty model.future in if isUsedUp && hasNoFuture && amountOfTracks > 1 then case amountOfTracks > 1 of @@ -141,6 +154,7 @@ auditor track audit acc = {-| Generated random indexes. `squirrel` = accumulator, ie. collected indexes + -} generateIndexes : Generator Int -> Int -> List Int -> List Int -> Seed -> List Int generateIndexes generator howMany usedIndexes squirrel seed = @@ -163,6 +177,22 @@ generateIndexes generator howMany usedIndexes squirrel seed = +-- Cleaning crew + + +cleanAutoGenerated : Bool -> String -> List Item -> List Item +cleanAutoGenerated shuffle trackId future = + case shuffle of + True -> + List.filterNot + (\i -> i.manualEntry == False && i.track.id == trackId) + future + + False -> + future + + + -- Constants diff --git a/src/App/Queue/State.elm b/src/App/Queue/State.elm index 0ee6497b..27a7aa61 100644 --- a/src/App/Queue/State.elm +++ b/src/App/Queue/State.elm @@ -45,12 +45,15 @@ update msg model = { manualEntry = True , track = track } + + cleanedFuture = + Fill.cleanAutoGenerated model.shuffle track.id model.future in (!) { model - | future = item :: model.future + | future = item :: cleanedFuture } - [] + [ do TopLevel.FillQueue ] -- # InjectLast -- > Add an item after the last manual entry @@ -63,8 +66,11 @@ update msg model = , track = track } + cleanedFuture = + Fill.cleanAutoGenerated model.shuffle track.id model.future + manualItems = - model.future + cleanedFuture |> List.filter (.manualEntry >> (==) True) |> List.length in @@ -72,12 +78,12 @@ update msg model = { model | future = List.concat - [ List.take manualItems model.future + [ List.take manualItems cleanedFuture , [ item ] - , List.drop manualItems model.future + , List.drop manualItems cleanedFuture ] } - [] + [ do TopLevel.FillQueue ] -- # RemoveItem Int -- > Remove an item from the queue. diff --git a/src/App/Queue/View.elm b/src/App/Queue/View.elm index b36d4100..ab38a366 100644 --- a/src/App/Queue/View.elm +++ b/src/App/Queue/View.elm @@ -167,9 +167,9 @@ renderItem index ( item, actions ) = [] [ small [] [ text (toString (index + 1) ++ ".") ] , if item.manualEntry == True then - strong [] [ text itemLabel ] - else span [] [ text itemLabel ] + else + span [ cssClass SubtleListItem ] [ text itemLabel ] ] , span [ cssClass ListActions ] diff --git a/src/Css/List/Styles.elm b/src/Css/List/Styles.elm index 7d8f579b..97f25ac8 100644 --- a/src/Css/List/Styles.elm +++ b/src/Css/List/Styles.elm @@ -10,6 +10,7 @@ type Classes = ListWithActions -- Children | ListActions + | SubtleListItem @@ -65,4 +66,7 @@ styles = ] ] ] + , class SubtleListItem + [ color (hex "#777") + ] ] -- 2.51.2 From bc143adc17c9426001518350f551d1c221060e4c Mon Sep 17 00:00:00 2001 From: Steven Vandevelde Date: Tue, 18 Jul 2017 22:20:12 +0200 Subject: [PATCH 5/5] Add IPFS notice --- src/App/Sources/State.elm | 11 ++++++++--- src/App/Sources/View.elm | 12 ++++++++++++ src/Css/Styles.elm | 4 ++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/App/Sources/State.elm b/src/App/Sources/State.elm index e89adc35..f9d6658b 100644 --- a/src/App/Sources/State.elm +++ b/src/App/Sources/State.elm @@ -29,7 +29,7 @@ initialModel : TopLevel.ProgramFlags -> Model initialModel flags = { collection = decodeSources flags , isProcessing = Nothing - , newSource = makeSource Ipfs Ipfs.initialData + , newSource = initialSource , processingErrors = [] , timestamp = Date.fromTime 0 } @@ -40,6 +40,11 @@ initialCommands = Cmd.none +initialSource : Source +initialSource = + makeSource AmazonS3 AmazonS3.initialData + + -- 🔥 @@ -224,7 +229,7 @@ update msg model = makeSource Ipfs Ipfs.initialData _ -> - makeSource AmazonS3 AmazonS3.initialData + initialSource in (!) { model | newSource = newSource } [] @@ -236,7 +241,7 @@ update msg model = ($) { model | collection = newCollection - , newSource = makeSource Ipfs Ipfs.initialData + , newSource = initialSource } [] [ do TopLevel.ProcessSources diff --git a/src/App/Sources/View.elm b/src/App/Sources/View.elm index b26b316e..c287bb09 100644 --- a/src/App/Sources/View.elm +++ b/src/App/Sources/View.elm @@ -238,6 +238,18 @@ pageNewForm newSource = ] [ text "here" ] , text "." + , br + [] + [] + , br + [] + [] + , Icons.warning (Color.rgb 65 50 63) 16 + , text "In order to use IPFS you currently must use " + , a [ href "https://github.com/icidasset/go-ipfs" ] [ text "my fork" ] + , text ", I'm still waiting for " + , a [ href "https://github.com/ipfs/go-ipfs/pull/4073" ] [ text "my pull-request" ] + , text " to be merged." ] -- Select the type of the source diff --git a/src/Css/Styles.elm b/src/Css/Styles.elm index 3e01d786..00d8a47c 100644 --- a/src/Css/Styles.elm +++ b/src/Css/Styles.elm @@ -202,6 +202,10 @@ stylesLocal = [ a [ borderBottom3 (px 2) solid (cssColor colors.base0A) ] + , svg + [ marginRight (gr 1) + , verticalAlign middle + ] ] ]