Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
bfc9d97
Init files
OphelieThomas33 Jan 15, 2023
c87a359
add input and button
OphelieThomas33 Jan 16, 2023
f1b8e42
test ts file
OphelieThomas33 Jan 17, 2023
83bd390
feat/add branch created
beren87 Jan 13, 2023
9d5b25f
modify multiplication.ts
OphelieThomas33 Jan 18, 2023
dc28b86
rebase
OphelieThomas33 Jan 15, 2023
ed1e057
add input and button
OphelieThomas33 Jan 16, 2023
4254b89
rebase
OphelieThomas33 Jan 18, 2023
edb9ef5
rebase
OphelieThomas33 Jan 18, 2023
5a3a2ce
Fix function
OphelieThomas33 Jan 19, 2023
c3a316f
add script to compile ==> npm run build, compile ts file and copy htm…
seb76370 Jan 20, 2023
dc87164
remove directory test
seb76370 Jan 20, 2023
db17fea
creat html & css calculator
beren87 Jan 15, 2023
173202e
first commit
ABBA-74 Jan 21, 2023
6e0c756
fix: issue on npm run build / remove all dist > build
ABBA-74 Jan 21, 2023
87eb877
update index.js to build project
seb76370 Jan 21, 2023
20a29ff
opt: added dataset for all calculator keys
ABBA-74 Jan 21, 2023
16769c5
opt: animtion btns on hover
ABBA-74 Jan 21, 2023
7c86be5
html: added title h1
ABBA-74 Jan 21, 2023
2e60537
Add vscode and dist in gitignore
OphelieThomas33 Jan 24, 2023
6c6271e
add vscode and dist in gitignore
OphelieThomas33 Jan 24, 2023
9145e68
add index.html and style.css in dist - change function to arrow funct…
OphelieThomas33 Jan 24, 2023
176f9a0
Revert "add index.html and style.css in dist - change function to arr…
OphelieThomas33 Jan 24, 2023
6ecf0d7
name of variables in english
OphelieThomas33 Jan 27, 2023
26a920a
test ts file
OphelieThomas33 Jan 17, 2023
075b838
modify multiplication.ts
OphelieThomas33 Jan 18, 2023
123b90e
Fix function
OphelieThomas33 Jan 19, 2023
df04cd1
Add vscode and dist in gitignore
OphelieThomas33 Jan 24, 2023
b2a77ed
add vscode and dist in gitignore
OphelieThomas33 Jan 24, 2023
77a2c27
add index.html and style.css in dist - change function to arrow funct…
OphelieThomas33 Jan 24, 2023
e7abe44
Revert "add index.html and style.css in dist - change function to arr…
OphelieThomas33 Jan 24, 2023
8c533ca
name of variables in english
OphelieThomas33 Jan 27, 2023
44a23d4
Merge branch 'feat/multiplication' of https://github.com/AlaAtrash/ca…
OphelieThomas33 Jan 27, 2023
fa11dec
multiplication of decimals
OphelieThomas33 Jan 27, 2023
0843a68
add validation function and multiplication if more than 2 decimals
OphelieThomas33 Jan 27, 2023
4beae0d
add script to compile ==> npm run build, compile ts file and copy htm…
seb76370 Jan 20, 2023
3ef57e3
remove directory test
seb76370 Jan 20, 2023
1bb50f4
creat html & css calculator
beren87 Jan 15, 2023
1758bd8
first commit
ABBA-74 Jan 21, 2023
ff0af33
fix: issue on npm run build / remove all dist > build
ABBA-74 Jan 21, 2023
113ed95
opt: added dataset for all calculator keys
ABBA-74 Jan 21, 2023
2264446
opt: animtion btns on hover
ABBA-74 Jan 21, 2023
7708b99
html: added title h1
ABBA-74 Jan 21, 2023
44db12e
Merge branch 'feat/homePageV2' of github.com:AlaAtrash/calculator int…
AlaAtrash Jan 27, 2023
501471f
Merge branch 'feat/homePageV2' into Temp/main
AlaAtrash Jan 31, 2023
73305a4
Merge pull request #5 from AlaAtrash/Temp/main
AlaAtrash Jan 31, 2023
955fa76
rebase
OphelieThomas33 Jan 15, 2023
245be99
add input and button
OphelieThomas33 Jan 16, 2023
d281a93
rebase
OphelieThomas33 Jan 18, 2023
ff8e39c
test ts file
OphelieThomas33 Jan 17, 2023
59d0cff
modify multiplication.ts
OphelieThomas33 Jan 18, 2023
7a157d1
Fix function
OphelieThomas33 Jan 19, 2023
d3ca44e
Add vscode and dist in gitignore
OphelieThomas33 Jan 24, 2023
444e0fa
add vscode and dist in gitignore
OphelieThomas33 Jan 24, 2023
1598d47
add index.html and style.css in dist - change function to arrow funct…
OphelieThomas33 Jan 24, 2023
a6a926e
Revert "add index.html and style.css in dist - change function to arr…
OphelieThomas33 Jan 24, 2023
e5b2f7a
name of variables in english
OphelieThomas33 Jan 27, 2023
5ba5eb4
Init files
OphelieThomas33 Jan 15, 2023
ad2d75d
add input and button
OphelieThomas33 Jan 16, 2023
ecf7240
modify multiplication.ts
OphelieThomas33 Jan 18, 2023
cb199b2
add index.html and style.css in dist - change function to arrow funct…
OphelieThomas33 Jan 24, 2023
9077fa7
Revert "add index.html and style.css in dist - change function to arr…
OphelieThomas33 Jan 24, 2023
4fe3493
multiplication of decimals
OphelieThomas33 Jan 27, 2023
d570c3b
add validation function and multiplication if more than 2 decimals
OphelieThomas33 Jan 27, 2023
cd9f168
Merge branch 'feat/multiplication' of github.com:AlaAtrash/calculator…
AlaAtrash Jan 31, 2023
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
node_modules/
node_modules/
dist/
.vscode/
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"liveServer.settings.port": 5501
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add to .gitignore

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's done

"liveServer.settings.port": 5502
}
Copy link
Copy Markdown
Collaborator

@ABBA-74 ABBA-74 Jan 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add to .gitignore ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok it's done

6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ $ npm install
```
$ npx tsc
$ npx tsc --watch (recompilation automatique)
```

## Compilation npm

```
$ npm run build

```

Expand All @@ -52,3 +57,4 @@ $ "files": ["src/index.ts", "src/sin_cos.ts"]
$ Dans un terminal taper la commande suivante:
$ node ./dist/<name_of_file>.js
```

1 change: 0 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
"use strict";
const compt = "55";
27 changes: 27 additions & 0 deletions dist/multiplication.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"use strict";
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add dist to .gitignore

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's done

const inputA = document.getElementById('numberA');
const inputB = document.getElementById('numberB');
let numberA;
let numberB;
const button = document.querySelector('.button-multiplication');
const showResult = document.getElementById('resultat');
let result = 1;
const multiplication = (...numbers) => {
if (numbers.includes(NaN) || numbers.includes(null)) {
showResult.textContent = "Merci de renseigner uniquement des valeurs numériques";
}
else {
console.log("ok ce sont des nombres");
for (const number of numbers) {
result *= number;
}
console.log(result);
showResult.textContent = "Résultat : " + result.toFixed(2);
result = 1;
}
};
button.addEventListener('click', () => {
numberA = parseFloat(inputA.value);
numberB = parseFloat(inputB.value);
multiplication(numberA, numberB);
});
66 changes: 53 additions & 13 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,56 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="style.css">
</head>

<body>
<html lang="fr">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Calculator</title>
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice !

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks :)

<link
href="https://fonts.googleapis.com/css2?family=Rubik:wght@700&display=swap"
rel="stylesheet"
/>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<h1>Project<br />Calculator TS</h1>
<div class="section-calculator">
<div class="calculator">
<div class="calculator-body">
<div class="screen">
<div class="result">3+6</div>
</div>
<div class="key key-opening-parenthesise key-opt" data-value="(">
(
</div>
<div class="key key-closing-parenthesise key-opt" data-value=")">
)
</div>
<div class="key key-cos key-opt" data-value="cos">COS</div>
<div class="key key-sin key-opt" data-value="sin">SIN</div>
<div class="key key-tan key-opt" data-value="tan">TAN</div>
<div class="key key-7 key-blue" data-value="7">7</div>
<div class="key key-7 key-blue" data-value="8">8</div>
<div class="key key-7 key-blue" data-value="9">9</div>
<div class="key key-division" data-value="/">/</div>
<div class="key key-C" data-value="c">C</div>
<div class="key key-4 key-blue" data-value="4">4</div>
<div class="key key-5 key-blue" data-value="5">5</div>
<div class="key key-6 key-blue" data-value="6">6</div>
<div class="key key-multiplication" data-value="*">x</div>
<div class="key key-equal" data-value="=">=</div>
<div class="key key-1 key-blue" data-value="1">1</div>
<div class="key key-2 key-blue" data-value="2">2</div>
<div class="key key-3 key-blue" data-value="3">3</div>
<div class="key key-substraction" data-value="-">-</div>
<div class="key key-plus-or-minus key-blue" data-value="+/-">+/-</div>
<div class="key key-0 key-blue" data-value="0">0</div>
<div class="key key-dot key-blue" data-value=".">.</div>
<div class="key key-addition" data-value="+">+</div>
</div>
</div>
</div>
<script type="module" src="dist/index.js"></script>
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<script type="module" src="index.js"></script>

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's done

</body>
</body>
</html>


</html>
46 changes: 46 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import * as fs from 'fs';
import { execSync } from 'child_process';
import * as path from 'path';

// example file and directory to copy
//const sourceDirectory = ["./", "./style"];
const sourceDirectory = ['./'];
const destinationDirectory = 'dist/';

if (fs.existsSync("./dist")) {
fs.rmSync(destinationDirectory, { recursive: true });
}

if (!fs.existsSync("./dist")) {
fs.mkdirSync("./dist");
}

sourceDirectory.forEach((dir) => {
cpyFile(dir, destinationDirectory);
});

function cpyFile(directory, destination) {
fs.readdir(directory, (err, files) => {
if (err) {
console.error(err);
return;
}

files.forEach((file) => {
if (path.extname(file) === '.html' || path.extname(file) === '.css') {
const sourceFile = path.join(directory, file);
let destinationFile = path.join(destination, directory);
fs.mkdir(destinationFile, { recursive: true }, (err) => {
if (err) throw err;
});
destinationFile = path.join(destinationFile, file);
const readStream = fs.createReadStream(sourceFile);
const writeStream = fs.createWriteStream(destinationFile);
readStream.pipe(writeStream);
}
});
});
}

//compile Ts file
execSync('npx tsc');
8 changes: 8 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

// let varNumb = document.getElementById('ids')

// varNumb?.addEventListener('click', () => {
// console.log('ok')
// })

//addition buttons function ===>
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
"name": "typescript",
"version": "1.0.0",
"description": "",
"main": "src/index.js",
"main": "src/multiplication.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"build": "node index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"typescript": "^4.8.4"
}
}
}
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
const compt:string = "55"
const compt:string = "55"
const compt2:string = "5555"
36 changes: 36 additions & 0 deletions src/multiplication.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const inputA = <HTMLInputElement>document.getElementById('numberA')
const inputB = <HTMLInputElement>document.getElementById('numberB')
let numberA: number
let numberB: number
const button = <HTMLButtonElement>document.querySelector('.button-multiplication')
const showResult = <HTMLParagraphElement>document.getElementById('resultat')
let result: number = 1


const multiplication = (...numbers: any) => {

if (numbers.includes(NaN) || numbers.includes(null)) {
showResult.textContent = "Merci de renseigner uniquement des valeurs numériques"

}
else {
console.log("ok ce sont des nombres")

for (const number of numbers) {
result *= number;
}
console.log(result)
showResult.textContent = "Résultat : " + result.toFixed(2);
result = 1
}

}


button.addEventListener('click', () => {
numberA = parseFloat(inputA.value)
numberB = parseFloat(inputB.value)
multiplication(numberA, numberB)
})


132 changes: 132 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/*** Reset CSS ***/
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Rubik', sans-serif;
}

body {
background-color: #e8c055;
background: linear-gradient(45deg, #e8c055, #e9dab2);
min-height: 100vh;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
font-size: 1.75rem;
color: rgb(246, 246, 246);
text-shadow: 0 3px 3px #00000033;
}

h1 {
text-align: center;
font-size: 3.6rem;
margin-bottom: 2.4rem;
line-height: 1.05;
text-shadow: 0 6px 6px #00000033;
}

/*** Calculator element ***/
.calculator {
width: clamp(23rem, 80vw, 50rem);
background-color: #404f66;
border-radius: 9px;
}

.calculator-body {
display: grid;
border-radius: 9px;
padding: 3rem;
grid-template-columns: repeat(5, 1fr);
grid-template-rows: repeat(6, 1fr);
column-gap: 1rem;
row-gap: 1rem;
box-shadow: 0 16px 16px #00000031;
}

.calculator-body > div {
background-color: #e8c055;
grid-column-end: span 1;
min-height: 2rem;
display: flex;
align-items: center;
justify-content: center;
border-radius: 6px;
box-shadow: 0 4px 4px #00000033;
}

.calculator-body .key-opt {
height: 2.8rem;
margin-top: 1.5rem;
}

.calculator-body .screen {
position: relative;
grid-column-end: span 5;
justify-content: end;
padding-right: 1rem;
overflow: hidden;
height: 100%;
width: 100%;
z-index: 10;
}

.calculator-body .screen::after {
position: absolute;
z-index: 5;
content: '';
width: 800px;
height: 100px;
background: #6699b1;
transform: skew(-50deg) translateX(50%);
}
.calculator-body .result {
position: relative;
z-index: 10;
letter-spacing: 0.25rem;
}
.calculator-body .screen,
.calculator-body .key-blue {
background-color: #709db0;
}

.calculator-body .key-equal {
grid-row-end: span 3;
}

.calculator-body .key {
cursor: pointer;
transition: background-color 0.3s ease-out;
}
.calculator-body .key:hover {
background-color: #c7a549;
}
.calculator-body .key-blue:hover {
background-color: #5c8191;
}

/*** Media queries ***/
@media screen and (max-width: 800px) {
body {
font-size: 1.5rem;
}
h1 {
font-size: 2.6rem;
}
.calculator {
min-width: 100%;
}
.calculator-body {
padding: 1.5rem;
}
}
@media screen and (max-width: 500px) {
body {
font-size: 1rem;
}
.calculator-body {
padding: 1rem;
}
}
Loading