@@ -24,6 +24,7 @@ import {
2424 EuiKeyPadMenuItem ,
2525 EuiPopover ,
2626 EuiSpacer ,
27+ EuiSwitch ,
2728 EuiText ,
2829 EuiToolTip ,
2930 useEuiTheme ,
@@ -49,7 +50,11 @@ import {
4950 useFormChangesContext ,
5051} from '@kbn/security-form-components' ;
5152import { KibanaPageTemplate } from '@kbn/shared-ux-page-kibana-template' ;
52- import type { DarkModeValue , UserProfileData } from '@kbn/user-profile-components' ;
53+ import type {
54+ ContrastModeValue ,
55+ DarkModeValue ,
56+ UserProfileData ,
57+ } from '@kbn/user-profile-components' ;
5358import { UserAvatar , useUpdateUserProfile } from '@kbn/user-profile-components' ;
5459
5560import { createImageHandler , getRandomColor , VALID_HEX_COLOR } from './utils' ;
@@ -110,6 +115,7 @@ export interface UserProfileFormValues {
110115 } ;
111116 userSettings : {
112117 darkMode : DarkModeValue ;
118+ contrastMode : ContrastModeValue ;
113119 } ;
114120 } ;
115121 avatarType : 'initials' | 'image' ;
@@ -236,7 +242,7 @@ const UserSettingsEditor: FunctionComponent<UserSettingsEditorProps> = ({
236242 < FormLabel for = "data.userSettings.darkMode" >
237243 < FormattedMessage
238244 id = "xpack.security.accountManagement.userProfile.userSettings.theme"
239- defaultMessage = "Mode "
245+ defaultMessage = "Color mode "
240246 />
241247 </ FormLabel >
242248 ) ,
@@ -318,6 +324,24 @@ const UserSettingsEditor: FunctionComponent<UserSettingsEditorProps> = ({
318324 </ >
319325 ) ;
320326
327+ const idSelectedContrast = formik . values . data . userSettings . contrastMode ;
328+ const contrastModeMenu = ( ) => {
329+ return (
330+ < EuiSwitch
331+ id = "contrastMode"
332+ label = { i18n . translate (
333+ 'xpack.security.accountManagement.userProfile.highContrastModeButton' ,
334+ { defaultMessage : 'High contrast' }
335+ ) }
336+ checked = { idSelectedContrast === 'high' }
337+ onChange = { ( { target } ) => {
338+ const value = target . checked ? 'high' : 'standard' ;
339+ return formik . setFieldValue ( 'data.userSettings.contrastMode' , value ) ;
340+ } }
341+ />
342+ ) ;
343+ } ;
344+
321345 return (
322346 < EuiDescribedFormGroup
323347 fullWidth
@@ -326,7 +350,7 @@ const UserSettingsEditor: FunctionComponent<UserSettingsEditorProps> = ({
326350 < h2 >
327351 < FormattedMessage
328352 id = "xpack.security.accountManagement.userProfile.userSettingsTitle"
329- defaultMessage = "Theme "
353+ defaultMessage = "Appearance "
330354 />
331355 </ h2 >
332356 }
@@ -343,6 +367,22 @@ const UserSettingsEditor: FunctionComponent<UserSettingsEditorProps> = ({
343367 { deprecatedWarning }
344368 </ >
345369 </ FormRow >
370+
371+ < FormRow
372+ name = "data.userSettings.contrastMode"
373+ fullWidth
374+ label = {
375+ < FormLabel for = "data.userSettings.contrastMode" >
376+ < FormattedMessage
377+ id = "xpack.security.accountManagement.userProfile.userSettings.contrastMode"
378+ defaultMessage = "Accessibility"
379+ />
380+ </ FormLabel >
381+ }
382+ hasChildLabel = { false }
383+ >
384+ { contrastModeMenu ( ) }
385+ </ FormRow >
346386 </ EuiDescribedFormGroup >
347387 ) ;
348388} ;
@@ -872,6 +912,7 @@ export function useUserProfileForm({ user, data }: UserProfileProps) {
872912 } ,
873913 userSettings : {
874914 darkMode : data . userSettings ?. darkMode || 'space_default' ,
915+ contrastMode : data . userSettings ?. contrastMode || 'standard' ,
875916 } ,
876917 }
877918 : undefined ,
@@ -924,7 +965,10 @@ export function useUserProfileForm({ user, data }: UserProfileProps) {
924965 resetInitialValues ( values ) ;
925966
926967 let isRefreshRequired = false ;
927- if ( initialValues . data ?. userSettings . darkMode !== values . data ?. userSettings . darkMode ) {
968+ if (
969+ initialValues . data ?. userSettings . darkMode !== values . data ?. userSettings . darkMode ||
970+ initialValues . data ?. userSettings . contrastMode !== values . data ?. userSettings . contrastMode
971+ ) {
928972 isRefreshRequired = true ;
929973 }
930974 showSuccessNotification ( { isRefreshRequired } ) ;
0 commit comments