Skip to content

Commit

Permalink
eslint config added and errors corrected
Browse files Browse the repository at this point in the history
  • Loading branch information
subhangi2731 committed May 29, 2021
1 parent cb20ae3 commit 4162177
Show file tree
Hide file tree
Showing 41 changed files with 34,825 additions and 13,799 deletions.
43 changes: 43 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
module.exports = {
"env": {
"browser": true,
"es2021": true,
"node": true,
"jest":true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended"
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": [
"react"
],
"rules": {
"react/prop-types": "off",
"no-mixed-spaces-and-tabs": 0,
"react/no-unescaped-entities": 0,
"indent": [
"error",
"tab"
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"double"
],
"semi": [
"error",
"always"
]
}
};
20,386 changes: 20,333 additions & 53 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@
"*.{js,css,md}": "prettier --write"
},
"devDependencies": {
"eslint": "^7.27.0",
"eslint-plugin-react": "^7.23.2",
"gh-pages": "^3.1.0"
}
}
42 changes: 21 additions & 21 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import Preloader from "./components/Preloader/Preloader";
import { ThemeProvider, createMuiTheme } from "@material-ui/core/styles";

const theme = createMuiTheme({
typography: {
fontFamily: "'Montserrat', sans-serif",
},
typography: {
fontFamily: "'Montserrat', sans-serif",
},
});
const Home = lazy(() => import("./pages/Home/Home"));
const Editor = lazy(() => import("./pages/Editor/Editor"));
Expand All @@ -21,24 +21,24 @@ const MediaManip = lazy(() => import("./pages/MediaManip/MediaManip"));
window.isHome = true;

function App({ location }) {
return (
<ThemeProvider theme={theme}>
<Suspense fallback={<Preloader />}>
{location.pathname !== "/404" && <Header />}
<Switch>
<Route path="/" exact component={Home} />
<Route path="/editor" exact component={Editor} />
<Route path="/sketch" exact component={Sketch} />
<Route path="/mediamanip" exact component={MediaManip} />
<Route path="/404" exact component={NotFound} />
<Redirect to="/404" />
</Switch>
{location.pathname !== "/404" && location.pathname !== "/sketch" && (
<Footer />
)}
</Suspense>
</ThemeProvider>
);
return (
<ThemeProvider theme={theme}>
<Suspense fallback={<Preloader />}>
{location.pathname !== "/404" && <Header />}
<Switch>
<Route path="/" exact component={Home} />
<Route path="/editor" exact component={Editor} />
<Route path="/sketch" exact component={Sketch} />
<Route path="/mediamanip" exact component={MediaManip} />
<Route path="/404" exact component={NotFound} />
<Redirect to="/404" />
</Switch>
{location.pathname !== "/404" && location.pathname !== "/sketch" && (
<Footer />
)}
</Suspense>
</ThemeProvider>
);
}

export default withRouter(App);
8 changes: 4 additions & 4 deletions src/App.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { render, screen } from "@testing-library/react";
import React,{ render, screen } from "@testing-library/react";
import App from "./App";

test("renders learn react link", () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});
104 changes: 52 additions & 52 deletions src/components/Dropdown/Dropdown.jsx
Original file line number Diff line number Diff line change
@@ -1,67 +1,67 @@
import { useState, useContext } from "react";
import React,{ useState, useContext } from "react";
import { Dropdown, DropdownToggle, DropdownMenu, DropdownItem } from "reactstrap";

import styles from "./dropdown.module.scss";
import { EditContext } from "../../pages/Editor/containers/editContext";

const DropdownComponent = props => {
const [dropdownOpen, setDropdownOpen] = useState(false);
const toggle = () => setDropdownOpen(prevState => !prevState);
const [dropdownOpen, setDropdownOpen] = useState(false);
const toggle = () => setDropdownOpen(prevState => !prevState);

const editContext = useContext(EditContext);
const editContext = useContext(EditContext);

const colors = ["black", "red", "orange", "blue", "green", "deeppink", "darkviolet", "dodgerblue"];
const colors = ["black", "red", "orange", "blue", "green", "deeppink", "darkviolet", "dodgerblue"];

const setValue = aItemValue => {
if (colors.includes(aItemValue)) {
if (aItemValue === "dodgerblue") {
return "Light Blue";
} else if (aItemValue === "deeppink") {
return "Pink";
} else if (aItemValue === "darkviolet") {
return "Violet";
} else {
return aItemValue.charAt(0).toUpperCase() + aItemValue.slice(1);
}
} else {
return aItemValue;
}
};
const setValue = aItemValue => {
if (colors.includes(aItemValue)) {
if (aItemValue === "dodgerblue") {
return "Light Blue";
} else if (aItemValue === "deeppink") {
return "Pink";
} else if (aItemValue === "darkviolet") {
return "Violet";
} else {
return aItemValue.charAt(0).toUpperCase() + aItemValue.slice(1);
}
} else {
return aItemValue;
}
};

const DropDownOptions = () => {
return (
<div>
{props.items.map((aItem, index) => (
<DropdownItem
onClick={getTargetFunc()}
name={props.type === "download" ? aItem : `body${props.type === "font" ? "Font" : props.type === "font-weight" ? "FontWeight" : "Color"}`}
value={aItem}
style={{ "font-family": `${aItem}`, color: `${aItem}`, "font-weight": `${aItem}` }}
key={index}
>
{setValue(aItem)}
</DropdownItem>
))}
</div>
);
};
const DropDownOptions = () => {
return (
<div>
{props.items.map((aItem, index) => (
<DropdownItem
onClick={getTargetFunc()}
name={props.type === "download" ? aItem : `body${props.type === "font" ? "Font" : props.type === "font-weight" ? "FontWeight" : "Color"}`}
value={aItem}
style={{ "font-family": `${aItem}`, color: `${aItem}`, "font-weight": `${aItem}` }}
key={index}
>
{setValue(aItem)}
</DropdownItem>
))}
</div>
);
};

const getTargetFunc = () => {
if (props.type === "font" || props.type === "color" || props.type === "font-weight") return editContext.onValueChange;
else if (props.type === "download") return editContext.downloadAction;
return editContext.pageSrcHandler;
};
const getTargetFunc = () => {
if (props.type === "font" || props.type === "color" || props.type === "font-weight") return editContext.onValueChange;
else if (props.type === "download") return editContext.downloadAction;
return editContext.pageSrcHandler;
};

return (
<Dropdown isOpen={dropdownOpen} toggle={toggle}>
<DropdownToggle caret className={styles.drbtn}>
{props.name} ({props.active})
</DropdownToggle>
<DropdownMenu>
<DropDownOptions />
</DropdownMenu>
</Dropdown>
);
return (
<Dropdown isOpen={dropdownOpen} toggle={toggle}>
<DropdownToggle caret className={styles.drbtn}>
{props.name} ({props.active})
</DropdownToggle>
<DropdownMenu>
<DropDownOptions />
</DropdownMenu>
</Dropdown>
);
};

export default DropdownComponent;
64 changes: 32 additions & 32 deletions src/components/Footer/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,36 @@ import JSONAnimation from "../../assets/githublogo/github.json";
import github from "react-useanimations/lib/github";

export default function Footer(props) {
return (
<div className={`${styles.footerDiv}`}>
<div className={styles.topShape}>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 100" preserveAspectRatio="none">
<path
style={{ fill: props.fill ? props.fill : "white" }}
className={styles.svgPath}
d="M761.9,44.1L643.1,27.2L333.8,98L0,3.8V0l1000,0v3.9"
></path>
</svg>
</div>
<div className={styles.tint}></div>
<div className={styles.githubLogoDiv}>
<a href="https://github.com/smaranjitghose/doc2pen">
<UseAnimations
className={styles.githubLogo}
animation={github}
animationkey={JSONAnimation}
size={50}
loop={true}
strokeColor="#ffffff"
speed={1}
/>
</a>
</div>
<div>
<Fade>
<p className={styles.footerText}>{emoji("Made with ❤️ in India for the students of the world.")}</p>
</Fade>
</div>
</div>
);
return (
<div className={`${styles.footerDiv}`}>
<div className={styles.topShape}>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 100" preserveAspectRatio="none">
<path
style={{ fill: props.fill ? props.fill : "white" }}
className={styles.svgPath}
d="M761.9,44.1L643.1,27.2L333.8,98L0,3.8V0l1000,0v3.9"
></path>
</svg>
</div>
<div className={styles.tint}></div>
<div className={styles.githubLogoDiv}>
<a href="https://github.com/smaranjitghose/doc2pen">
<UseAnimations
className={styles.githubLogo}
animation={github}
animationkey={JSONAnimation}
size={50}
loop={true}
strokeColor="#ffffff"
speed={1}
/>
</a>
</div>
<div>
<Fade>
<p className={styles.footerText}>{emoji("Made with ❤️ in India for the students of the world.")}</p>
</Fade>
</div>
</div>
);
}
Loading

0 comments on commit 4162177

Please sign in to comment.