NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

import React, { useState } from 'react';

const shapes = [
{ name: 'Point', description: 'A single location in space, often represented by a dot.' },
{ name: 'Line', description: 'A straight path that extends infinitely in both directions.' },
{ name: 'Line Segment', description: 'A finite portion of a line, defined by two endpoints.' },
{ name: 'Ray', description: 'A portion of a line that extends indefinitely in one direction from a starting point.' },
{ name: 'Angle', description: 'Formed by two rays or line segments with a common endpoint.' },
{ name: 'Polygon', description: 'A closed shape made up of line segments joined end to end. Examples include triangles, quadrilaterals, pentagons, etc.' },
{ name: 'Triangle', description: 'A polygon with three sides and three angles.' },
{ name: 'Quadrilateral', description: 'A polygon with four sides. Examples include rectangles, squares, parallelograms, trapezoids, etc.' },
{ name: 'Circle', description: 'A set of all points equidistant from a fixed point called the center.' },
{ name: 'Ellipse', description: 'A set of all points such that the sum of the distances from two fixed points (foci) is constant.' },
{ name: 'Parabola', description: 'The set of all points equidistant from a fixed point (focus) and a fixed line (directrix).', },
{ name: 'Hyperbola', description: 'The set of all points such that the difference of the distances from two fixed points (foci) is constant.' },
{ name: 'Arc', description: 'A portion of the circumference of a circle.' },
{ name: 'Sector', description: 'The portion of a circle enclosed by two radii and an arc.' },
{ name: 'Trapezoid', description: 'A quadrilateral with at least one pair of parallel sides.' },
{ name: 'Rhombus', description: 'A quadrilateral with all sides of equal length.' },
{ name: 'Regular Polygon', description: 'A polygon with all sides and angles equal.' },
{ name: 'Pentagon', description: 'A polygon with five sides.' },
{ name: 'Hexagon', description: 'A polygon with six sides.' },
{ name: 'Octagon', description: 'A polygon with eight sides.' },
{ name: 'Sphere', description: 'The set of all points in space equidistant from a fixed point (center).', },
{ name: 'Cylinder', description: 'A three-dimensional shape with two parallel circular bases connected by a curved surface.' },
{ name: 'Cone', description: 'A three-dimensional shape with a circular base and a single vertex.' },
{ name: 'Rectangular Prism', description: 'A three-dimensional shape with six rectangular faces, opposite faces are congruent.' },
{ name: 'Pyramid', description: 'A three-dimensional shape with a polygonal base and triangular faces that meet at a common vertex.' },
];

const ShapeInfo = ({ name, description, dimensions }) => (
<div>
<h2>{name}</h2>
<p>{description}</p>
{dimensions && (
<div>
{dimensions.map((dimension) => (
<p key={dimension.name}>{dimension.name}: {dimension.value}</p>
))}
</div>
)}
</div>
);

const App = () => {
const [selectedShape, setSelectedShape] = useState(null);
const [showDimensions, setShowDimensions] = useState(false);

const handleShapeSelection = (shape) => {
setSelectedShape(shape);
};

const handleDimensionToggle = () => {
setShowDimensions(!showDimensions);
};

let dimensions = null;
if (selectedShape && showDimensions) {
switch (selectedShape.name) {
case 'Rectangle':
case 'Square':
dimensions = [{ name: 'Height', value: 100 }, { name: 'Width', value: 50 }]; // Replace with actual input if needed
break;
case 'Circle':
dimensions = [{ name: 'Radius', value: 25 }]; // Replace with actual input if needed
break;
case 'Triangle':
dimensions = [{ name: 'Height', value: 80 }, { name: 'Base', value: 60 }]; // Replace with actual input if needed
break;
case 'Trapezoid':
dimensions = [
{ name: 'Height', value: 70 }, // Replace with actual input if needed
{ name: 'Base 1', value: 40 }, // Replace with actual input if needed
{ name: 'Base 2', value: 50 }, // Replace with actual input if needed
];
break;
case 'Rhombus':
dimensions = [{ name: 'Side', value: 30 }]; // Replace with actual input if needed
break;
case 'Regular Polygon': // Assuming number of sides is known (replace with actual input if needed)
dimensions = [
{ name: 'Side', value: 20 }, // Replace with actual input if needed
{ name: 'Apothem', value: 15 }, // Replace with actual input if needed
];
break;
case 'Pentagon':
case 'Hexagon':
case 'Octagon':
// Add dimensions for these shapes (replace with actual input if needed)
dimensions = [];
break;
case 'Sphere':
dimensions = [{ name: 'Radius', value: 12 }]; // Replace with actual input if needed
break;
case 'Cylinder':
dimensions = [
{ name: 'Height', value: 80 }, // Replace with actual input if needed
{ name: 'Radius', value: 18 }, // Replace with actual input if needed
];
break;
case 'Cone':
dimensions = [
{ name: 'Height', value: 60 }, // Replace with actual input if needed
{ name: 'Radius', value: 15 }, // Replace with actual input if needed
];
break;
case 'Rectangular Prism':
dimensions = [
{ name: 'Length', value: 100 }, // Replace with actual input if needed
{ name: 'Width', value: 50 }, // Replace with actual input if needed
{ name: 'Height', value: 75 }, // Replace with actual input if needed
];
break;
case 'Pyramid':
dimensions = [
{ name: 'Height', value: 50 }, // Replace with actual input if needed
{ name: 'Base Side', value: 20 }, // Replace with actual input if needed (assuming all sides of the base are equal)
];
break;
default:
dimensions = [];
}
}

const handleDimensionInput = (event) => {
// Implement logic to handle user input for dimensions based on the selected shape
};

return (
<div className="App">
<h1>Shape Explorer</h1>
<div>
<h2>Select a Shape:</h2>
<ul>
{shapes.map((shape) => (
<li key={shape.name} onClick={() => handleShapeSelection(shape)}>
{shape.name}
</li>
))}
</ul>
</div>
<div>
<label htmlFor="showDimensions">
<input
type="checkbox"
id="showDimensions"
checked={showDimensions}
onChange={handleDimensionToggle}
/>
Show Dimensions
</label>
{selectedShape && (
<ShapeInfo name={selectedShape.name} description={selectedShape.description} dimensions={dimensions} />
)}
{showDimensions && (
<div>
{/* Implement UI elements to allow user input for dimensions based on the selected shape */}
<button onClick={handleDimensionInput}>Update Dimensions</button>
</div>
)}
</div>
</div>
);
};

export default App;

     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.