Last active
August 29, 2015 14:09
-
-
Save jdegoes/f4f4b1af8bdd85747f9d to your computer and use it in GitHub Desktop.
Figuring out the new guard layout rule
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
reify :: forall eff. ComponentClass (FileSystemTreeProps eff) FileSystemTreeState | |
reify = createClass spec | |
{ displayName = "FileSystemTree" | |
, getInitialState = \_ -> pure {collapsed: true} | |
, render = \this -> case this.props.files of | |
(FileType {"type" = "file", name = n}) -> pure $ D.div {} | |
[D.span {} | |
[ dataFileIcon | |
, D.rawText n | |
] | |
] | |
(FileType {"type" = "directory", name = n}) | n `endsWith` ".nb" -> pure $ D.div {} | |
[D.span {onClick: eventHandler this \this _ -> | |
this.props.request $ OpenNotebook $ joinPath $ this.props.path `snoc` n | |
} | |
[ notebookIcon | |
, D.rawText $ formatNotebookName n | |
] | |
] | |
(FileType {"type" = "directory", name = n, children = c}) -> pure $ treeView | |
{ collapsed: this.state.collapsed | |
, defaultCollapsed: true | |
, nodeLabel: D.span | |
{onClick: eventHandler (coerceThis this) toggleTree} | |
[ if this.state.collapsed then dirClosedIcon else dirOpenIcon | |
, D.rawText n | |
] | |
, onClick: eventHandler (coerceThis this) toggleTree | |
} | |
(sort c <#> \f -> reify { files: f | |
, request: this.props.request | |
, path: this.props.path `snoc` n | |
} []) | |
(FileType {"type" = "mount", name = n}) -> pure $ D.div {} | |
[D.span {} | |
[ mountIcon | |
, D.rawText n | |
] | |
] | |
(FileType {name = n}) -> pure $ D.div {} | |
[D.span {} | |
[ fileIcon | |
, D.rawText n | |
] | |
] } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment