Make it look more like Minsuk's version.
This commit is contained in:
parent
3a237d0d0e
commit
69f8de7f2e
4
elm.json
4
elm.json
|
@ -8,10 +8,12 @@
|
|||
"direct": {
|
||||
"elm/browser": "1.0.2",
|
||||
"elm/core": "1.0.5",
|
||||
"elm/html": "1.0.0"
|
||||
"elm/html": "1.0.0",
|
||||
"feathericons/elm-feather": "1.5.0"
|
||||
},
|
||||
"indirect": {
|
||||
"elm/json": "1.1.3",
|
||||
"elm/svg": "1.0.1",
|
||||
"elm/time": "1.0.0",
|
||||
"elm/url": "1.0.0",
|
||||
"elm/virtual-dom": "1.0.2"
|
||||
|
|
|
@ -96,8 +96,8 @@ body {
|
|||
.week-grid {
|
||||
display: grid;
|
||||
width: 100%;
|
||||
height: 50vh;
|
||||
grid-template-columns: auto repeat(7, 1fr);
|
||||
height: 70vh;
|
||||
grid-template-columns: auto repeat(5, 1fr);
|
||||
grid-template-rows: auto repeat(10, 1fr);
|
||||
}
|
||||
|
||||
|
@ -107,13 +107,19 @@ body {
|
|||
border-radius: 0.25rem;
|
||||
padding: 0.25rem;
|
||||
box-sizing: border-box;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
|
||||
&.selected {
|
||||
border-style: dashed;
|
||||
border-width: 2px;
|
||||
}
|
||||
|
||||
p {
|
||||
margin-top: 0.1rem;
|
||||
margin-bottom: 0.1rem;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
}
|
||||
|
||||
.column-container {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
module ClassSchedule.View exposing (..)
|
||||
import ClassSchedule.Model exposing (..)
|
||||
import Html exposing (Html, Attribute, div, text, table, td, th, tr, span, input, h1)
|
||||
import Html exposing (Html, Attribute, div, text, table, td, th, tr, span, input, h1, p)
|
||||
import Html.Attributes exposing (class, classList, type_, style)
|
||||
import Html.Events exposing (onClick)
|
||||
import Html.Events exposing (onClick, onInput)
|
||||
import Tuple exposing (..)
|
||||
import Dict exposing (..)
|
||||
import FeatherIcons
|
||||
|
@ -110,14 +110,14 @@ viewClassTable sel =
|
|||
|
||||
viewToolbar : Model -> Html Msg
|
||||
viewToolbar m = div []
|
||||
[ span [] [ text "Search: " , input [ type_ "text" ] [] ]
|
||||
[ span [] [ text "Search: " , input [ type_ "text", onInput SearchInput ] [] ]
|
||||
]
|
||||
|
||||
viewClassList : Model -> Html Msg
|
||||
viewClassList m = div []
|
||||
[ viewToolbar m
|
||||
, case get (m.term) (m.terms) of
|
||||
Just cs -> viewClassTable (m.selected) cs
|
||||
Just cs -> viewClassTable (m.selected) <| List.filter (courseContains m.searchInput) cs
|
||||
Nothing -> text "Please select a term!"
|
||||
]
|
||||
|
||||
|
@ -214,6 +214,9 @@ groupDims l =
|
|||
days : List DayOfWeek
|
||||
days = [Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday]
|
||||
|
||||
courseContains : String -> (CourseStatus, Course) -> Bool
|
||||
courseContains s (_, c) = String.contains s (viewCrn c.crn) || String.contains s c.name || List.any (String.contains s) c.instructors
|
||||
|
||||
buildCellDict : Maybe Int -> List (CourseStatus, Course) -> Dict Int (Dict Int (List (Course, CellInfo)))
|
||||
buildCellDict ms l =
|
||||
let
|
||||
|
@ -225,8 +228,8 @@ buildCellDict ms l =
|
|||
in
|
||||
List.foldl Dict.union Dict.empty <| List.indexedMap singleDay days
|
||||
|
||||
viewCourseBlock : CellInfo -> String -> Html Msg
|
||||
viewCourseBlock ci s =
|
||||
viewCourseBlock : CellInfo -> Course -> Html Msg
|
||||
viewCourseBlock ci c =
|
||||
let
|
||||
ps f = String.fromFloat f ++ "%"
|
||||
nw = if (ci.width) == 100.0 then 100.0 else (ci.width)*0.95
|
||||
|
@ -239,7 +242,9 @@ viewCourseBlock ci s =
|
|||
, style "top" (ps (ci.verticalOffset))
|
||||
, classList [("selected", sel), ("color-green", ad == Added)]
|
||||
]
|
||||
[ text s ]
|
||||
[ p [] [ text <| viewCrn <| c.crn ]
|
||||
, p [] [ text <| c.name ]
|
||||
]
|
||||
|
||||
viewTableDayHeader : DayOfWeek -> Html Msg
|
||||
viewTableDayHeader dw = span [ class "table-day-header" ] [ text <| viewDayCode dw ]
|
||||
|
@ -247,12 +252,12 @@ viewTableDayHeader dw = span [ class "table-day-header" ] [ text <| viewDayCode
|
|||
viewClassSchedule : Model -> Html Msg
|
||||
viewClassSchedule m =
|
||||
let
|
||||
header = span [] [] :: List.map viewTableDayHeader days
|
||||
header = span [] [] :: List.map viewTableDayHeader (List.take 5 days)
|
||||
cellDict = buildCellDict m.selected (Maybe.withDefault [] <| Dict.get m.term m.terms)
|
||||
times = List.range 0 10
|
||||
time h = List.map (\w -> Maybe.withDefault [] <| Maybe.andThen (Dict.get h) <| Dict.get w cellDict) (List.range 0 6)
|
||||
time h = List.map (\w -> Maybe.withDefault [] <| Maybe.andThen (Dict.get h) <| Dict.get w cellDict) (List.range 0 4)
|
||||
container xs = div [ class "column-container" ] <|
|
||||
List.map (\(c, ci) -> viewCourseBlock ci (viewCrn c.crn)) xs
|
||||
List.map (\(c, ci) -> viewCourseBlock ci c) xs
|
||||
in
|
||||
Debug.log (Debug.toString cellDict) <| div [ class "table-wrapper", style "width" "100%", style "padding" "1rem" ]
|
||||
[ div [ class "week-grid" ] <|
|
||||
|
|
51
src/Main.elm
51
src/Main.elm
|
@ -22,35 +22,35 @@ onDays dds (t1, t2) = List.map (\d -> (d, t1, t2)) dds
|
|||
|
||||
classes : List Course
|
||||
classes =
|
||||
[ { crn = (ComputerScience, 544)
|
||||
, name = "Operating Systems II"
|
||||
, instructors = ["Yeongjin Jang"]
|
||||
, times = onDays [Tuesday, Thursday] <| oneHour <| nAm 8
|
||||
[ { crn = (ComputerScience, 517)
|
||||
, name = "Theory of Comp"
|
||||
, instructors = ["Mike Rosulek"]
|
||||
, times = onDays [Monday, Wednesday, Friday] <| oneHour <| nPm 2
|
||||
}
|
||||
, { crn = (ComputerScience, 480)
|
||||
, name = "Translators"
|
||||
, instructors = ["Rob Hess"]
|
||||
, times = onDays [Tuesday, Thursday] <| oneHour <| nAm 10
|
||||
, { crn = (ComputerScience, 531)
|
||||
, name = "Artificial Intelligence"
|
||||
, instructors = ["John Doe"]
|
||||
, times = onDays [Monday, Wednesday, Friday] <| oneHour <| nPm 0
|
||||
}
|
||||
, { crn = (ComputerScience, 583)
|
||||
, name = "Advanced Functional Programming"
|
||||
, instructors = ["Eric Walkingshaw"]
|
||||
, times = onDays [Monday, Wednesday] <| oneHour <| nAm 10
|
||||
}
|
||||
, { crn = (ComputerScience, 583)
|
||||
, name = "Advanced Functional Programming"
|
||||
, instructors = ["Eric Walkingshaw"]
|
||||
, times = onDays [Monday, Wednesday] <| oneHour <| nAm 11
|
||||
}
|
||||
, { crn = (ComputerScience, 583)
|
||||
, name = "Advanced Functional Programming"
|
||||
, instructors = ["Eric Walkingshaw"]
|
||||
, { crn = (ComputerScience, 533)
|
||||
, name = "Intelligent Somethings"
|
||||
, instructors = ["Alan Fern"]
|
||||
, times = onDays [Monday, Wednesday] <| twoHours <| nAm 10
|
||||
}
|
||||
, { crn = (ComputerScience, 582)
|
||||
, name = "Programming Languages II"
|
||||
, instructors = ["Martin Erwig"]
|
||||
, times = onDays [Monday, Wednesday] <| oneHour <| nPm 4
|
||||
, { crn = (ComputerScience, 535)
|
||||
, name = "Deep Learning"
|
||||
, instructors = ["F. Li"]
|
||||
, times = onDays [Tuesday, Thursday] <| twoHours <| nPm 2
|
||||
}
|
||||
, { crn = (ComputerScience, 551)
|
||||
, name = "Computer Graphics"
|
||||
, instructors = ["Mike Bailey"]
|
||||
, times = onDays [Monday, Wednesday] <| twoHours <| nPm 0
|
||||
}
|
||||
, { crn = (ComputerScience, 565)
|
||||
, name = "Human-Computer Interaction"
|
||||
, instructors = ["Minsuk Kahng"]
|
||||
, times = onDays [Tuesday, Thursday] <| twoHours <| nPm 4
|
||||
}
|
||||
]
|
||||
|
||||
|
@ -81,6 +81,7 @@ update msg m =
|
|||
SelectCourse i -> ({ m | selected = Just i}, Cmd.none)
|
||||
AddCourse i -> (modifyCurrent (changeCourse i Added) m, Cmd.none)
|
||||
RemoveCourse i -> (modifyCurrent (changeCourse i NotAdded) m, Cmd.none)
|
||||
SearchInput s -> ({ m | searchInput = s }, Cmd.none)
|
||||
_ -> (m, Cmd.none)
|
||||
|
||||
subscriptions : Model -> Sub Msg
|
||||
|
|
Loading…
Reference in New Issue
Block a user