fix(ui): give InfoTips one placement and spacing rule

The (i) sat 0-16px from the text it explains depending on the page.
It now sits ~4px after the text and is centred on that line, in both
inline and flex contexts.

- inline call sites that were glued to the text get a plain space
- flex containers that added their own 8-10px gap are normalized
- InfoTip nudged up 1px so it centres on the text line
- settings rows wrap on phones so the (i) stays beside its label
- Servers level picker uses InfoTip instead of a hover-only tooltip
- placement rule documented in the InfoTip header comment
This commit is contained in:
Juan Denis committed 2026-11-09 18:40:46 -05:00
1 parent 6b7a4b7f28
commit 1c9c0c7dd5
11 files changed
+32 -45

No files matched your search

+3
View File
@@ -11,6 +11,9 @@ import { t } from '../i18n/t';
// pins it open; on a pinned tip they toggle it closed. Narrow screens get a
// bottom sheet instead, so the text never sits on top of the content it
// explains. Both are portalled (no button-in-button) and above Modal/Sheet.
// Placement: put it right after the label/heading text it explains, inside
// the same element (separate it with a plain space, or let the flex gap do it),
// never on its own line. Standard: ~4px after the text, centred on that line.
// `trigger` replaces the (i) glyph (e.g. a whole step pill); `title` heads the sheet.
export default function InfoTip({ children, label, title, trigger, side = 'top', size = 'sm', className = '' }) {
const [open, setOpen] = useState(false);
+2 -2
View File
@@ -37,7 +37,7 @@ const RequiresDocker = ({ children, what = 'This page' }) => {
<p className="requires-docker__text">
{what} {t('app.requiresDocker.needsDocker', 'needs Docker.')}
<InfoTip>
{' '}<InfoTip>
{what} {t('app.requiresDocker.needsDockerToRunContainersAnd', 'needs Docker to run containers, and this server was installed with the')} <strong>{profileLabel}</strong> {t('app.requiresDocker.profileWhichLeavesItOutNothing', 'profile, which leaves it out. Nothing is locked; adding Docker turns this page on.')}
</InfoTip>
</p>
@@ -58,7 +58,7 @@ const RequiresDocker = ({ children, what = 'This page' }) => {
<p className="requires-docker__footnote">
{t('app.requiresDocker.checkedAutomatically', 'Re-checked automatically.')}{' '}
<Link to="/settings/system">{t('app.requiresDocker.settingsSystem', 'Settings → System')}</Link>
<InfoTip>
{' '}<InfoTip>
{t('app.requiresDocker.serverkitReChecksForDockerAutomatically', 'ServerKit re-checks for Docker automatically. Monitoring, domains, certificates, cron and DNS keep working without it. See')}{' '}
{t('app.requiresDocker.settingsSystem', 'Settings → System')} {t('app.requiresDocker.forThisInstallSProfile', 'for this install\'s profile.')}
</InfoTip>
+2 -2
View File
@@ -183,7 +183,7 @@ function Downloads() {
<section className="downloads-section">
<h2>{t('app.downloads.directDownloads', 'Direct downloads')}
<InfoTip>{t('app.downloads.downloadTheAgentBinaryForYour', 'Download the agent binary for your platform. After downloading, follow the installation instructions below.')}</InfoTip></h2>
{' '}<InfoTip>{t('app.downloads.downloadTheAgentBinaryForYour', 'Download the agent binary for your platform. After downloading, follow the installation instructions below.')}</InfoTip></h2>
<div className="download-cards">
{platforms.map((platform) => {
@@ -219,7 +219,7 @@ function Downloads() {
<section className="downloads-section">
<h2>{t('app.downloads.quickInstallCommands', 'Quick install commands')}
<InfoTip>{t('app.downloads.useTheseOneLinerCommandsTo', 'Use these one-liner commands to download and install the agent. Replace')} <code>YOUR_TOKEN</code> {t('app.downloads.withTheServerRegistrationToken', 'with the server registration token.')}</InfoTip></h2>
{' '}<InfoTip>{t('app.downloads.useTheseOneLinerCommandsTo', 'Use these one-liner commands to download and install the agent. Replace')} <code>YOUR_TOKEN</code> {t('app.downloads.withTheServerRegistrationToken', 'with the server registration token.')}</InfoTip></h2>
<p className="section-description">{t('app.downloads.replaceTokenHint', 'Replace')} <code>YOUR_TOKEN</code></p>
<div className="install-commands">
+4 -4
View File
@@ -223,12 +223,12 @@ const RemoteAccess = ({ serverId }) => {
{serverId && currentServer ? (
<p>
{t('app.remoteAccess.exposeServicesOn', 'Expose services on')} <strong>{currentServer.name}</strong>.
<InfoTip>{t('app.remoteAccess.exposeServicesRunningOn', 'Expose services running on')} <strong>{currentServer.name}</strong> {t('app.remoteAccess.toAPublicHostnameOverA', 'to a public hostname over a WireGuard tunnel. ServerKit pairs this host with an edge server that has a public IP.')}</InfoTip>
{' '}<InfoTip>{t('app.remoteAccess.exposeServicesRunningOn', 'Expose services running on')} <strong>{currentServer.name}</strong> {t('app.remoteAccess.toAPublicHostnameOverA', 'to a public hostname over a WireGuard tunnel. ServerKit pairs this host with an edge server that has a public IP.')}</InfoTip>
</p>
) : (
<p>
{t('app.remoteAccess.exposeAPrivateServicePublicly', 'Expose a private service publicly.')}
<InfoTip>{t('app.remoteAccess.exposeAServiceRunningOnA', 'Expose a service running on a private server (behind NAT, no port-forwarding) to a public hostname over a WireGuard tunnel between two of your agents.')}</InfoTip>
{' '}<InfoTip>{t('app.remoteAccess.exposeAServiceRunningOnA', 'Expose a service running on a private server (behind NAT, no port-forwarding) to a public hostname over a WireGuard tunnel between two of your agents.')}</InfoTip>
</p>
)}
{serverId && (
@@ -247,12 +247,12 @@ const RemoteAccess = ({ serverId }) => {
description={serverId ? (
<>
{t('app.remoteAccess.pickAPublicIpEdgeServerShort', 'Pick a public-IP edge server.')}
<InfoTip>{t('app.remoteAccess.pickAPublicIpEdgeServer', 'Pick a public-IP edge server and ServerKit will pair it with {{value}} over WireGuard.', { value: currentServer?.name || t('app.remoteAccess.thisHost', 'this host') })}</InfoTip>
{' '}<InfoTip>{t('app.remoteAccess.pickAPublicIpEdgeServer', 'Pick a public-IP edge server and ServerKit will pair it with {{value}} over WireGuard.', { value: currentServer?.name || t('app.remoteAccess.thisHost', 'this host') })}</InfoTip>
</>
) : (
<>
{t('app.remoteAccess.pickAnEdgeAndAPrivateHost', 'Pick an edge and a private host.')}
<InfoTip>{t('app.remoteAccess.pickAPublicIpEdgeServer2', 'Pick a public-IP edge server and a private host, and ServerKit will pair them over WireGuard and publish your service. No router changes are needed.')}</InfoTip>
{' '}<InfoTip>{t('app.remoteAccess.pickAPublicIpEdgeServer2', 'Pick a public-IP edge server and a private host, and ServerKit will pair them over WireGuard and publish your service. No router changes are needed.')}</InfoTip>
</>
)}
action={exposeButton}
+8 -16
View File
@@ -1,9 +1,8 @@
import { useState, useEffect, useCallback, useMemo, useId } from 'react';
import { useNavigate } from 'react-router-dom';
import { Ban, ChevronRight, ClipboardPaste, Container, Cpu, Database, Flame, Folder, Hash, HardDrive, Info, KeyRound, Lock, MemoryStick, Plus, RefreshCw, Server as ServerLucideIcon, Terminal, X } from 'lucide-react';
import { Ban, ChevronRight, ClipboardPaste, Container, Cpu, Database, Flame, Folder, Hash, HardDrive, KeyRound, Lock, MemoryStick, Plus, RefreshCw, Server as ServerLucideIcon, Terminal, X } from 'lucide-react';
import InfoTip from '../components/InfoTip';
import IconStepStrip from '../components/IconStepStrip';
import { Tooltip, TooltipTrigger, TooltipContent } from '@/components/ui/tooltip';
import LevelIllustration from '../components/servers/LevelIllustrations';
import api from '../services/api';
import { useToast } from '../contexts/useToast.js';
@@ -889,20 +888,13 @@ const LevelPicker = ({ value, onChange }) => {
})}
</span>
</div>
<Tooltip>
<TooltipTrigger asChild>
<Button variant="unstyled" type="button" className="level-picker__info"
aria-label={t('app.servers.levelInfo', 'What can {{level}} do?', { level: levelLabel(level) })}
onClick={(e) => e.stopPropagation()}
>
<Info size={14} aria-hidden="true" />
</Button>
</TooltipTrigger>
<TooltipContent side="top" align="end" className="level-picker__tip">
<span>{copy[level].can}</span>
<span>{copy[level].cannot}</span>
</TooltipContent>
</Tooltip>
<InfoTip className="level-picker__info"
label={t('app.servers.levelInfo', 'What can {{level}} do?', { level: levelLabel(level) })}
side="top"
>
<p>{copy[level].can}</p>
<p>{copy[level].cannot}</p>
</InfoTip>
</div>
))}
</div>
@@ -1862,6 +1862,7 @@ $sk-tones: ('accent', 'green', 'cyan', 'amber', 'red', 'violet');
&.is-clickable:focus-within { border-color: var(--border); }
&__head { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
&__head > .info-tip { margin-inline-start: -6px; } // 10px gap - 6 = the 4px InfoTip rule
&__icon {
display: inline-flex; align-items: center; justify-content: center;
flex-shrink: 0;
@@ -14,6 +14,7 @@
cursor: pointer;
vertical-align: middle;
position: relative;
inset-block-start: -1px; // optical: middle-aligned glyph sits ~1-2px below the text's centre
// Invisible 32px touch target; the glyph and line box stay as they are.
&::before {
+3 -1
View File
@@ -96,6 +96,8 @@
svg { flex-shrink: 0; }
&.tip-chip-row { gap: $space-1; }
// Amber, not red: keeping backups only on the same disk is a risk to fix,
// not a failure that has already happened.
&--warn {
@@ -1117,7 +1119,7 @@
flex: 1 1 12rem;
flex-wrap: wrap;
align-items: center;
gap: 0 $space-2;
gap: 0 $space-1;
min-inline-size: 0;
font-size: $text-sm;
+1
View File
@@ -574,6 +574,7 @@
}
.mon-panel-hint svg { flex-shrink: 0; color: var(--green); }
.mon-panel-hint .info-tip { margin-inline-start: -$space-1; } // gap is 8px; the tip sits 4px after the text
// Wide tables keep their own scroller so the panel never widens the page.
.mon-table-scroll { overflow-x: auto; }
+1 -19
View File
@@ -2651,29 +2651,11 @@
}
}
// Corner-positioned InfoTip: deliberately outside the inline spacing rule.
&__info {
position: absolute;
top: $space-1;
inset-inline-end: $space-1;
display: inline-flex;
padding: $space-1;
color: $text-tertiary;
background: none;
border: 0;
border-radius: 50%;
cursor: pointer;
&:hover,
&:focus-visible {
color: $text-primary;
}
}
&__tip {
flex-direction: column;
align-items: flex-start;
max-width: 260px;
white-space: normal;
}
&__note {
+6 -1
View File
@@ -1170,6 +1170,7 @@
background: $bg-hover;
border-radius: $radius-control;
gap: $space-4;
flex-wrap: wrap; // on phones the control drops below the label instead of squeezing it
&:not(:last-child) {
margin-bottom: $space-3;
@@ -1182,12 +1183,15 @@
}
.settings-label {
flex: 1;
flex: 1 1 12rem;
display: flex;
flex-wrap: wrap;
align-items: center;
column-gap: $space-1;
// `.form-group label` adds a bottom margin; mirror it so align-items: center centres the (i) on the text, not text + margin.
.form-group & > .ui-label + .info-tip { margin-block-end: $space-2; }
> span:first-child {
display: block;
font-weight: $font-weight-medium;
@@ -1416,6 +1420,7 @@
display: flex;
align-items: flex-start;
justify-content: space-between;
flex-wrap: wrap;
gap: $space-3;
margin-bottom: $space-3;