Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Create display view #14

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file removed src/App.css
Empty file.
11 changes: 0 additions & 11 deletions src/App.js

This file was deleted.

10 changes: 10 additions & 0 deletions src/App.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.edit-mode-container {
display: flex;
flex-direction: column;

& .button-module {
display: flex;
flex-direction: row;
align-self: flex-start;
}
}
9 changes: 0 additions & 9 deletions src/App.test.js

This file was deleted.

13 changes: 13 additions & 0 deletions src/DisplayView.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';

export default function DisplayView({ width = '100%', children }) {
/************************************
* Render
************************************/

return (
<div style={{width: width}}>
{children ? children : <p>Nothing to Display.</p>}
</div>
);
}
34 changes: 34 additions & 0 deletions src/EditMode.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React, { useState } from 'react';
import './App.scss';

import EditView from './EditView';
import DisplayView from './DisplayView';

/************************************
* Constants
************************************/

const EDIT_VIEW = 'EDIT';
const DISPLAY_VIEW = 'DISPLAY';

export default function EditMode({width = '100%', height = '500px'}) {
/************************************
* State
************************************/

const [view, setView] = useState(EDIT_VIEW);

/************************************
* Render
************************************/

return (
<div className='edit-mode-container' style={{width: width, height: height}}>
<div className='button-module'>
<button onClick={() => setView(EDIT_VIEW)}>Edit</button>
<button onClick={() => setView(DISPLAY_VIEW)}>Preview</button>
</div>
{ view === EDIT_VIEW ? <EditView /> : <DisplayView>{/* TODO: Parsed Markdown Goes Here */}</DisplayView> }
</div>
);
}
11 changes: 11 additions & 0 deletions src/EditView.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react';

export default function EditView({ onValueChange, ...rest }) {
/************************************
* Render
************************************/

return (
<textarea style={{height: 'inherit'}} {...rest} onChange={onValueChange}></textarea>
);
}
12 changes: 12 additions & 0 deletions src/LeifdownApp.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';
import EditMode from './EditMode';

export default function LeifdownApp() {
/************************************
* Render
************************************/

return (
<EditMode />
);
}
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import LeifdownApp from './LeifdownApp';
import * as serviceWorker from './serviceWorker';

ReactDOM.render(
<React.StrictMode>
<App />
<LeifdownApp />
</React.StrictMode>,
document.getElementById('root')
);
Expand Down