1 import type { FC } from 'react';
3 import type { IconSize } from '@proton/components';
4 import { Icon } from '@proton/components';
5 import { getIconSizePx } from '@proton/pass/components/Layout/Icon/IconBox';
6 import { VAULT_COLOR_MAP, VAULT_ICON_MAP } from '@proton/pass/components/Vault/constants';
7 import type { VaultIcon as VaultIconEnum } from '@proton/pass/types/protobuf/vault-v1';
8 import { VaultColor as VaultColorEnum } from '@proton/pass/types/protobuf/vault-v1';
9 import { rootFontSize } from '@proton/shared/lib/helpers/dom';
10 import clsx from '@proton/utils/clsx';
12 import './VaultIcon.scss';
14 export type VaultIconName = VaultIconEnum | 'pass-all-vaults' | 'pass-trash';
19 color?: VaultColorEnum;
20 highlighted?: boolean;
25 const rem = (px: number) => `${px / rootFontSize()}rem`;
27 export const VaultIcon: FC<Props> = ({
33 icon = 'pass-all-vaults',
37 `pass-vault-icon rounded-xl relative w-custom h-custom`,
38 background && 'background',
39 size >= 5 && 'rounded-full',
43 '--vault-icon-color': highlighted
44 ? 'var(--interaction-norm-contrast)'
45 : `rgb(${VAULT_COLOR_MAP[color ?? VaultColorEnum.COLOR1]})`,
46 '--w-custom': rem(getIconSizePx(background ? size * 2 : size)),
47 '--h-custom': rem(getIconSizePx(background ? size * 2 : size)),
51 className="absolute inset-center"
52 name={icon === 'pass-all-vaults' || icon === 'pass-trash' ? icon : VAULT_ICON_MAP[icon]}