Skip to content

Commit bd66184

Browse files
committed
rebuild code v 0.1
1 parent 219dee8 commit bd66184

File tree

7 files changed

+1665
-17510
lines changed

7 files changed

+1665
-17510
lines changed

package-lock.json

Lines changed: 0 additions & 16532 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"private": true,
55
"dependencies": {
66
"@material-ui/core": "^3.9.2",
7+
"@material-ui/icons": "^3.0.2",
78
"@uiw/react-codemirror": "^1.0.19",
89
"axios": "^0.18.0",
910
"highlight.js": "^9.15.6",

src/App.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ class App extends Component {
8686

8787
return (
8888
<div className="App">
89-
<Navbar></Navbar>
90-
89+
<Navbar content={this.state.content}></Navbar>
90+
9191
<div className="text-container">
9292
<div className="text-box" onMouseOver={(e) => this.setCurrentIndex(1, e)}>
9393

src/icon/fullscreen.svg

Lines changed: 1 addition & 0 deletions
Loading

src/icon/github.svg

Lines changed: 1 addition & 0 deletions
Loading

src/layout/navbar.js

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
11
import React, { Component } from 'react';
22
import '../App.css'
33
import axios from 'axios';
4+
import githubIcon from '../icon/github.svg'
5+
import fullscreenIcon from '../icon/fullscreen.svg'
46

57
import { CLIENT_ID, CLIENT_SECRET, PROXY, ACCESS_TOKEN } from '../utils/constant.js';
68
import { queryParse, axiosJSON, axiosGithub } from '../utils/helper';
79

10+
// Material Design
11+
import PropTypes from 'prop-types';
12+
import { withStyles } from '@material-ui/core/styles';
13+
import IconButton from '@material-ui/core/IconButton';
14+
import DeleteIcon from '@material-ui/icons/Delete';
15+
import Tooltip from '@material-ui/core/Tooltip';
16+
17+
18+
19+
const styles = theme => ({
20+
button: {
21+
margin: theme.spacing.unit,
22+
borderRadius: 0,
23+
},
24+
});
25+
826

927
class Navbar extends Component {
1028
constructor(props) {
@@ -42,8 +60,6 @@ class Navbar extends Component {
4260
console.log(this.state.title);
4361
}
4462

45-
46-
4763
login = () => {
4864
window.location.href = `https://github.com/login/oauth/authorize?client_id=${CLIENT_ID}&scope=public_repo`;
4965
}
@@ -88,10 +104,13 @@ class Navbar extends Component {
88104
//commit the file
89105

90106
commitFile = async () => {
107+
108+
console.log(this.props.content);
91109
try {
92110
const response = await axiosGithub.put(`/repos/zhning12/markdown_example/contents/${this.state.title}.md`, {
93111
"message": "I am the commit message",
94-
"content": btoa(this.state.content)
112+
// "content": btoa(this.state.content)
113+
"content": btoa(this.props.content)
95114
});
96115
console.log(response);
97116
} catch (error) {
@@ -100,16 +119,24 @@ class Navbar extends Component {
100119
}
101120

102121
render() {
122+
const { classes } = this.props;
103123
return (
104124
<div className="navi-bar">
105125
<div className="left-nav"></div>
106126
<div className="right-nav"></div>
127+
<Tooltip title="Log in GitHub" enterDelay={500} leaveDelay={200}>
128+
<IconButton className={classes.button} onClick={this.login}>
129+
<img src={githubIcon} alt="log in"></img>
130+
</IconButton>
131+
</Tooltip>
107132

108-
<button onClick={this.login}>点击登录</button>
133+
<IconButton className={classes.button} aria-label="Delete">
134+
<DeleteIcon />
135+
</IconButton>
109136

110-
<button onClick={this.fullScreen} id="goFS">
111-
{this.state.isFullScreen ? '取消全屏' : '全屏'}
112-
</button>
137+
<IconButton className={classes.button} onClick={this.fullScreen} id="goFS">
138+
<img src={fullscreenIcon} alt="full screen"></img>
139+
</IconButton>
113140

114141
<button onClick={this.createRepo} id="createRepo">
115142
Create a New Repo
@@ -133,4 +160,8 @@ class Navbar extends Component {
133160
}
134161
}
135162

136-
export default Navbar;
163+
Navbar.propTypes = {
164+
classes: PropTypes.object.isRequired,
165+
};
166+
167+
export default withStyles(styles)(Navbar);

0 commit comments

Comments
 (0)