From 81aa11277d7dc5cc977b03342efcec1cb0902b36 Mon Sep 17 00:00:00 2001 From: Steven Vandevelde Date: Fri, 2 Nov 2018 16:08:52 +0100 Subject: [PATCH] Add foundation for new-source form --- src/Applications/UI.elm | 10 +-- src/Applications/UI/Kit.elm | 16 ++++- src/Applications/UI/Navigation.elm | 3 +- src/Applications/UI/Page.elm | 4 ++ src/Applications/UI/Settings.elm | 56 +++++++-------- src/Applications/UI/Sources.elm | 111 ++++++++++++++++++++--------- src/Library/Sources.elm | 41 ++++++++++- src/Static/Html/Application.html | 6 +- 8 files changed, 174 insertions(+), 73 deletions(-) diff --git a/src/Applications/UI.elm b/src/Applications/UI.elm index e888a2e4..d4935714 100644 --- a/src/Applications/UI.elm +++ b/src/Applications/UI.elm @@ -254,25 +254,27 @@ defaultScreen model = [ style "max-width" (String.fromFloat UI.Kit.insulationWidth ++ "px") ] [ T.bg_white , T.br2 + , T.flex + , T.flex_column , T.flex_grow_1 , T.overflow_hidden , T.w_100 ] - [ case model.page of + (case model.page of Page.Index -> -- TODO: Tracks - empty + [ empty ] Page.NotFound -> -- TODO - text "Page not found." + [ text "Page not found." ] Page.Settings -> UI.Settings.view model Page.Sources subPage -> UI.Sources.view model subPage - ] + ) ----------------------------------------- -- Controls diff --git a/src/Applications/UI/Kit.elm b/src/Applications/UI/Kit.elm index b9bafc44..f1abd8bd 100644 --- a/src/Applications/UI/Kit.elm +++ b/src/Applications/UI/Kit.elm @@ -1,4 +1,4 @@ -module UI.Kit exposing (canister, colorKit, colors, defaultFont, h1, headerFont, insulationWidth, intro) +module UI.Kit exposing (canister, colorKit, colors, defaultFont, h1, h2, headerFont, insulationWidth, intro) import Chunky exposing (..) import Color @@ -106,6 +106,20 @@ h1 text = [ Html.text text ] +h2 : String -> Html msg +h2 text = + slab + Html.h2 + [ style "font-family" headerFont ] + [ T.f3 + , T.fw7 + , T.lh_title + , T.mb4 + , T.mt0 + ] + [ Html.text text ] + + intro : Html msg -> Html msg intro child = slab diff --git a/src/Applications/UI/Navigation.elm b/src/Applications/UI/Navigation.elm index ccb7df8f..9c790d5b 100644 --- a/src/Applications/UI/Navigation.elm +++ b/src/Applications/UI/Navigation.elm @@ -158,7 +158,8 @@ localItem idx ( Icon icon, Label labelText labelType, action ) = , T.justify_center , T.lh_solid , T.no_underline - , T.ph2 + , T.outline_0 + , T.ph3 ] [ icon UI.Kit.colors.text 16 diff --git a/src/Applications/UI/Page.elm b/src/Applications/UI/Page.elm index 2943aa69..6ecd2fbc 100644 --- a/src/Applications/UI/Page.elm +++ b/src/Applications/UI/Page.elm @@ -46,6 +46,9 @@ toString page = Sources Sources.Index -> "/sources" + Sources (Sources.New _) -> + "/sources/new" + -- ⚗️ @@ -60,4 +63,5 @@ route = -- Sources , map (Sources Sources.Index) (s "sources") + , map (Sources <| Sources.New Sources.newForm) (s "sources" s "new") ] diff --git a/src/Applications/UI/Settings.elm b/src/Applications/UI/Settings.elm index f3ca39b8..c573730e 100644 --- a/src/Applications/UI/Settings.elm +++ b/src/Applications/UI/Settings.elm @@ -15,7 +15,7 @@ import UI.Page as Page -- 🗺 -view : UI.Core.Model -> Html UI.Core.Msg +view : UI.Core.Model -> List (Html UI.Core.Msg) view = index @@ -24,33 +24,31 @@ view = -- PAGES -index : UI.Core.Model -> Html UI.Core.Msg +index : UI.Core.Model -> List (Html UI.Core.Msg) index model = - chunk - [] - [ ----------------------------------------- - -- Navigation - ----------------------------------------- - UI.Navigation.local - [ ( Icon Icons.import_export - , Label "Import / Export" Shown - , PerformMsg UI.Core.Bypass - ) - , ( Icon Icons.exit_to_app - , Label "Sign out" Shown - , PerformMsg UI.Core.Bypass - ) - ] - model.page - - ----------------------------------------- - -- Content - ----------------------------------------- - , UI.Kit.canister - [ UI.Kit.h1 "Settings" - , [ text "Changes are automatically saved." - ] - |> Html.span [] - |> UI.Kit.intro - ] + [ ----------------------------------------- + -- Navigation + ----------------------------------------- + UI.Navigation.local + [ ( Icon Icons.import_export + , Label "Import / Export" Shown + , PerformMsg UI.Core.Bypass + ) + , ( Icon Icons.exit_to_app + , Label "Sign out" Shown + , PerformMsg UI.Core.Bypass + ) ] + model.page + + ----------------------------------------- + -- Content + ----------------------------------------- + , UI.Kit.canister + [ UI.Kit.h1 "Settings" + , [ text "Changes are automatically saved." + ] + |> Html.span [] + |> UI.Kit.intro + ] + ] diff --git a/src/Applications/UI/Sources.elm b/src/Applications/UI/Sources.elm index 25c18444..7c93b3af 100644 --- a/src/Applications/UI/Sources.elm +++ b/src/Applications/UI/Sources.elm @@ -17,48 +17,91 @@ import UI.Page as Page -- 🗺 -view : UI.Core.Model -> Sources.Page -> Html UI.Core.Msg +view : UI.Core.Model -> Sources.Page -> List (Html UI.Core.Msg) view model page = case page of Index -> index model + New form -> + new form model --- PAGES +-- INDEX -index : UI.Core.Model -> Html UI.Core.Msg + +index : UI.Core.Model -> List (Html UI.Core.Msg) index model = - chunk - [] - [ ----------------------------------------- - -- Navigation - ----------------------------------------- - UI.Navigation.local - [ ( Icon Icons.add - , Label "Add a new source" Shown - , GoToPage (Page.Sources Sources.Index) - ) - , ( Icon Icons.sync - , Label "Process sources" Shown - , PerformMsg UI.Core.Bypass - ) - ] - model.page - - ----------------------------------------- - -- Content - ----------------------------------------- - , UI.Kit.canister - [ UI.Kit.h1 "Sources" - , [ text "A source is a place where your music is stored." - , lineBreak - , text "By connecting a source, the application will scan it and keep a list of all the music in it." - , lineBreak - , text "It will not copy anything." - ] - |> Html.span [] - |> UI.Kit.intro - ] + [ ----------------------------------------- + -- Navigation + ----------------------------------------- + UI.Navigation.local + [ ( Icon Icons.add + , Label "Add a new source" Shown + , GoToPage (Page.Sources <| New newForm) + ) + , ( Icon Icons.sync + , Label "Process sources" Shown + , PerformMsg UI.Core.Bypass + ) + ] + model.page + + ----------------------------------------- + -- Content + ----------------------------------------- + , UI.Kit.canister + [ UI.Kit.h1 "Sources" + , [ text "A source is a place where your music is stored." + , lineBreak + , text "By connecting a source, the application will scan it and keep a list of all the music in it." + , lineBreak + , text "It will not copy anything." + ] + |> Html.span [] + |> UI.Kit.intro + ] + ] + + + +-- NEW + + +new : Form -> UI.Core.Model -> List (Html UI.Core.Msg) +new form = + case form.step of + Where -> + newWhere form + + _ -> + always [ empty ] + + +newWhere : Form -> UI.Core.Model -> List (Html UI.Core.Msg) +newWhere { context } model = + [ ----------------------------------------- + -- Navigation + ----------------------------------------- + UI.Navigation.local + [ ( Icon Icons.arrow_back + , Label "Back to list" Hidden + , GoToPage (Page.Sources Sources.Index) + ) + ] + model.page + + ----------------------------------------- + -- Content + ----------------------------------------- + , chunk + [ T.flex + , T.flex_grow_1 + , T.items_center + , T.justify_center + , T.relative + ] + [ UI.Kit.h2 "Where is your music stored?" ] + ] diff --git a/src/Library/Sources.elm b/src/Library/Sources.elm index c0170074..edc12d0c 100644 --- a/src/Library/Sources.elm +++ b/src/Library/Sources.elm @@ -1,4 +1,4 @@ -module Sources exposing (Page(..), Service(..), Source, SourceData) +module Sources exposing (Form, FormStep(..), Page(..), Service(..), Source, SourceData, defaultService, emptySource, newForm) import Dict exposing (Dict) @@ -28,9 +28,48 @@ type Service = AmazonS3 +defaultService : Service +defaultService = + AmazonS3 + + -- PAGE type Page = Index + | New Form + + + +-- FORM + + +type alias Form = + { step : FormStep, context : Source } + + +type FormStep + = Where + | How + | By + + +newForm : Form +newForm = + { step = Where, context = emptySource } + + + +-- ⚡️ + + +emptySource : Source +emptySource = + { id = "CHANGE_ME_PLEASE" + , data = Dict.empty + , directoryPlaylists = True + , enabled = True + , service = defaultService + } diff --git a/src/Static/Html/Application.html b/src/Static/Html/Application.html index e86c8d80..efdbdfe5 100644 --- a/src/Static/Html/Application.html +++ b/src/Static/Html/Application.html @@ -64,11 +64,11 @@ - - + + - + -- knotmirror 0.0.1