-
Notifications
You must be signed in to change notification settings - Fork 195
Expand file tree
/
Copy pathAltTextControls.tsx
More file actions
51 lines (47 loc) · 1.52 KB
/
AltTextControls.tsx
File metadata and controls
51 lines (47 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { useFormikContext } from 'formik';
import React from 'react';
import { Form } from '@openedx/paragon';
import { useIntl } from '@edx/frontend-platform/i18n';
import { ImageConfig } from './types';
import messages from './messages';
const AltTextControls = () => {
const intl = useIntl();
const formik = useFormikContext<ImageConfig>();
return (
<>
<Form.Label className="mb-0">
{intl.formatMessage(messages.accessibilityLabel)}
</Form.Label>
<Form.Group className="mb-1">
<Form.Checkbox
name="isDecorative"
checked={formik.values.isDecorative}
className="mt-2.5 decorative-control-label"
onChange={formik.handleChange}
>
<Form.Label>
{intl.formatMessage(messages.decorativeAltTextCheckboxLabel)}
</Form.Label>
</Form.Checkbox>
</Form.Group>
<Form.Group>
<Form.Control
name="altText"
floatingLabel={intl.formatMessage(messages.altTextFloatingLabel)}
disabled={formik.values.isDecorative}
isInvalid={Boolean(formik.errors.altText)}
onChange={formik.handleChange}
type="input"
value={formik.values.altText}
/>
{formik.errors.altText && (
<Form.Control.Feedback type="invalid">
{formik.errors.altText}
</Form.Control.Feedback>
)}
</Form.Group>
</>
);
};
export const AltTextControlsInternal = AltTextControls; // For testing only
export default AltTextControls;