Skip to content

Commit

Permalink
Merge pull request #22 from ms-club-sliit/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
rusiruavb authored Dec 16, 2021
2 parents 525a643 + c457ce0 commit 8b3c7fe
Show file tree
Hide file tree
Showing 30 changed files with 3,552 additions and 247 deletions.
27 changes: 25 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,47 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@hookform/resolvers": "^2.8.5",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"@types/jest": "^26.0.15",
"@types/jquery": "^3.5.10",
"@types/node": "^12.0.0",
"@types/react": "^17.0.0",
"@types/react-avatar-editor": "^10.3.6",
"@types/react-bootstrap-table-next": "^4.0.16",
"@types/react-bootstrap-table2-paginator": "^2.1.2",
"@types/react-dom": "^17.0.0",
"@types/react-rangeslider": "^2.2.4",
"@types/react-rte": "^0.16.3",
"axios": "^0.24.0",
"env-cmd": "^10.1.0",
"html-to-react": "^1.4.7",
"jquery": "^3.6.0",
"mdbreact": "^5.2.0",
"moment": "^2.29.1",
"node-sass": "4.14.1",
"react": "^17.0.2",
"react-avatar-editor": "^12.0.0",
"react-bootstrap-table-next": "^4.0.3",
"react-bootstrap-table2-paginator": "^2.1.2",
"react-bootstrap-table2-toolkit": "^2.1.3",
"react-dom": "^17.0.2",
"react-hook-form": "^7.21.2",
"react-rangeslider": "^2.2.0",
"react-redux": "^7.2.6",
"react-router-dom": "^6.0.2",
"react-rte": "^0.16.4",
"react-scripts": "4.0.3",
"react-select": "^5.2.1",
"react-toastify": "^8.1.0",
"redux": "^4.1.2",
"redux-promise-middleware": "^6.1.2",
"serve": "^13.0.2",
"typescript": "^4.1.2",
"web-vitals": "^1.0.1"
"web-vitals": "^1.0.1",
"yup": "^0.32.11"
},
"scripts": {
"start": "react-scripts start",
Expand All @@ -40,7 +55,14 @@
"extends": [
"react-app",
"react-app/jest"
]
],
"plugins": [
"react-hooks"
],
"rules": {
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn"
}
},
"browserslist": {
"production": [
Expand All @@ -55,6 +77,7 @@
]
},
"devDependencies": {
"@types/bootstrap": "^5.1.6",
"@types/react-bootstrap-table2-toolkit": "^2.1.5",
"@types/react-redux": "^7.1.20",
"@types/redux": "^3.6.0",
Expand Down
20 changes: 16 additions & 4 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
<meta name="theme-color" content="#000000" />

<!-- MDB Library -->
<link rel="stylesheet" href="./assets/css/mdb.min.css" />
<link
href="https://cdnjs.cloudflare.com/ajax/libs/mdb-ui-kit/3.10.1/mdb.min.css"
rel="stylesheet"
/>

<title>MS CLUB SLIIT</title>
</head>
Expand All @@ -16,9 +19,18 @@
<div id="root"></div>

<!-- MDB Scripts -->
<script type="text/javascript" src="./assets/js/mdb.min.js"></script>

<script
type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/mdb-ui-kit/3.10.1/mdb.min.js"
></script>

<!-- Font Awesome Scritps -->
<script src="https://kit.fontawesome.com/12c182894b.js" crossorigin="anonymous"></script>
<script
src="https://kit.fontawesome.com/12c182894b.js"
crossorigin="anonymous"
></script>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</body>
</html>
76 changes: 71 additions & 5 deletions src/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

/**
MS Club of SLIIT Website - Media Query Template
MS Club of SLIIT Admin Pannel - Media Query Template
@include media("<=phone") {}
@include media(">=phone", '<tablet') {}
@include media('>=tablet', '<smalldesktop') {}
Expand All @@ -17,21 +17,29 @@
@import "./styles/breakpoints.scss";
@import "react-bootstrap-table-next/dist/react-bootstrap-table2.min.css";
@import "react-bootstrap-table2-paginator/dist/react-bootstrap-table2-paginator.min.css";
@import "react-toastify/dist/ReactToastify.css";
@import "react-rangeslider/lib/index.css";
@import "./styles/colors.scss";
@import "./styles/navbar.scss";
@import "./styles/table.scss";
@import "./styles/events.scss";
@import "./styles/image-canvas.scss";

.container {
margin-top: 70px;
margin-top: 80px;
}

p {
margin-bottom: 5px;
line-height: 19px;
}

.btn {
text-transform: unset !important;
}

.card {
border-radius: 0px;
border-radius: 4px;
padding: 15px;
}

Expand All @@ -49,7 +57,65 @@ footer {
}

.page-description {
font-family: "Roboto Regular";
font-size: 16px;
font-family: "Poppins Regular";
font-size: 13px;
margin-top: 0px;
}

.badge {
font-family: "Poppins Light";
font-size: 11px;
}

.form-control {
border: 1;
font-size: 14px;
height: 35px;
padding-left: 8px;
margin-bottom: 0px;
}

.form-control:focus {
border: 0px !important;
font-size: 14px;
height: 35px;
padding-left: 8px;
}

.form-label {
font-size: 14px;
margin-bottom: 0px;
}

.modal-header {
border-bottom: none;
}

.modal-title {
font-size: 16px;
}

.modal-footer {
border-top: none;
}

.modal-body {
background-color: #f4f7fa;
}

.modal-content {
-webkit-border-radius: 0px !important;
-moz-border-radius: 0px !important;
border-radius: 4px !important;
}

.validation-message {
font-size: 12px;
margin: 0px !important;
padding: 0px !important;
}

.toastBody {
font-family: "Poppins Regular";
font-size: 14px;
}
8 changes: 5 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React from 'react';
import AppRoutes from './routes/app-routes';
import './App.scss';
import React from "react";
import { ToastContainer } from "react-toastify";
import AppRoutes from "./routes/app-routes";
import "./App.scss";

const App: React.FC = () => (
<div>
<AppRoutes />
<ToastContainer bodyClassName="toastBody" />
</div>
);

Expand Down
144 changes: 144 additions & 0 deletions src/components/image-canvas/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
import { useState } from "react";
import AvatarEditor from "react-avatar-editor";
import Slider from "react-rangeslider";

interface CanvasProps {
getEditedImage: (data: any) => any;
width: number;
height: number;
}

const resizeImage = (image: any, width: number, height: number) => {
let canvas = document.createElement("canvas");
let context = canvas.getContext("2d");

canvas.width = image.width > width ? width : image.width;
canvas.height = image.height > height ? height : image.height;

context?.drawImage(image, 0, 0, canvas.width, canvas.height);
return canvas.toDataURL("image/jpeg");
};

/**
* Image previewer and editor
* @param props getEditedImage (Callback function)
* @param props width (Canvas width)
* @param props height (Canvas height)
* @returns base64 edited image
* @example
* const handleImage = (data: any) => {
* setImageData(data); // This is the base64 image
* }
*
* const SomeForm: React.FC = () => {
* return (
* <ImageCanvas getEditedImage={handleImage} />
* )
* }
*/
const ImageCanvas = (props: CanvasProps) => {
const [zoomLevel, setZoomLevel] = useState<number>(1);
const [rotate, setRotation] = useState<number>(0);
const [imgSrc, setImgSrc] = useState<any>("");
const [editor, setEditor] = useState<any>();

const configureEditor = (editor: any) => {
setEditor(editor);
};

const changeZoomLevel = (level: number) => {
setZoomLevel(level);
};

const changeRotation = () => {
let rotation = rotate + 90;

if (rotation >= 360) {
rotation = 0;
}

setRotation(rotation);
};

const handleImage = (event: any) => {
setImgSrc(event.target.files[0]);
};

const saveChanges = async (event: any) => {
let image: any = editor.getImage();
image = resizeImage(image, props.width, props.height);

let binary = atob(image.split(",")[1]);
let arr = [];
for (let i = 0; i < binary.length; i++) {
arr.push(binary.charCodeAt(i));
}
let blob = new Blob([new Uint8Array(arr)], { type: "image/jpeg" });
let file = new File([blob], imgSrc.name);
props.getEditedImage(file);
};

return (
<div>
<div className="justiy-content-md-center text-center mb-3 mx-5">
<input
type="file"
className="text-center image-selector"
accept="image/*"
name="imageSrc"
id="imageFile"
onChange={(e) => handleImage(e)}
/>
</div>

{imgSrc ? (
<div className="row">
<div className="form-group g-0 d-flex justify-content-md-center image-editor">
<AvatarEditor
ref={configureEditor}
image={imgSrc}
border={0}
width={props.width}
height={props.height}
borderRadius={0}
color={[0, 0, 0, 0.6]}
scale={zoomLevel}
rotate={rotate}
onPositionChange={saveChanges}
onLoadSuccess={saveChanges}
/>

<div className="slider orientation-reversed mx-4">
<div className="slider-group">
<div className="slider-vertical">
<Slider
min={1}
max={8}
step={0.1}
tooltip={false}
orientation="vertical"
value={zoomLevel}
onChange={changeZoomLevel}
onChangeComplete={saveChanges}
/>
</div>
</div>
</div>
</div>

<div className="d-flex justify-content-center">
<button
type="button"
className="btn btn-primary btn-pill shadow-none btn-sm mt-3"
onClick={changeRotation}
>
<i className="fas fa-undo rotate-icon"></i>
</button>
</div>
</div>
) : null}
</div>
);
};

export default ImageCanvas;
Loading

0 comments on commit 8b3c7fe

Please sign in to comment.