Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhanced Conductivity And Resistivity Calculator UI #1455

Merged
merged 16 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from 13 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
19 changes: 15 additions & 4 deletions Calculators/Conductivity-And-Resistivity-Calculator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,23 @@
</head>

<body>


<div class="calculator">
<input type="number" id="resistanceInput" placeholder="Enter Resistance">
<input type="number" id="lengthInput" placeholder="Enter Length">
<input type="number" id="areaInput" placeholder="Enter Cross-sectional Area">
<div class="heading">
<h1>Conductivity and Resistivity Calculator</h1>
</div>
<div class="inputcontainer">
<input type="number" id="resistanceInput" placeholder="Enter Resistance">
<input type="number" id="lengthInput" placeholder="Enter Length">
<input type="number" id="areaInput" placeholder="Enter Cross-sectional Area">
</div>

<button onclick="calculate()">Calculate</button>
<div id="result"></div>
<div id="result">
<input type="text" id="resistivityresult" placeholder="Resistivity" disabled>
<input type="text" id="conductivityresult" placeholder="Conductivity" disabled>
</div>
</div>
<script src="script.js"></script>
</body>
Expand Down
12 changes: 8 additions & 4 deletions Calculators/Conductivity-And-Resistivity-Calculator/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,20 @@ function calculate() {

// Check if inputs are valid
if (isNaN(resistance) || isNaN(length) || isNaN(area)) {
document.getElementById("result").innerText = "Please enter valid numbers.";
document.getElementById("conductivityresult").value = `Invalid Input`;
document.getElementById("resistivityresult").value = `Invalid Input`;
return;
}

// Calculate conductivity using the formula: conductivity = 1 / resistance
const conductivity = 1 / resistance;
const number1 = 1 / resistance
const conductivity = number1.toFixed(12);

// Calculate resistivity using the formula: resistivity = resistance * (area / length)
const resistivity = resistance * (area / length);
const number2=resistance * (area / length);
const resistivity = number2.toFixed(12);

// Display the result
document.getElementById("result").innerText = `Conductivity: ${conductivity} S/m\nResistivity: ${resistivity} ohm*m`;
document.getElementById("conductivityresult").value = `Conductivity: ${conductivity} S/m`;
document.getElementById("resistivityresult").value = `Resistivity: ${resistivity} ohm-m`;
}
28 changes: 26 additions & 2 deletions Calculators/Conductivity-And-Resistivity-Calculator/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ body {
align-items: center;
height: 100vh;
margin: 0;
background: linear-gradient(45deg, #7F7FD5, #86A8E7, #91EAE4);
background: linear-gradient(60deg, #4709ab, #482fd3, #0f9e94);
}

.calculator {
Expand All @@ -16,6 +16,8 @@ body {
animation: fadeIn 1s ease-in-out;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
transition: box-shadow 0.3s ease-in-out;
max-width: fit-content;
height: 42%;
}

.calculator:hover {
Expand All @@ -38,7 +40,7 @@ input:focus {
button {
padding: 12px;
cursor: pointer;
background: linear-gradient(90deg, #FF5E79, #FF8C6B);
background: linear-gradient(90deg, #df677b, #efb043);
color: white;
border: none;
border-radius: 5px;
Expand All @@ -52,11 +54,26 @@ button:hover {
}

#result {
display: flex;
justify-content:space-between;
align-items: center;
gap: 10px;
margin-top: 10px;
font-weight: bold;
animation: fadeIn 1s ease-in-out;
}

#result input {
border-radius: 10px;
padding: 10px;
justify-content: space-evenly;
align-items: center;
width: 100%;
font-size: 15px;


}

@media (max-width: 600px) {
.calculator {
width: 90%;
Expand All @@ -69,4 +86,11 @@ button:hover {
button {
width: 100%;
}
}
.heading {
font-size: 17px;
margin-bottom: 10px;
font-family:'Times New Roman', Times, serif;
font-weight: bold;
color: #0d757a;
}