<html>
<head>
<meta charset="UTF-8" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/17.0.2/umd/react.development.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/17.0.2/umd/react-dom.development.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"></script>
</head>
<body>
<div id="app"></div>
<script type="text/babel">
const { useState } = React;
function App() {
const [areYouDeveloper, setAreYouDeveloper] = useState('yes');
const [selectedLanguage, setSelectedLanguage] = useState('');
const handleDropdownChange = (e) => {
const selectedValue = e.target.value;
setAreYouDeveloper(selectedValue);
};
const handleRadioChange = (e) => {
const selectedLanguage = e.target.value;
setSelectedLanguage(selectedLanguage);
};
return (
<div className="container">
<select value={areYouDeveloper} onChange={handleDropdownChange} className="dropdown">
<option value="">Are you a developer?</option>
<option value="yes">Yes</option>
<option value="no">No</option>
</select>
{areYouDeveloper === 'yes' && (
<div>
If yes, select your preferred programming language.
<div className="radio-option">
<input
type="radio"
name="radioOption"
id="radioReact"
value="React"
onChange={handleRadioChange}
className="radio-input"
/>
<label htmlFor="radioReact" className="radio-label">
React
</label>
</div>
<div className="radio-option">
<input
type="radio"
name="radioOption"
id="radioAngular"
value="Angular"
onChange={handleRadioChange}
className="radio-input"
/>
<label htmlFor="radioAngular" className="radio-label">
Angular
</label>
</div>
<div className="radio-option">
<input
type="radio"
name="radioOption"
id="radioVue"
value="Vue.js"
onChange={handleRadioChange}
className="radio-input"
/>
<label htmlFor="radioVue" className="radio-label">
Vue.js
</label>
</div>
</div>
)}
{selectedLanguage && <p>Selected Language: {selectedLanguage}</p>}
</div>
);
}
ReactDOM.render(<App />, document.getElementById('app'));
</script>
<style>
.container {
text-align: center;
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.12), 0 2px 4px 0 rgba(0, 0, 0, 0.24);
width: 600px;
margin: 0 auto;
padding: 20px;
}
/* Dropdown styling */
.dropdown {
padding: 10px;
font-size: 16px;
border: 2px solid #3498db;
border-radius: 8px;
margin-bottom: 20px;
width: 100%;
}
/* Radio option styling */
.radio-option {
display: flex;
align-items: center;
margin-bottom: 10px;
}
.radio-input {
margin-right: 10px;
cursor: pointer;
}
.radio-label {
cursor: pointer;
}
/* Radio input styling when disabled */
.radio-input[disabled]+.radio-label {
color: #aaa;
cursor: not-allowed;
}
/* Styling for 'Yes' option in the dropdown */
.dropdown option[value="yes"] {
font-weight: bold;
color: #3498db;
}
</style>
</body>
</html>