Step 1. Create the markup
We added a temperature toggle switch to the new Figma design:
Add a new ToggleSwitch component to your application and create the markup for the switch. Use the checkbox input type and implement custom styles for it according to the design.
This small piece of UI is more complicated under the hood than it would first seem. Although we could tell you how to implement it here, in the real world, you’ll often have to search around for solutions. Luckily, the React ecosystem is quite active, so examples of components are not hard to find. Here are a few to get you started:
For an explanation of how to set up a basic React checkbox component, check out this short tutorial.
For ideas on how to turn the checkbox into a toggle switch, check out this article.
Independently researching and implementing functionality like this is a critical skill for a software engineer. This is a great time to get some practice!
Step 2. Create a currentTemperatureUnit state in the root component
In the App component, create a currentTemperatureUnit state variable. Pass the string "F" as the initial value:
const [currentTemperatureUnit, setCurrentTemperatureUnit] = useState('F');
Step 3. Create a context object
To use context in our components, you may recall that we need to create a context object and wrap all elements that need to access the context in its provider.
We'll create the context object in a separate directory. To do so, create a contexts folder and add a new file called [login to view URL] there. The file's path should look like this: src/contexts/CurrentTemperatureUnitContext.js. Export a new context object from this file.
Import this object into App and use its provider. Wrap all the current content of the root component with it. For the provider's value, pass an object with currentTemperatureUnit and handleToggleSwitchChange as properties.
<div className="page">
<[login to view URL]
value={{ currentTemperatureUnit, handleToggleSwitchChange }}
>
{/* Contents of the App component */}
</[login to view URL]>
</div>
Step 4. Extract a new value from the weather API
Previously, we extracted the current temperature value in Fahrenheit. To be able to use the value in Celsius, we need to extract it from the OpenWeather API as we did with the Fahrenheit value. (You can refer to the documentation if needed.) You can create a nested object for the temperature values:
weather.temperature.F = [login to view URL];
weather.temperature.C = [login to view URL](([login to view URL] - 32) * 5/9);
Pay attention to the second line above. We receive a Fahrenheit value from the API and transform this value to Celsius.
Step 5. Use context in ToggleSwitch
Import the current unit context to the ToggleSwitch component and subscribe to it in order to get its value. Use the checkbox value and component state to toggle the measurement unit. When the checkbox is clicked, handle the toggle switch change by creating a corresponding method in [login to view URL]:
const handleToggleSwitchChange = () => {
currentTemperatureUnit === 'F'
? setCurrentTemperatureUnit('C')
: setCurrentTemperatureUnit('F');
};
Step 6. Use context in WeatherCard
Import CurrentTemperatureUnitContext into the WeatherCard component to get the context value.
Now you have the temperature unit value derived from the context. Use it to modify the temperature value displayed on the card. If you made the temperature object as we showed above, the following value can be displayed:
{[login to view URL][currentTemperatureUnit]}
Step 7. Use context in Main
We also display the temperature value in the Main component. Import it there and modify the displayed value.
Add a /profile route
We have a hardcoded username and avatar in the app header. You'll learn how to implement user authorization later in the program. For now, we'll prepare a hardcoded profile page for users using React Router.
Step 1. Create a new Profile component
The main page displays clothing items that match the current weather type. We can see from Figma that we need a place where we will see all the cards. The new Profile component will include two components inside:
SideBar displays the current user's username and avatar (still hardcoded).
ClothesSection displays all the clothing items from the current application state and includes a button that opens the AddItemModal component.
image
Step 2. Install React Router
npm install react-router-dom@6
Step 3. Configure routes
Configure routes in [login to view URL] for two paths:
/ for the Main component
/profile for the Profile component
Step 4. Add navigation links to Header
Use Link to turn the header elements into navigation links:
Clicking the logo leads to the main page (/)
Clicking the profile information leads to the profile page (/profile)
Complete the form for adding a clothing item
Finally, let's make our form add a new clothing item to the application state.
Step 1. Create the AddItemModal component
Create a new component called AddItemModal and import it into App.js. The contents of this component will be the corresponding ModalWithForm component and all of its children.
Handle the form data by the component's state by creating handlers corresponding to the onChange event of each state variable (name, imageUrl, weather).
Create a submit handler to prevent default behavior and call the corresponding onAddItem() method with the appropriate arguments:
// onAddItem refers to handleAddItemSubmit, which is declared in [login to view URL]
const AddItemModal = ({ isOpen, onAddItem, onCloseModal }) => {
// declare state for each input field
// use a useEffect hook to reset the input field state to empty strings when
// the modal is opened
// create onChange handlers corresponding to each state variable
function handleSubmit(e) {
// prevent default behavior
// call onAddItem with appropriate arguments
}
return (
{/* don't forget to pass appropriate props to ModalWithForm */}
<ModalWithForm>
{/* the contents of the form will go in here */}
</ModalWithForm>
);
};
export default AddItemModal;
Step 2. Save an item
Add the handleAddItemSubmit handler to App.js. In this handler, call the corresponding methods from [login to view URL] and update the clothingItems (your name may differ) state with an extended copy of the current array using the spread ... operator:
setClothingItems([item, ...clothingItems]);
If everything is working correctly, new items should appear at the beginning of the list. After refreshing the page, the new cards will disappear. To save them, we'll need a server with a database. (However, there's no need to think about saving cards just yet.)
Add functionality to delete cards
Step 1. Add a delete button
Add a delete button inside the ItemModal component according to the Figma design. When implementing the functionality to delete a card, you can choose from the following two options:
The card is deleted immediately when a user clicks on the delete button.
A confirmation modal is opened when the user clicks on the delete button (see Step 2 below). The card is only deleted after the user has confirmed the action.
In either case, the ItemModal component accepts the handler as a prop that takes the card object.
In case of immediate removal, the handler, which is passed from the [login to view URL], will contain the corresponding API call. After a successful API request, the clothingItems state should be updated using the filter() method. You should also create a copy of the array and exclude the deleted card from it. Finally, remember to close the item modal window.
Step 2. Implement a confirmation modal (optional)
If you have decided to create a confirmation modal, follow the instructions here. There is nothing complicated about implementing a confirmation modal, and it will help your users avoid accidentally deleting their favorite cards.
Let's start by creating our markup for the modal. It should contain a warning message, as well as buttons to close, confirm, and cancel. The modal can be closed by clicking the "X" or the "Cancel" button. Clicking the confirmation button calls the handler, which is passed from App.
Besides the option to delete immediately, we now have two handlers in the App component. They are:
the openConfirmationModal handler, which is passed from the App to the ItemModal component, opens the confirmation modal, and saves a card to delete in the state.
the handleCardDelete handler, which is passed from the App to the DeleteConfirmationModal component. This handler makes the API call. After a successful API request, the clothingItems state needs to be updated, the modals closed, and the state containing the card should be reset.
Hi, I have carefully reviewed your requirements and am highly interested in this opportunity. With extensive experience and a strong background in the technical stack you require, I am confident in my ability to deliver a high-quality solution that meets all your expectations. I look forward to the opportunity to collaborate and discuss further. Thanks
$140 USD in 7 days
5.0
(9 reviews)
4.1
4.1
69 freelancers are bidding on average $123 USD for this job
Hello, I'm Asma, Graphic Designer and Web Developer with 10 years of experience working with clients and agencies from around the world. Creative problem solver with a passion for creating visually appealing and user-friendly digital solutions. I love building luxurious brands and designing captivating visual identities. I've worked with clients in lifestyle, property, fashion, hospitality, and luxury sectors. 24/7 Support & Faster Response .
#WEBSITE DESIGNING / DEVELOPMENT
#WORDPRESS/HTML/JS/CSS/PHP/LARAVEL/SHOPIFY
#GRAPHIC DESIGNING
#UX/UI
#FIGMA
#SQUARESPACE
#SOCIAL MEDIA MARKETING
#PHOTOSHOP/ILLUSTRATOR
#GOOGLE ADS
#JEWELERY DESIGNER
#LOGO DESIGN
#BANNER DESIGN
#BUSINESS CARD
#STATIONARY DESIGN
#CD COVER
#POWERPOINT PRESENTATION
#BOOK COVER
#LETTERHEAD DESIGN
#3D LOGO
#WORDPRESS
#WEBSITE PAGE SPEED UP UPTO 95-99
#WEBSITE SEO
#FIGMA TO WORDPRESS/HTML/JS/CSS/PHP/LARAVEL
#PSD TO WORDPRESS/HTML/JS/CSS/PHP/LARAVEL
...... ETC :)
Hello,
I’ve reviewed your project and am confident my expertise in JavaScript, CSS, HTML, React.js, Servermakes me a great fit. I focus on delivering high-quality, impactful results.
I'm experienced with years of hands-on expertise in JavaScript, CSS, HTML, React.js, Server, passionate about delivering top-notch results that truly make an impact.
Let’s connect and chat—I’d love the chance to discuss how I can bring value to your project!
Regards,
Umair
Hi There,
I’m offering an exclusive 25% discount on my custom feature development services, including dynamic temperature unit switching and user profile management. If you need a seamless, user-friendly solution to allow users to personalize their experience, I can develop a scalable, efficient, and intuitive system tailored to your needs.
With over 6 years of experience in frontend & backend development, API integrations, and user authentication, I ensure your features are secure, fast, and fully optimized. Your project will be delivered on time, with free ongoing support for future improvements.
I’m available 24/7 to discuss your project. Let’s enhance your platform with dynamic and user-focused features!
Best regards,
Sohail Jamil
Dear Hiring Manager,
I am Abdul, a skilled and experienced JavaScript developer with a strong background in React.js, HTML, CSS, and server-side technologies. I have successfully completed numerous projects similar to the one you have described, showcasing my ability to deliver high-quality solutions efficiently.
For the "Dynamic Temperature Unit & User Profile Feature" project, I am confident in my ability to tackle each step outlined in the project description. From creating the markup for the temperature toggle switch to implementing context objects and integrating React Router for the profile page, I am well-versed in the necessary technologies and methodologies to bring your project to life.
My proficiency in React.js and my dedication to staying updated with the latest industry trends make me a suitable candidate for this project. I am eager to discuss further details and demonstrate how my skills align with your project requirements.
Thank you for considering my proposal, and I look forward to the opportunity to collaborate with you on this exciting project.
Best regards,
Abdul
I am excited about the opportunity to work on implementing the temperature toggle switch in your React application as described in the project details. I understand the importance of creating a custom ToggleSwitch component using a checkbox input type and how crucial it is to use context for managing the state of the currentTemperatureUnit. I will ensure that the temperature values are correctly fetched and converted from the OpenWeather API and integrate the context across ToggleSwitch, WeatherCard, and Main components seamlessly.
My extensive experience of over 8 years in web and mobile development, particularly with React.js and related technologies, positions me well to deliver a robust and efficient solution. I have a strong background in implementing complex UI components and managing state effectively using context and state management libraries. Additionally, my experience in integrating APIs and configuring routes using React Router will be instrumental for this project.
I am confident in my ability to provide a high-quality implementation, and I am eager to discuss further how I can contribute to your project. Please feel free to message me. Thank you!
Hello there
I’m excited to help you implement the temperature toggle switch feature in your React application. I'll create the markup for the toggle switch using a checkbox input type and apply custom styling to match the Figma design. By researching and implementing the functionality, I will ensure a smooth user experience while toggling between Fahrenheit and Celsius.
Additionally, I’ll create the currentTemperatureUnit state in your root component and implement context for easy state management across all components. From integrating the weather data from OpenWeather API to updating the weather display based on the selected temperature unit, I’ll ensure everything works seamlessly. The profile page and add item functionality will be designed with navigation using React Router, making it easy for users to interact with your application.
Best regards,
Dotgix Technologies
I am confident I can help you build and implement the features for your project, following the steps outlined in the provided details. I will create the ToggleSwitch component with custom styles, integrating it seamlessly into the application. I will set up the currentTemperatureUnit state in the App component and manage it with React Context to toggle between Fahrenheit and Celsius. Additionally, I'll integrate the weather API to fetch and transform temperature values accordingly.
For routing, I'll implement React Router for seamless navigation between the main page and profile page, including the setup of a profile section with hardcoded user data. I'll also handle the functionality for adding and deleting clothing items, using forms and modals, ensuring smooth interaction for users. This includes managing the form state, handling item submissions, and setting up delete functionality with confirmation prompts.
Let me know if you'd like to discuss specific details or any adjustments. I’m ready to get started and complete the project efficiently.
Hello, Greetings Milestone C.,
Good afternoon!
⚡⚡⚡I HAVE READ ALL YOUR REQUIREMENTS VERY CAREFULLY AND UNDERSTOOD WHAT YOU WANT.⚡⚡⚡
As a top developer with extensive experience in JavaScript, CSS, HTML, Server and React.js, I can provide the precise results you're seeking for.
For over 8 years, I have developed numerous projects focusing on enhanced user experience and performance optimization.
✔ Expertise and Experience: 8+ years of hands-on experience in JavaScript, CSS, HTML, Server and React.js to deliver high-quality solutions.
✔ Efficiency: Streamlined development processes to save time and reduce costs.
✔ Scalability: Solutions designed to grow seamlessly with your business.
✔ Reliability: Robust implementations to minimize downtime and ensure optimal performance.
✔ Customization: Solutions tailored to your specific needs and objectives.
✔ Ongoing Support: 6+ weeks of support and maintenance to ensure your project runs smoothly.
I will share my past work in the chatbox.
I am eager to contribute my expertise to your project.
Looking forward to your reply.
Best regards,
Hello,
I am thrilled by the opportunity to bring your project to life! With my extensive expertise in React, JavaScript, and CSS, I am poised to tackle the complexities within your dynamic temperature unit and user profile feature project. My strategy includes developing a sophisticated ToggleSwitch component, effectively handling context-based state management, and integrating React Router for seamless navigation.
My professional approach ensures each element is finely tuned to fit the Figma design and function flawlessly.
Could you please share more about your preferred style and any specific functionalities you envision for the UI?
Thanks,
Jeremy
Hi, Milestone!
I am excited to express my interest in your project "Dynamic Temperature Unit & User Profile Feature." Your detailed description showcases the complexity of the task, and I am confident that my experience in React development aligns well with your requirements. I have successfully implemented similar UI components and context functionalities in previous projects, ensuring a seamless user experience.
https://www.freelancer.com/u/centaurusagency
I assure you of quick delivery, unlimited revisions, and a 100% satisfaction guarantee. By collaborating with me, you can expect high-quality results that meet your expectations. I am eager to further discuss how I can contribute to the success of your project. Do you have any specific preferences for the design or functionality of the temperature toggle switch?
Looking forward to the opportunity to work together.
Best regards,
Centaurus Agency.
Hi, I have read your proposal carefully and I am very confident with this task because My skills are best matched with this project and I have ever worked similar project.
If I have chance to work with this, I will provide perfect result within your deadline.
Looking forward discussing this project with you.
Thank you. Petro.
Hello Milestone,
I have extensive experience in React development and I am confident in my ability to successfully complete this project. I will start by creating the markup for the temperature toggle switch component and implementing custom styles. Then, I will create a currentTemperatureUnit state in the root component and a context object to manage the temperature unit value. Next, I will extract the temperature values from the OpenWeather API and use context in the ToggleSwitch and WeatherCard components to display the temperature unit correctly. Additionally, I will add a profile route with a Profile component and configure routes using React Router. Finally, I will create the AddItemModal component for adding clothing items and implement functionality to delete cards.
Looking forward to discussing this project further with you.
Thanks,
Syed
I am Muhammad Faisal, an astute software engineer with 7+ years of experience and expertise that spans across web development, app creation, and 3D design. My multi-faceted skill set places me in a unique position to not only meet but exceed your expectations for this project. As a web developer and designer, I am well-versed in HTML, CSS, and JavaScript - core skills you require for this task. I understand the intricacy behind seemingly-simple features like a temperature unit toggle switch and know how to build it robustly while ensuring clean UI/UX.
Additionally, my experience in mobile app development complements your requirement to create a profile page using React Router. Whether on iOS or Android platforms, creating seamless user journeys has been integral to my work.
My proficiency in 3D design may not directly apply here but showcases my knack for innovative problem-solving and adopting new technologies quickly - qualities that would be essential as you expand your project scope globally. Trust me with your project, I assure you a precise blend of design and functionality that will leave a lasting impression on your users.
"I think I am the perfect fit for your project. Your requirements for creating a ToggleSwitch component in React align perfectly with my expertise in building clean and user-friendly UI components. While I am new to Freelancer.com, I have extensive experience in developing seamless and integrated solutions. I'd love to chat more about your project!
Regards, Juandre"
I have successfully completed similar UI projects before, including working with context and state management in React.
For your project, I will create the ToggleSwitch component using a checkbox input with custom styles according to your design. I’ll implement the currentTemperatureUnit state in the App component and utilize context to pass this state across components, ensuring that the temperature values from the OpenWeather API are displayed in both Celsius and Fahrenheit.
Additionally, I’ll set up routing using React Router for the Profile component and integrate functionality for adding and deleting clothing items, ensuring a smooth user experience throughout.
I can start work immediately and deliver in a short time.
As a seasoned full-stack developer, I specialize in utilizing CSS, JavaScript, and React.js to build dynamic and interactive user interfaces - skills that align perfectly with your project's needs. My comprehensive understanding of React's ecosystem ensures that I am no stranger to the research and implementation process you described. Over the years, I've conquered numerous complex UI components, and I relish the opportunity to tackle this toggle switch for temperature units.
Moreover, my proficiency in Python (including Python's weather API libraries) assures you that extracting details from OpenWeather API is well within my wheelhouse. I understand the significance of creating clean and reusable code and will implement it effectively when establishing the currentTemperatureUnit state variable within the root component. My skills also extend to working with Contexts - a crucial aspect of your project's step 3 - enabling me to handle data sharing seamlessly.
To efficiently implement this project, I would start by building a modular solution using React's state management and context API to handle the temperature toggle and display logic. I'll create reusable components for the toggle switch, weather display, and profile page, ensuring clean routing with React Router for easy navigation. With my experience in React, I'll also handle dynamic state updates and integrate the weather API seamlessly, ensuring a smooth user experience across the application.
Hello Milestone, I’m ready to start working on creating a dynamic temperature unit and user profile feature for your project.
While I'm new here, my experience in React development and creating complex UI components makes me a great fit for this project. I fully understand the requirements for creating a temperature toggle switch component and implementing a user profile feature using React Router.
I am eager to showcase my skills and work closely with you to bring your project to life. Let's discuss further details in chat, where I can share my relevant work samples with you. Looking forward to your response!
Thank you & Regards,
Pawan Kumar.
Dear Client,
I am excited to assist you in developing the features for your React application. With extensive experience in building dynamic user interfaces, I can create the ToggleSwitch component and implement the necessary state management for current temperature units. I will ensure the integration of context for seamless data flow and develop the Profile and AddItemModal components as specified. My proficiency with React Router will facilitate smooth navigation throughout the app. Additionally, I can implement both immediate and confirmation delete functionalities, enhancing user experience. I am committed to delivering a polished and functional application.
Thank you for considering my application!
I understand that you need a React developer to implement a toggle switch for temperature conversion, manage temperature state using context, extract temperature values from an API, and integrate these updates across multiple components. Additionally, you require routing for a profile page, form handling for adding clothing items, and functionality to delete cards with an optional confirmation modal.
To efficiently implement this, do you have specific design constraints or UI libraries that should be used for the toggle switch? Also, should the weather API integration include additional data points beyond temperature conversion?
For the routing setup, do you have predefined navigation behavior, or should it follow a standard layout structure? Clarifying these details will ensure seamless integration within your existing project structure.
If you can provide more insights on these aspects, I can deliver an optimized and scalable solution tailored to your requirements.