Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Tweak item add edit UI (#2413)

Leendert de Borst027d25370096
diff --git a/apps/web/src/components/attachments/AttachmentViewer.tsx b/apps/web/src/components/attachments/AttachmentViewer.tsx
index 6a26c432d..f212aa629 100644
--- a/apps/web/src/components/attachments/AttachmentViewer.tsx
+++ b/apps/web/src/components/attachments/AttachmentViewer.tsx
@@ -2,6 +2,7 @@ import { downloadBytes } from '@aliasvault/client/utilities/FileDownload';
import React from 'react';
import Card from '@/components/shared/Card';
+import SectionTitle from '@/components/shared/SectionTitle';
import type { Attachment } from '@aliasvault/models/vault';
@@ -50,7 +51,7 @@ const AttachmentViewer: React.FC<AttachmentViewerProps> = ({ attachments }) => {
return (
<Card variant="section">
- <h3 className="mb-4 text-xl font-semibold dark:text-white">Attachments</h3>
+ <SectionTitle>Attachments</SectionTitle>
{visible.length > 0 ? (
<div className="space-y-2">
{visible.map((attachment) => {
diff --git a/apps/web/src/components/email/RecentEmails.tsx b/apps/web/src/components/email/RecentEmails.tsx
index ea58f39c8..c69ddf62a 100644
--- a/apps/web/src/components/email/RecentEmails.tsx
+++ b/apps/web/src/components/email/RecentEmails.tsx
@@ -7,6 +7,7 @@ import AlertMessageError from '@/components/alerts/AlertMessageError';
import EmailModal from '@/components/email/EmailModal';
import SkeletonBase from '@/components/loading/SkeletonBase';
import Card from '@/components/shared/Card';
+import SectionTitle from '@/components/shared/SectionTitle';
import { useDb } from '@/context/DbContext';
import { useWebApi } from '@/context/WebApiContext';
import { useEmailDomains } from '@/hooks/useEmailDomains';
@@ -201,7 +202,7 @@ const RecentEmails: React.FC<RecentEmailsProps> = ({ emailAddress }) => {
<Card variant="section">
<div className="flex justify-between">
<div>
- <h3 className="mb-4 text-xl font-semibold dark:text-white">{t('components.main.email.recentEmails.EmailSectionTitle')}</h3>
+ <SectionTitle>{t('components.main.email.recentEmails.EmailSectionTitle')}</SectionTitle>
</div>
<div className="flex justify-end items-center space-x-2">
{autoRefreshEnabled && (
diff --git a/apps/web/src/components/forms/EditFormRow.tsx b/apps/web/src/components/forms/EditFormRow.tsx
index a4340457b..78857aaa0 100644
--- a/apps/web/src/components/forms/EditFormRow.tsx
+++ b/apps/web/src/components/forms/EditFormRow.tsx
@@ -1,6 +1,7 @@
import React from 'react';
import FormLabel from '@/components/shared/FormLabel';
+import SectionTitle from '@/components/shared/SectionTitle';
type EditFormRowProps = {
id: string;
@@ -22,7 +23,7 @@ export const EDIT_INPUT_CLASSES = 'outline-0 shadow-sm bg-gray-50 border border-
const EditFormRow: React.FC<EditFormRowProps> = ({ id, label, type = 'text', value, onChange, onFocus, placeholder = '', labelStyle = 'default' }) => (
<>
{labelStyle === 'header'
- ? <label htmlFor={id} className="mb-4 text-xl font-semibold dark:text-white block">{label}</label>
+ ? <SectionTitle htmlFor={id}>{label}</SectionTitle>
: <FormLabel htmlFor={id}>{label}</FormLabel>}
<div className="relative">
{type === 'textarea' ? (
diff --git a/apps/web/src/components/forms/RemovableSection.tsx b/apps/web/src/components/forms/RemovableSection.tsx
index ae3f76423..0cca4d640 100644
--- a/apps/web/src/components/forms/RemovableSection.tsx
+++ b/apps/web/src/components/forms/RemovableSection.tsx
@@ -2,6 +2,7 @@ import React from 'react';
import { useTranslation } from 'react-i18next';
import Card from '@/components/shared/Card';
+import SectionTitle from '@/components/shared/SectionTitle';
type RemovableSectionProps = {
title?: string;
@@ -18,8 +19,8 @@ const RemovableSection: React.FC<RemovableSectionProps> = ({ title = '', canRemo
return (
<Card variant="section" className="relative">
- {title.length > 0 && <h3 className="mb-4 text-xl font-semibold dark:text-white">{title}</h3>}
- <div className="grid gap-6">
+ {title.length > 0 && <SectionTitle>{title}</SectionTitle>}
+ <div className="grid gap-4">
{children}
</div>
{canRemove && (
diff --git a/apps/web/src/components/items/ItemTypeSelector.tsx b/apps/web/src/components/items/ItemTypeSelector.tsx
index 61eeefda9..0f491745d 100644
--- a/apps/web/src/components/items/ItemTypeSelector.tsx
+++ b/apps/web/src/components/items/ItemTypeSelector.tsx
@@ -15,16 +15,16 @@ const ALL_TYPES: ItemType[] = [ItemTypes.Login, ItemTypes.Alias, ItemTypes.Credi
/**
* The icon of an item type.
*/
-const TypeIcon: React.FC<{ itemType: ItemType }> = ({ itemType }) => {
+const TypeIcon: React.FC<{ itemType: ItemType; className?: string }> = ({ itemType, className = 'w-5 h-5' }) => {
switch (itemType) {
case ItemTypes.Login:
- return <svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z" /></svg>;
+ return <svg className={className} fill="none" stroke="currentColor" viewBox="0 0 24 24"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z" /></svg>;
case ItemTypes.Alias:
- return <svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" /></svg>;
+ return <svg className={className} fill="none" stroke="currentColor" viewBox="0 0 24 24"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" /></svg>;
case ItemTypes.CreditCard:
- return <svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z" /></svg>;
+ return <svg className={className} fill="none" stroke="currentColor" viewBox="0 0 24 24"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z" /></svg>;
default:
- return <svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" /></svg>;
+ return <svg className={className} fill="none" stroke="currentColor" viewBox="0 0 24 24"><path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" /></svg>;
}
};
@@ -40,6 +40,40 @@ const typeNameKey = (itemType: ItemType): string => {
}
};
+type ItemTypePillProps = {
+ itemType: ItemType;
+ /** Makes the pill the dropdown toggle of the edit page; without it the pill is a muted read-only label. */
+ onClick?: () => void;
+ isOpen?: boolean;
+};
+
+/**
+ * Pill showing the item type.
+ */
+export const ItemTypePill: React.FC<ItemTypePillProps> = ({ itemType, onClick, isOpen = false }) => {
+ const { t } = useTranslation();
+
+ if (!onClick) {
+ return (
+ <span className="inline-flex items-center gap-1.5 px-2.5 py-0.5 bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-full">
+ <span className="shrink-0 text-gray-500 dark:text-gray-400"><TypeIcon itemType={itemType} className="w-3.5 h-3.5" /></span>
+ <span className="text-xs font-medium whitespace-nowrap text-gray-700 dark:text-gray-300">{t(typeNameKey(itemType))}</span>
+ </span>
+ );
+ }
+
+ return (
+ <button type="button" onClick={onClick} className="inline-flex items-center gap-1.5 pl-2.5 pr-2 py-0.5 bg-primary-50 dark:bg-primary-900/20 border border-primary-200 dark:border-primary-800 rounded-full hover:bg-primary-100 dark:hover:bg-primary-900/40 focus:outline-none focus:ring-2 focus:ring-primary-500 transition-colors">
+ <span className="shrink-0 text-primary-600 dark:text-primary-400"><TypeIcon itemType={itemType} className="w-3.5 h-3.5" /></span>
+ <span className="text-xs font-medium whitespace-nowrap text-primary-700 dark:text-primary-300">{t(typeNameKey(itemType))}</span>
+ <span className="ml-1 text-xs whitespace-nowrap text-primary-600/70 dark:text-primary-400/70">{t('sharedResources.ItemTypeLabel')}</span>
+ <svg className={`w-3 h-3 shrink-0 text-primary-500 transition-transform ${isOpen ? 'rotate-180' : ''}`} fill="none" stroke="currentColor" viewBox="0 0 24 24">
+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M19 9l-7 7-7-7" />
+ </svg>
+ </button>
+ );
+};
+
/**
* Dropdown to pick the item type.
*/
@@ -47,25 +81,13 @@ const ItemTypeSelector: React.FC<ItemTypeSelectorProps> = ({ selectedType, onSel
const { t } = useTranslation();
return (
- <div className="relative mb-4">
- <div className="relative w-full px-4 py-3 bg-primary-50 dark:bg-primary-900/20 border border-primary-200 dark:border-primary-800 rounded-lg flex items-center gap-2">
- <button type="button" onClick={() => onShowDropdownChange(!showDropdown)} className="peer absolute inset-0 rounded-lg" aria-label={t('sharedResources.ItemTypeLabel')}></button>
- <div className="relative flex items-center gap-2 min-w-0 pointer-events-none peer-hover:opacity-80 transition-opacity">
- <span className="shrink-0 text-primary-600 dark:text-primary-400"><TypeIcon itemType={selectedType} /></span>
- <span className="text-primary-700 dark:text-primary-300 font-medium text-sm truncate">{t(typeNameKey(selectedType))}</span>
- </div>
- <div className="relative flex-1 flex items-center justify-end gap-1 min-w-0 pointer-events-none peer-hover:opacity-80 transition-opacity">
- <span className="text-xs text-primary-600/80 dark:text-primary-400/80 truncate">{t('sharedResources.ItemTypeLabel')}</span>
- <svg className={`w-4 h-4 shrink-0 text-primary-500 transition-transform ${showDropdown ? 'rotate-180' : ''}`} fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M19 9l-7 7-7-7" />
- </svg>
- </div>
- </div>
+ <div className="relative inline-block">
+ <ItemTypePill itemType={selectedType} onClick={() => onShowDropdownChange(!showDropdown)} isOpen={showDropdown} />
{showDropdown && (
<>
<div className="fixed inset-0 z-10" onClick={() => onShowDropdownChange(false)}></div>
- <div className="absolute z-20 mt-1 w-full bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg overflow-hidden">
+ <div className="absolute left-0 z-20 mt-2 w-56 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg overflow-hidden">
{ALL_TYPES.map((itemType) => {
const selected = selectedType === itemType;
return (
diff --git a/apps/web/src/components/shared/Card.tsx b/apps/web/src/components/shared/Card.tsx
index 8b10e8ad7..a04d66df8 100644
--- a/apps/web/src/components/shared/Card.tsx
+++ b/apps/web/src/components/shared/Card.tsx
@@ -9,12 +9,12 @@ type CardProps = {
className?: string;
};
-const BASE_CLASSES = 'p-4 mb-4 bg-white border border-gray-200 rounded-lg shadow-sm dark:border-gray-700 sm:p-6 dark:bg-gray-800';
+const BASE_CLASSES = 'mb-4 bg-white border border-gray-200 rounded-lg shadow-sm dark:border-gray-700 dark:bg-gray-800';
const VARIANT_CLASSES: Record<CardVariant, string> = {
- page: 'mx-4',
- section: '2xl:col-span-2',
- plain: '',
+ page: 'p-4 sm:p-6 mx-4',
+ section: 'p-4 sm:p-5 2xl:col-span-2',
+ plain: 'p-4 sm:p-6',
};
/**
diff --git a/apps/web/src/components/shared/PageHeader.tsx b/apps/web/src/components/shared/PageHeader.tsx
index 85b13c15f..ae1d22122 100644
--- a/apps/web/src/components/shared/PageHeader.tsx
+++ b/apps/web/src/components/shared/PageHeader.tsx
@@ -9,13 +9,14 @@ type PageHeaderProps = {
title: string;
description?: string;
titleActions?: React.ReactNode;
+ titleSuffix?: React.ReactNode;
customActions?: React.ReactNode;
};
/**
* Page header with breadcrumbs, title, description and actions.
*/
-const PageHeader: React.FC<PageHeaderProps> = ({ breadcrumbItems = [], title, description = '', titleActions, customActions }) => {
+const PageHeader: React.FC<PageHeaderProps> = ({ breadcrumbItems = [], title, description = '', titleActions, titleSuffix, customActions }) => {
const { t } = useTranslation();
const items: BreadcrumbItem[] = [{ displayName: t('sharedResources.Home'), url: '/', showHomeIcon: true }, ...breadcrumbItems];
@@ -24,7 +25,13 @@ const PageHeader: React.FC<PageHeaderProps> = ({ breadcrumbItems = [], title, de
<div className="mb-4 col-span-full xl:mb-2">
<Breadcrumb items={items} />
<div className="flex flex-row items-center justify-between gap-4">
- {titleActions ?? <H1>{title}</H1>}
+ {titleActions ?? (titleSuffix ? (
+ <div className="flex flex-wrap items-center gap-3">
+ <H1>{title}</H1>
+ {/* Centering uses the heading's line box, whose descender space makes the glyphs sit lower; nudge down to match. */}
+ <div className="translate-y-0.5">{titleSuffix}</div>
+ </div>
+ ) : <H1>{title}</H1>)}
{customActions && (
<div className="flex flex-wrap items-center gap-2">
{customActions}
diff --git a/apps/web/src/components/shared/SectionTitle.tsx b/apps/web/src/components/shared/SectionTitle.tsx
new file mode 100644
index 000000000..919b7e696
--- /dev/null
+++ b/apps/web/src/components/shared/SectionTitle.tsx
@@ -0,0 +1,17 @@
+import React from 'react';
+
+type SectionTitleProps = {
+ children: React.ReactNode;
+ className?: string;
+ htmlFor?: string;
+};
+
+/**
+ * Title of a section card on the item pages.
+ */
+const SectionTitle: React.FC<SectionTitleProps> = ({ children, className = 'mb-3', htmlFor }) => {
+ const classes = `text-lg font-semibold dark:text-white ${className}`.trim();
+ return htmlFor ? <label htmlFor={htmlFor} className={`block ${classes}`}>{children}</label> : <h3 className={classes}>{children}</h3>;
+};
+
+export default SectionTitle;
diff --git a/apps/web/src/components/totp/TotpCodes.tsx b/apps/web/src/components/totp/TotpCodes.tsx
index f13ca60ab..f300d2980 100644
--- a/apps/web/src/components/totp/TotpCodes.tsx
+++ b/apps/web/src/components/totp/TotpCodes.tsx
@@ -7,6 +7,7 @@ import { useTranslation } from 'react-i18next';
import Card from '@/components/shared/Card';
import FormLabel from '@/components/shared/FormLabel';
import FormModal from '@/components/shared/FormModal';
+import SectionTitle from '@/components/shared/SectionTitle';
import { useConfirmModal } from '@/context/ConfirmModalContext';
import { useNotifications } from '@/context/NotificationContext';
@@ -167,7 +168,7 @@ const TotpCodes: React.FC<TotpCodesProps> = ({ totpCodes, onTotpCodesChange, can
<Card variant="section" className="relative">
<div className="flex justify-between items-start">
<div>
- <h3 className="text-xl font-semibold dark:text-white">{t(`${tk}.TwoFactorAuthenticationTitle`)}</h3>
+ <SectionTitle className="">{t(`${tk}.TwoFactorAuthenticationTitle`)}</SectionTitle>
</div>
<div className="flex items-center gap-2">
{visibleCodes.length > 0 && !isAddFormVisible && (
diff --git a/apps/web/src/components/totp/TotpViewer.tsx b/apps/web/src/components/totp/TotpViewer.tsx
index ca58971e4..a31f4b4f1 100644
--- a/apps/web/src/components/totp/TotpViewer.tsx
+++ b/apps/web/src/components/totp/TotpViewer.tsx
@@ -4,6 +4,7 @@ import React, { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import Card from '@/components/shared/Card';
+import SectionTitle from '@/components/shared/SectionTitle';
import { useClipboardCopy } from '@/hooks/useClipboardCopy';
import type { ItemRef } from '@aliasvault/client/database/ItemRef';
@@ -72,7 +73,7 @@ const TotpViewer: React.FC<TotpViewerProps> = ({ totpCodes, item }) => {
<Card variant="section">
<div className="flex justify-between">
<div>
- <h3 className="mb-4 text-xl font-semibold dark:text-white">{t('components.main.components.totpCodes.totpViewer.TwoFactorAuthenticationTitle')}</h3>
+ <SectionTitle>{t('components.main.components.totpCodes.totpViewer.TwoFactorAuthenticationTitle')}</SectionTitle>
</div>
</div>
diff --git a/apps/web/src/pages/items/AddEdit.tsx b/apps/web/src/pages/items/AddEdit.tsx
index b83b6070b..3c3b8730b 100644
--- a/apps/web/src/pages/items/AddEdit.tsx
+++ b/apps/web/src/pages/items/AddEdit.tsx
@@ -23,6 +23,7 @@ import Card from '@/components/shared/Card';
import FormLabel from '@/components/shared/FormLabel';
import PageContent from '@/components/shared/PageContent';
import PageHeader from '@/components/shared/PageHeader';
+import SectionTitle from '@/components/shared/SectionTitle';
import StickyActionBar from '@/components/shared/StickyActionBar';
import TotpCodes from '@/components/totp/TotpCodes';
import { useDb } from '@/context/DbContext';
@@ -48,8 +49,8 @@ const MIN_SAVE_INDICATOR_MS = 250;
*/
const Section: React.FC<{ title?: React.ReactNode; children: React.ReactNode; className?: string }> = ({ title, children, className = '' }) => (
<Card variant="section" className={className}>
- {title && <h3 className="mb-4 text-xl font-semibold dark:text-white flex items-center gap-2">{title}</h3>}
- <div className="grid gap-6">
+ {title && <SectionTitle className="mb-3 flex items-center gap-2">{title}</SectionTitle>}
+ <div className="grid gap-4">
{children}
</div>
</Card>
@@ -491,6 +492,11 @@ const ItemAddEditForm: React.FC = () => {
breadcrumbItems={breadcrumbItems}
title={editMode ? t(`${tk}.EditItemTitle`) : t(`${tk}.AddItemTitle`)}
description={editMode ? t(`${tk}.EditItemDescription`) : t(`${tk}.AddItemDescription`)}
+ titleSuffix={!loading && (
+ <ItemTypeSelector selectedType={edit.ItemType} onSelectedTypeChange={(type) => {
+ void handleItemTypeChange(edit, type).then(setEdit);
+ }} showDropdown={showTypeDropdown} onShowDropdownChange={setShowTypeDropdown} />
+ )}
customActions={(
<>
<Button color="success" onClick={() => void save()}>{t(`${tk}.SaveItemButton`)}</Button>
@@ -507,13 +513,8 @@ const ItemAddEditForm: React.FC = () => {
}}>
<div className="grid grid-cols-1 px-4 pt-6 md:grid-cols-2 lg:grid-cols-3 md:gap-4 dark:bg-gray-900">
<div className="col-span-1 md:col-span-1 lg:col-span-1">
- <ItemTypeSelector selectedType={edit.ItemType} onSelectedTypeChange={(type) => {
- void handleItemTypeChange(edit, type).then(setEdit);
- }} showDropdown={showTypeDropdown} onShowDropdownChange={setShowTypeDropdown} />
-
- <div className="p-4 mb-4 bg-white border-2 border-primary-600 rounded-lg shadow-sm 2xl:col-span-2 dark:border-gray-700 sm:p-6 dark:bg-gray-800">
- <h3 className="mb-4 text-xl font-semibold dark:text-white">{t(`${tk}.ServiceSectionHeader`)}</h3>
- <div className="grid gap-6">
+ <Card variant="section">
+ <div className="grid gap-4">
<div className="col-span-6 sm:col-span-3">
<FormLabel htmlFor="service-name">{t(`${tk}.ServiceNameLabel`)}</FormLabel>
<div className="flex items-start gap-4">
@@ -542,7 +543,7 @@ const ItemAddEditForm: React.FC = () => {
</div>
)}
</div>
- </div>
+ </Card>
{show2FA && hasLoginFields && (
<div className="col-span-1 md:col-span-1 lg:col-span-1">
@@ -672,7 +673,7 @@ const ItemAddEditForm: React.FC = () => {
{edit.ItemType === ItemTypes.Alias && (
<div className="col-span-1 md:col-span-1 lg:col-span-2">
<Card variant="section">
- <h3 className="mb-4 text-xl font-semibold dark:text-white flex items-center justify-between gap-2">
+ <SectionTitle className="mb-3 flex items-center justify-between gap-2">
<span>{t(`${tk}.AliasSectionHeader`)}</span>
<button type="button" id="generate-random-alias" onClick={() => void onGenerateRandomAlias()} className="p-1.5 text-gray-400 hover:text-primary-500 transition-colors focus:outline-none" title={t('sharedResources.Generate')}>
<svg className="w-4 h-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
@@ -680,8 +681,8 @@ const ItemAddEditForm: React.FC = () => {
<path d="M20.49 15a9 9 0 1 1-2.12-9.36L23 10" />
</svg>
</button>
- </h3>
- <div className="grid gap-6">
+ </SectionTitle>
+ <div className="grid gap-4">
<div className="col-span-6 sm:col-span-3">{textField(FieldKey.AliasFirstName, 'first-name', t(`${tk}.FirstNameLabel`))}</div>
<div className="col-span-6 sm:col-span-3">{textField(FieldKey.AliasLastName, 'last-name', t(`${tk}.LastNameLabel`))}</div>
<div className="col-span-6 sm:col-span-3">{textField(FieldKey.AliasGender, 'gender', t(`${tk}.GenderLabel`))}</div>
@@ -728,7 +729,7 @@ const ItemAddEditForm: React.FC = () => {
{customFields.length > 0 && (
<div className="col-span-1 md:col-span-1 lg:col-span-2">
<Card variant="section">
- <h3 className="mb-4 text-xl font-semibold dark:text-white">{t(`${tk}.CustomFieldsSectionHeader`)}</h3>
+ <SectionTitle>{t(`${tk}.CustomFieldsSectionHeader`)}</SectionTitle>
<DraggableCustomFieldsList
customFields={customFields}
onReorder={reordered => update(current => reorderCustomFields(current, reordered))}
diff --git a/apps/web/src/pages/items/View.tsx b/apps/web/src/pages/items/View.tsx
index b74188998..17709fc55 100644
--- a/apps/web/src/pages/items/View.tsx
+++ b/apps/web/src/pages/items/View.tsx
@@ -10,6 +10,7 @@ import { type DisplayField, getUrlValues, groupDisplayFields, shouldBeFullWidth
import FieldBlock from '@/components/items/FieldBlock';
import { buildFolderBreadcrumbs } from '@/components/items/FolderBreadcrumbs';
import ItemIcon from '@/components/items/ItemIcon';
+import { ItemTypePill } from '@/components/items/ItemTypeSelector';
import LoadingIndicator from '@/components/loading/LoadingIndicator';
import type { BreadcrumbItem } from '@/components/shared/Breadcrumb';
import Button from '@/components/shared/Button';
@@ -18,6 +19,7 @@ import FormModal from '@/components/shared/FormModal';
import LinkButton from '@/components/shared/LinkButton';
import PageContent from '@/components/shared/PageContent';
import PageHeader from '@/components/shared/PageHeader';
+import SectionTitle from '@/components/shared/SectionTitle';
import TotpViewer from '@/components/totp/TotpViewer';
import { useDb } from '@/context/DbContext';
import { useNotifications } from '@/context/NotificationContext';
@@ -35,7 +37,7 @@ import type { Folder } from '@aliasvault/client/database/repositories/FolderRepo
*/
const Section: React.FC<{ title?: string; children: React.ReactNode }> = ({ title, children }) => (
<Card variant="section">
- {title && <h3 className="mb-4 text-xl font-semibold dark:text-white">{title}</h3>}
+ {title && <SectionTitle>{title}</SectionTitle>}
{children}
</Card>
);
@@ -169,6 +171,7 @@ const ItemView: React.FC = () => {
<PageHeader
breadcrumbItems={breadcrumbItems}
title={t('pages.main.items.view.ViewItemTitle')}
+ titleSuffix={<ItemTypePill itemType={item.ItemType} />}
customActions={(
<>
<LinkButton smallText={t('pages.main.items.view.EditButtonMobile')} text={t('pages.main.items.view.EditButtonDesktop')} href={itemRoute(item, true)} color="primary" />
@@ -223,7 +226,7 @@ const ItemView: React.FC = () => {
<div className="col-span-1 md:col-span-2 lg:col-span-2">
{isLoginLike && loginFields.length > 0 && (
<Card variant="section">
- <h3 className="mb-2 text-xl font-semibold dark:text-white">{t('pages.main.items.view.LoginDetailsSection')}</h3>
+ <SectionTitle className="mb-2">{t('pages.main.items.view.LoginDetailsSection')}</SectionTitle>
<p className="mb-4 text-sm text-gray-600 dark:text-gray-400">
<span>{domains.isAliasVaultSupportedDomain(emailAddress) ? t('pages.main.items.view.GeneratedItemDescription') : t('pages.main.items.view.StoredItemDescription')}</span>
</p>
diff --git a/core/client/src/items/FaviconService.ts b/core/client/src/items/FaviconService.ts
index dd64ec6cc..7a8bc3786 100644
--- a/core/client/src/items/FaviconService.ts
+++ b/core/client/src/items/FaviconService.ts
@@ -54,7 +54,6 @@ export type FaviconFetchOptions = {
*/
const FAVICON_FETCH_TIMEOUT_MS = 5000;
-
/**
* Centralized service for favicon/logo operations, shared by every client.
*/
diff --git a/core/client/src/utilities/ImageType.ts b/core/client/src/utilities/ImageType.ts
index dab9700ac..4c720ce18 100644
--- a/core/client/src/utilities/ImageType.ts
+++ b/core/client/src/utilities/ImageType.ts
@@ -31,8 +31,16 @@ export function detectImageMimeType(bytes: Uint8Array): string | null {
return 'image/webp';
}
- // An SVG may start with an XML declaration, a BOM or whitespace before the root element.
- const head = new TextDecoder().decode(bytes.subarray(0, 256)).replace(/^/, '').trimStart().toLowerCase();
+ /*
+ * An SVG may start with an XML declaration, BOM (\uFEFF), or whitespace before the root element.
+ * Remove BOM and trim leading whitespace safely.
+ */
+ let head = new TextDecoder().decode(bytes.subarray(0, 256));
+ // Remove BOM (uFEFF if present at start)
+ if (head.charCodeAt(0) === 0xFEFF) {
+ head = head.substring(1);
+ }
+ head = head.trimStart().toLowerCase();
if (head.startsWith('<svg') || (head.startsWith('<?xml') && head.includes('<svg'))) {
return 'image/svg+xml';
}