Add markdown previewer certification project
This commit is contained in:
parent
4bed26ba5a
commit
963a58b899
11 changed files with 29370 additions and 0 deletions
23
3-frontend-dev-libraries/2-markdown-previewer/.gitignore
vendored
Normal file
23
3-frontend-dev-libraries/2-markdown-previewer/.gitignore
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.js
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
29079
3-frontend-dev-libraries/2-markdown-previewer/package-lock.json
generated
Normal file
29079
3-frontend-dev-libraries/2-markdown-previewer/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
44
3-frontend-dev-libraries/2-markdown-previewer/package.json
Normal file
44
3-frontend-dev-libraries/2-markdown-previewer/package.json
Normal file
|
@ -0,0 +1,44 @@
|
|||
{
|
||||
"name": "markdown-previewer",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"homepage": "https://cherrykitten.github.io/freecodecamp-projects/3-frontend-dev-libraries/2-markdown-previewer/",
|
||||
"dependencies": {
|
||||
"@testing-library/jest-dom": "^5.16.5",
|
||||
"@testing-library/react": "^13.4.0",
|
||||
"@testing-library/user-event": "^13.5.0",
|
||||
"marked-react": "^1.3.0",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-scripts": "5.0.1",
|
||||
"web-vitals": "^2.1.4"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test",
|
||||
"eject": "react-scripts eject",
|
||||
"deploy": "gh-pages -d build"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
"react-app",
|
||||
"react-app/jest"
|
||||
]
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
">0.2%",
|
||||
"not dead",
|
||||
"not op_mini all"
|
||||
],
|
||||
"development": [
|
||||
"last 1 chrome version",
|
||||
"last 1 firefox version",
|
||||
"last 1 safari version"
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"gh-pages": "^4.0.0"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v6.2.0/css/all.css">
|
||||
<meta
|
||||
name="description"
|
||||
content="Markdown previewer"
|
||||
/>
|
||||
<title>Markdown previewer</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
</body>
|
||||
</html>
|
25
3-frontend-dev-libraries/2-markdown-previewer/src/App.css
Normal file
25
3-frontend-dev-libraries/2-markdown-previewer/src/App.css
Normal file
|
@ -0,0 +1,25 @@
|
|||
.App {
|
||||
height: 100vh;
|
||||
width: 100vw;
|
||||
background-color: #1d2228;
|
||||
margin: 0;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-evenly;
|
||||
align-items: center;
|
||||
overflow: hidden;
|
||||
}
|
||||
.App #editor, .App #preview {
|
||||
margin: 0;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
overflow: scroll;
|
||||
background-color: #fb8122;
|
||||
box-shadow: rgba(136, 165, 191, 0.48) 6px 2px 16px 0px, rgba(255, 255, 255, 0.8) -6px -2px 16px 0px;
|
||||
}
|
||||
.App #editor img, .App #preview img {
|
||||
max-width: 20rem;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
/*# sourceMappingURL=App.css.map */
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"sourceRoot":"","sources":["App.scss"],"names":[],"mappings":"AAGA;EACE;EACA;EACA,kBANO;EAOP;EACA;EACA;EACA;EACA;EACA;;AAEA;EACE;EACA;EACA;EACA;EACA,kBAlBK;EAmBL;;AAEA;EACE;EACA","file":"App.css"}
|
82
3-frontend-dev-libraries/2-markdown-previewer/src/App.js
Normal file
82
3-frontend-dev-libraries/2-markdown-previewer/src/App.js
Normal file
|
@ -0,0 +1,82 @@
|
|||
import './App.css';
|
||||
import Markdown from "marked-react"
|
||||
import React from "react";
|
||||
import defaultPreview from "./defaultPreview";
|
||||
|
||||
class App extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
input: defaultPreview,
|
||||
preview: defaultPreview,
|
||||
fullscreenEditor: false,
|
||||
fullscreenPreview: false,
|
||||
};
|
||||
}
|
||||
|
||||
updateText = (event) => {
|
||||
this.setState({input: event.target.value, preview: event.target.value})
|
||||
}
|
||||
|
||||
setFullscreen = (event, target) => {
|
||||
target === 'editor'
|
||||
? this.state.fullscreenEditor === false
|
||||
? this.setState({fullscreenEditor: true, fullscreenPreview: false})
|
||||
: this.setState({fullscreenEditor: false})
|
||||
: this.state.fullscreenPreview === false
|
||||
? this.setState({fullscreenPreview: true, fullscreenEditor: false})
|
||||
: this.setState({fullscreenPreview: false})
|
||||
}
|
||||
|
||||
render() {
|
||||
const editorStyle = {
|
||||
width: this.state.fullscreenEditor ? '80%' : '20%',
|
||||
display: this.state.fullscreenPreview ? 'none' : 'initial',
|
||||
opacity: this.state.fullscreenPreview ? '0' : '100',
|
||||
height: '80%',
|
||||
position: 'relative',
|
||||
|
||||
}
|
||||
const previewStyle = {
|
||||
width: this.state.fullscreenPreview ? '80%' : '40%',
|
||||
display: this.state.fullscreenEditor ? 'none' : 'initial',
|
||||
opacity: this.state.fullscreenEditor ? '0' : '100',
|
||||
height: '80%',
|
||||
position: 'relative',
|
||||
}
|
||||
return (
|
||||
<div className={"App"} style={{position: 'relative'}}>
|
||||
<div style={editorStyle}>
|
||||
<button
|
||||
id={"setFullscreenEditor"}
|
||||
style={{position: "absolute", right: 5, top: 5}}
|
||||
onClick={ (e) => this.setFullscreen(e, 'editor') }
|
||||
>
|
||||
<i className="fa-sharp fa-solid fa-expand"></i>
|
||||
</button>
|
||||
<textarea
|
||||
style={{resize: 'none', height: '100%', width: '100%'}}
|
||||
id="editor"
|
||||
onChange={this.updateText}
|
||||
value={this.state.input}
|
||||
></textarea>
|
||||
</div>
|
||||
<div style={previewStyle}>
|
||||
<button id={"setFullscreenPreview"}
|
||||
style={{position: "absolute", right: 5, top: 5}}
|
||||
onClick={ (e) => this.setFullscreen(e, 'preview') }
|
||||
>
|
||||
<i className="fa-sharp fa-solid fa-expand"></i>
|
||||
</button>
|
||||
<div id={'preview'} style={{maxHeight: '100%'}}>
|
||||
<Markdown gfm={true} breaks={true}>
|
||||
{this.state.preview}
|
||||
</Markdown>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default App;
|
28
3-frontend-dev-libraries/2-markdown-previewer/src/App.scss
Normal file
28
3-frontend-dev-libraries/2-markdown-previewer/src/App.scss
Normal file
|
@ -0,0 +1,28 @@
|
|||
$color1: #1d2228;
|
||||
$color2: #fb8122;
|
||||
|
||||
.App {
|
||||
height: 100vh;
|
||||
width: 100vw;
|
||||
background-color: $color1;
|
||||
margin: 0;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-evenly;
|
||||
align-items: center;
|
||||
overflow: hidden;
|
||||
|
||||
#editor, #preview{
|
||||
margin: 0;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
overflow: scroll;
|
||||
background-color: $color2;
|
||||
box-shadow: rgba(136, 165, 191, 0.48) 6px 2px 16px 0px, rgba(255, 255, 255, 0.8) -6px -2px 16px 0px;
|
||||
|
||||
img{
|
||||
max-width: 20rem;
|
||||
height: auto;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
const defaultPreview =
|
||||
`
|
||||
# Markdown preview!!!! yay!!!!!
|
||||
|
||||
## soooo many things to do here
|
||||
### some examples:
|
||||
|
||||
code, y'all know I like code: \`<div id="blabla"></div>\`
|
||||
|
||||
\`\`\`
|
||||
// Code, but many lineeeees
|
||||
|
||||
function blabla() {
|
||||
while (true) {
|
||||
console.log('FreeCodeCamp is awesome!');
|
||||
}
|
||||
}
|
||||
\`\`\`
|
||||
|
||||
Pretty **bold**... claim tbh.
|
||||
|
||||
Would be a shame if something ~~happened to it~~.
|
||||
|
||||
Please look at my [GitHub](https://github.com/CherryKitten) profile!
|
||||
|
||||
> Block Quotes!
|
||||
> WHAT
|
||||
> WHY
|
||||
> OKAY
|
||||
|
||||
|
||||
- Things I like:
|
||||
- Cats
|
||||
- Black ones
|
||||
- Orange ones
|
||||
- Grey ones
|
||||
- White ones
|
||||
- Striped ones
|
||||
- Dotted ones
|
||||
- And all those that I forgot
|
||||
|
||||
![freeCodeCamp Logo](https://cdn.freecodecamp.org/testable-projects-fcc/images/fcc_secondary.svg)
|
||||
|
||||
`
|
||||
|
||||
export default defaultPreview
|
13
3-frontend-dev-libraries/2-markdown-previewer/src/index.css
Normal file
13
3-frontend-dev-libraries/2-markdown-previewer/src/index.css
Normal file
|
@ -0,0 +1,13 @@
|
|||
body {
|
||||
margin: 0;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
||||
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
||||
sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
||||
monospace;
|
||||
}
|
12
3-frontend-dev-libraries/2-markdown-previewer/src/index.js
Normal file
12
3-frontend-dev-libraries/2-markdown-previewer/src/index.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
import React from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
import './index.css';
|
||||
import App from './App';
|
||||
|
||||
|
||||
const root = ReactDOM.createRoot(document.getElementById('root'));
|
||||
root.render(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
</React.StrictMode>
|
||||
);
|
Reference in a new issue