Skip to content
This repository has been archived by the owner on Mar 4, 2024. It is now read-only.

Commit

Permalink
feat: being able to edit and start tutorials from the projects page
Browse files Browse the repository at this point in the history
  • Loading branch information
prescientmoon committed Jul 20, 2020
1 parent 337c095 commit 6a0d064
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
8 changes: 8 additions & 0 deletions public/styles/pages/projects.scss
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@
margin-right: 1rem;
}

.project__data-icon--clickable {
transition: transform $transition-time;
}

.project__data-icon--clickable:hover {
transform: scale(1.4);
}

.project--new {
@include utils.center;
background: $primary;
Expand Down
8 changes: 8 additions & 0 deletions src/AppM.purs
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,22 @@ instance manageProjectsAppM :: ManageProjects AppM where
[ { id: TutorialId 0
, name: "A sample tutorial"
, completed: false
, own: true
}
, { id: TutorialId 1
, name: "Another tutorial"
, completed: false
, own: false
}
, { id: TutorialId 2
, name: "Actually completed this"
, completed: true
, own: false
}
, { id: TutorialId 7
, name: "A tutorial I can edit"
, completed: false
, own: true
}
]

Expand Down
21 changes: 17 additions & 4 deletions src/Component/Projects.purs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ data Action
| OpenProject ProjectId
| DeleteProject ProjectId MouseEvent
| DeleteTutorial TutorialId MouseEvent
| EditTutorial' TutorialId MouseEvent
| StartTutorial TutorialId
| CreateProject
| CreateTutorial
| CloneProject ProjectId
Expand Down Expand Up @@ -124,6 +126,11 @@ component =
case response of
Right cloneId -> navigate $ Project cloneId
Left err -> modify_ _ { projectList = Failure err }
EditTutorial' id event -> do
liftEffect $ stopPropagation $ MouseEvent.toEvent event
navigate $ EditTutorial id
StartTutorial id -> do
navigate $ Tutorial id
DeleteProject id event -> do
liftEffect $ stopPropagation $ MouseEvent.toEvent event
oldProjects <- gets $ preview $ _projectList <<< _Success
Expand Down Expand Up @@ -187,7 +194,7 @@ component =
]
, whenElem (not isExample) \_ ->
HH.div
[ className "project__data-icon"
[ className "project__data-icon project__data-icon--clickable"
, onClick $ Just <<< DeleteProject id
]
[ icon "delete"
Expand Down Expand Up @@ -243,17 +250,23 @@ component =
$ [ newProject CreateTutorial ]
<> (mkItem <$> tutorials)
where
mkItem { name, completed, id } =
HH.div [ className "project", onClick $ const $ Just CreateTutorial ]
mkItem { name, completed, id, own } =
HH.div [ className "project", onClick $ const $ Just $ StartTutorial id ]
[ HH.div [ className "project__name no-overflow" ] [ HH.text name ]
, HH.div [ className "project__data" ]
[ whenElem completed \_ ->
HH.div
[ className "project__data-icon"
]
[ icon "verified" ]
, whenElem own \_ ->
HH.div
[ className "project__data-icon project__data-icon--clickable"
, onClick $ Just <<< EditTutorial' id
]
[ icon "edit" ]
, HH.div
[ className "project__data-icon"
[ className "project__data-icon project__data-icon--clickable"
, onClick $ Just <<< DeleteTutorial id
]
[ icon "delete"
Expand Down
1 change: 1 addition & 0 deletions src/Data/ProjectList.purs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type TutorialOverview
= { name :: String
, id :: TutorialId
, completed :: Boolean
, own :: Boolean
}

-- | Stuff we get from the server to render on the projects page
Expand Down

0 comments on commit 6a0d064

Please sign in to comment.