blob: 9a5a7d2d93ee779688428871c955965a30199a13 [file] [log] [blame]
Adrià Vilanova Martínez535e7312021-10-17 00:48:12 +02001// Copyright 2021 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5import React from 'react';
6import { makeStyles } from '@material-ui/styles';
7import { RoleSelection } from './RoleSelection/RoleSelection.tsx';
8
9const userGroups = Object.freeze({
10 END_USER: 'End User',
11 WEB_DEVELOPER: 'Web Developer',
12 CONTRIBUTOR: 'Chromium Contributor',
13});
14
15const useStyles = makeStyles({
16 flex: {
17 display: 'flex',
18 justifyContent: 'space-between',
19 }
20});
21
22/**
23 * RadioDescription contains a set of radio buttons and descriptions (RoleSelection)
24 * to be chosen from in the landing step of the Issue Wizard.
25 *
26 * @returns React.ReactElement
27 */
28export const RadioDescription = ({ value, setValue }: { value: string, setValue: Function }): React.ReactElement => {
29 const classes = useStyles();
30
31 const handleRoleSelectionClick = (userGroup: string) =>
32 (event: React.MouseEvent<HTMLElement>) => setValue(userGroup)
33
34 return (
35 <div className={classes.flex}>
36 <RoleSelection
37 checked={value === userGroups.END_USER}
38 handleOnClick={handleRoleSelectionClick(userGroups.END_USER)}
39 value={userGroups.END_USER}
40 description="I am a user trying to do something on a website."
41 inputProps={{ 'aria-label': userGroups.END_USER }}
42 />
43 <RoleSelection
44 checked={value === userGroups.WEB_DEVELOPER}
45 handleOnClick={handleRoleSelectionClick(userGroups.WEB_DEVELOPER)}
46 value={userGroups.WEB_DEVELOPER}
47 description="I am a web developer trying to build something."
48 inputProps={{ 'aria-label': userGroups.WEB_DEVELOPER }}
49 />
50 <RoleSelection
51 checked={value === userGroups.CONTRIBUTOR}
52 handleOnClick={handleRoleSelectionClick(userGroups.CONTRIBUTOR)}
53 value={userGroups.CONTRIBUTOR}
54 description="I know about a problem in specific tests or code."
55 inputProps={{ 'aria-label': userGroups.CONTRIBUTOR }}
56 />
57 </div>
58 );
59}