mirror of
https://github.com/lux-tel/session-desktop.git
synced 2026-10-30 20:33:24 +00:00
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import type { SessionDataTestId } from 'react';
|
|
import { alignButtonEndAbsoluteButtonStyle } from './sharedStyles';
|
|
import { SessionLucideIconButton } from '../icon/SessionIconButton';
|
|
import { LUCIDE_ICONS_UNICODE } from '../icon/lucide';
|
|
|
|
type ShowHideButtonStrings<T extends string> = { hide: T; show: T };
|
|
|
|
export type ShowHideButtonProps = {
|
|
forceShow: boolean;
|
|
toggleForceShow: () => void;
|
|
hasError: boolean;
|
|
ariaLabels: ShowHideButtonStrings<string>;
|
|
dataTestIds: ShowHideButtonStrings<SessionDataTestId>;
|
|
};
|
|
|
|
export const ShowHideButton = (props: ShowHideButtonProps) => {
|
|
const { forceShow, toggleForceShow, hasError, ariaLabels, dataTestIds } = props;
|
|
|
|
const style = alignButtonEndAbsoluteButtonStyle();
|
|
|
|
return (
|
|
<SessionLucideIconButton
|
|
ariaLabel={forceShow ? ariaLabels.hide : ariaLabels.show}
|
|
unicode={forceShow ? LUCIDE_ICONS_UNICODE.EYE_OFF : LUCIDE_ICONS_UNICODE.EYE}
|
|
iconColor={hasError ? 'var(--danger-color)' : 'var(--text-secondary-color)'}
|
|
iconSize="large"
|
|
onClick={toggleForceShow}
|
|
style={style}
|
|
dataTestId={forceShow ? dataTestIds.hide : dataTestIds.show}
|
|
/>
|
|
);
|
|
};
|