forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(castro): basic code browsing layout
fix #15
- Loading branch information
1 parent
4ca28cf
commit eecfcf8
Showing
11 changed files
with
209 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react'; | ||
import { HashRouter as Router, Route } from 'react-router-dom'; | ||
|
||
import { Main } from './main'; | ||
import Layout from './Layout/Layout'; | ||
|
||
export default props => { | ||
return ( | ||
<Router> | ||
<div> | ||
<Route path="/" exact render={() => <Main {...props} />}/> | ||
<Route path="/codebrowsing" component={Layout} /> | ||
</div> | ||
</Router> | ||
); | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.codeBlock { | ||
height: 100%; | ||
} |
26 changes: 26 additions & 0 deletions
26
kibana-extra/castro/public/components/Layout/CodeBlock.tsx
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from 'react'; | ||
|
||
import { EuiCodeBlock } from '@elastic/eui'; | ||
|
||
import './CodeBlock.css' | ||
|
||
const codeSnippet = `var y = function(le) { | ||
return function(f) { | ||
return f(f); | ||
}(function(f) { | ||
return le( | ||
function(x) { return (f(f))(x); } | ||
); | ||
}); | ||
};`; | ||
|
||
export default class CodeBlock extends React.PureComponent { | ||
static defaultProps = { | ||
code: codeSnippet, | ||
language: 'js' | ||
}; | ||
|
||
public render() { | ||
return <EuiCodeBlock language={this.props.language} className="codeBlock">{this.props.code}</EuiCodeBlock> | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
kibana-extra/castro/public/components/Layout/DirectoryTree.tsx
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from 'react'; | ||
import { EuiSideNav, EuiIcon } from '@elastic/eui'; | ||
|
||
import directoryTree from './mockData/directoreTree'; | ||
|
||
function to (node) { | ||
const data = { | ||
id: node.name, | ||
name: node.name, | ||
isSelected: true, | ||
onClick: () => { | ||
//link to file path | ||
console.log(node.path) | ||
} | ||
} | ||
if(!node.is_simple && node.obj_type === 2) { | ||
data.icon = <EuiIcon type="arrowRight"/> | ||
} | ||
if (node.children && node.children.length > 0) { | ||
data.items = node.children.map(to); | ||
} | ||
return data | ||
} | ||
|
||
export default class DirectoryTree extends React.PureComponent { | ||
public render() { | ||
const items= directoryTree.children.map(to); | ||
console.log(items, directoryTree) | ||
return <EuiSideNav | ||
items={items} | ||
style={{ width: 192 }} | ||
/> | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import React from 'react'; | ||
|
||
import { | ||
EuiHeader, | ||
EuiHeaderBreadcrumbs, | ||
EuiHeaderSection, | ||
EuiHeaderSectionItem, | ||
EuiHeaderSectionItemButton, | ||
EuiHeaderLogo, | ||
EuiIcon, | ||
EuiSideNav, | ||
EuiFlexGroup, | ||
EuiFlexItem | ||
} from '@elastic/eui'; | ||
|
||
import DirectoryTree from './DirectoryTree'; | ||
import CodeBlock from './CodeBlock'; | ||
|
||
export default class Layout extends React.Component { | ||
public render() { | ||
return <div><EuiHeader> | ||
<EuiHeaderSection> | ||
<EuiHeaderSectionItem border="right"> | ||
<EuiHeaderLogo>Code Browsing</EuiHeaderLogo> | ||
</EuiHeaderSectionItem> | ||
|
||
</EuiHeaderSection> | ||
|
||
<EuiHeaderSection side="right"> | ||
<EuiHeaderSectionItemButton aria-label="Search"> | ||
<EuiIcon | ||
type="search" | ||
size="m" | ||
/> | ||
</EuiHeaderSectionItemButton> | ||
</EuiHeaderSection> | ||
</EuiHeader> | ||
<EuiFlexGroup> | ||
<EuiFlexItem style={{ maxWidth: 300 }}> | ||
<DirectoryTree /> | ||
</EuiFlexItem> | ||
|
||
<EuiFlexItem> | ||
<CodeBlock /> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</div> | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
kibana-extra/castro/public/components/Layout/mockData/directoreTree.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const json = JSON.parse(` | ||
{"name":"","path":"","obj_type":2,"children":[{"name":".env","path":".env","obj_type":3,"is_simple":false},{"name":".gitignore","path":".gitignore","obj_type":3,"is_simple":false},{"name":"CHANGES","path":"CHANGES","obj_type":3,"is_simple":false},{"name":"cn-lambda-compose","path":"cn-lambda-compose","obj_type":3,"is_simple":false},{"name":"cn-lambda-compose-dis","path":"cn-lambda-compose-dis","obj_type":3,"is_simple":false},{"name":"configs","path":"configs/","obj_type":2,"children":[],"is_simple":false},{"name":"docker-compose-distributed.yml","path":"docker-compose-distributed.yml","obj_type":3,"is_simple":false},{"name":"docker-compose-editorserver.yml","path":"docker-compose-editorserver.yml","obj_type":3,"is_simple":false},{"name":"docker-compose.yml","path":"docker-compose.yml","obj_type":3,"is_simple":false},{"name":"docs","path":"docs/","obj_type":2,"children":[],"is_simple":false},{"name":"jaas.conf","path":"jaas.conf","obj_type":3,"is_simple":false},{"name":"lambda-compose","path":"lambda-compose","obj_type":3,"is_simple":false},{"name":"lambda-compose-dis","path":"lambda-compose-dis","obj_type":3,"is_simple":false},{"name":"lambda-compose-editorserver","path":"lambda-compose-editorserver","obj_type":3,"is_simple":false},{"name":"scripts","path":"scripts/","obj_type":2,"children":[],"is_simple":false},{"name":"thirdparty","path":"thirdparty/","obj_type":2,"children":[],"is_simple":false},{"name":"tools","path":"tools/","obj_type":2,"children":[],"is_simple":false},{"name":"upgrade","path":"upgrade","obj_type":3,"is_simple":false}],"is_simple":false} | ||
`); | ||
|
||
export default json; |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
dist |