mirror of
https://github.com/jhd3197/ServerKit.git
synced 2026-12-01 20:55:16 +09:00
Merge pull request #237 from jhd3197/feat/ux-page-actions
fix(ui): keep page actions together on narrow screens
This commit is contained in:
4 files changed
+83
-26
No files matched your search
@@ -83,6 +83,7 @@ export function KpiBand({
|
||||
<div
|
||||
className={cn('sk-kpiband', dense && 'sk-kpiband--dense', className)}
|
||||
style={{ '--kpi-cols': cols }}
|
||||
data-cols={cols}
|
||||
>
|
||||
{primary}
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useState, useEffect, useId, useMemo } from 'react';
|
||||
import {
|
||||
ShieldCheck, RefreshCw, Plus, Lock, MoreVertical,
|
||||
Settings, Download, Upload,
|
||||
Settings, Download, Upload, MoreHorizontal,
|
||||
} from 'lucide-react';
|
||||
import api from '../services/api';
|
||||
import Modal from '@/components/Modal';
|
||||
@@ -24,6 +24,7 @@ import {
|
||||
import DomainField from '../components/DomainField';
|
||||
import { formatExpiry } from '../utils/expiry';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import useMediaQuery from '@/hooks/useMediaQuery';
|
||||
import { toastError } from '@/utils/errorMessage';
|
||||
import { formatDateTime } from '@/utils/intl';
|
||||
|
||||
@@ -98,6 +99,7 @@ const SSL_BUILTIN_VIEWS = [
|
||||
|
||||
const SSLCertificates = () => {
|
||||
const { t } = useTranslation();
|
||||
const phone = useMediaQuery('(max-width: 639px)');
|
||||
const fieldId = useId();
|
||||
const toast = useToast();
|
||||
const { confirm } = useConfirm();
|
||||
@@ -471,37 +473,71 @@ const SSLCertificates = () => {
|
||||
{t('app.sSLCertificates.installCertbot', 'Install Certbot')}
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={handleSetupAutoRenewal}
|
||||
disabled={actionLoading || !certbotInstalled}
|
||||
title={t('app.sSLCertificates.configureAutomaticRenewalViaSystemdOr', 'Configure automatic renewal via systemd or cron')}
|
||||
>
|
||||
<Settings size={15} />
|
||||
{t('app.sSLCertificates.autoRenew2', 'Auto-renew')}
|
||||
</Button>
|
||||
{certificates.length > 0 && (
|
||||
<Button variant="outline" size="sm" onClick={handleRenewAll} disabled={actionLoading}>
|
||||
<RefreshCw size={15} />
|
||||
{t('app.sSLCertificates.renewAll', 'Renew all')}
|
||||
</Button>
|
||||
{phone ? (
|
||||
// Phones: the secondary actions share one overflow menu so the
|
||||
// bar stays a single row; Install Certbot / New certificate stay out.
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button variant="outline" size="icon" aria-label={t('common.more', 'More')}>
|
||||
<MoreHorizontal size={15} />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
<DropdownMenuItem onClick={handleSetupAutoRenewal} disabled={actionLoading || !certbotInstalled}>
|
||||
<Settings size={15} />
|
||||
{t('app.sSLCertificates.autoRenew2', 'Auto-renew')}
|
||||
</DropdownMenuItem>
|
||||
{certificates.length > 0 && (
|
||||
<DropdownMenuItem onClick={handleRenewAll} disabled={actionLoading}>
|
||||
<RefreshCw size={15} />
|
||||
{t('app.sSLCertificates.renewAll', 'Renew all')}
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
<DropdownMenuItem onClick={loadData}>
|
||||
<RefreshCw size={15} />
|
||||
{t('common.actions.refresh', 'Refresh')}
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={() => setShowUploadModal(true)}>
|
||||
<Upload size={15} />
|
||||
{t('app.sSLCertificates.upload', 'Upload')}
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
) : (
|
||||
<>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={handleSetupAutoRenewal}
|
||||
disabled={actionLoading || !certbotInstalled}
|
||||
title={t('app.sSLCertificates.configureAutomaticRenewalViaSystemdOr', 'Configure automatic renewal via systemd or cron')}
|
||||
>
|
||||
<Settings size={15} />
|
||||
{t('app.sSLCertificates.autoRenew2', 'Auto-renew')}
|
||||
</Button>
|
||||
{certificates.length > 0 && (
|
||||
<Button variant="outline" size="sm" onClick={handleRenewAll} disabled={actionLoading}>
|
||||
<RefreshCw size={15} />
|
||||
{t('app.sSLCertificates.renewAll', 'Renew all')}
|
||||
</Button>
|
||||
)}
|
||||
<Button variant="outline" size="sm" onClick={loadData}>
|
||||
<RefreshCw size={15} />
|
||||
{t('common.actions.refresh', 'Refresh')}
|
||||
</Button>
|
||||
<Button variant="outline" size="sm" onClick={() => setShowUploadModal(true)}>
|
||||
<Upload size={15} />
|
||||
{t('app.sSLCertificates.upload', 'Upload')}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
<Button variant="outline" size="sm" onClick={loadData}>
|
||||
<RefreshCw size={15} />
|
||||
{t('common.actions.refresh', 'Refresh')}
|
||||
</Button>
|
||||
<Button variant="outline" size="sm" onClick={() => setShowUploadModal(true)}>
|
||||
<Upload size={15} />
|
||||
{t('app.sSLCertificates.upload', 'Upload')}
|
||||
</Button>
|
||||
<Button size="sm" onClick={() => setShowObtainModal(true)} disabled={!certbotInstalled}>
|
||||
<Plus size={15} />
|
||||
{t('app.sSLCertificates.newCertificate', 'New certificate')}
|
||||
</Button>
|
||||
<SearchField value={search} onSearch={setSearch} placeholder={t('app.sSLCertificates.searchCertificates', 'Search certificates…')} />
|
||||
</>
|
||||
), [actionLoading, certbotInstalled, certbotMissing, certificates.length, search]);
|
||||
), [actionLoading, certbotInstalled, certbotMissing, certificates.length, search, phone]);
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -60,10 +60,15 @@
|
||||
&__actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
// No wrap: the search shrinks, so an icon button is never orphaned. When
|
||||
// the bar itself wraps, this group takes its own row, icons together.
|
||||
flex-wrap: nowrap;
|
||||
flex: 0 1 auto;
|
||||
min-width: 0;
|
||||
gap: $space-2;
|
||||
margin-inline-start: auto;
|
||||
|
||||
> * { flex-shrink: 0; }
|
||||
}
|
||||
|
||||
// Amber, not red: unsaved tweaks are a state, not an error.
|
||||
|
||||
@@ -275,6 +275,7 @@ $sk-tones: ('accent', 'green', 'cyan', 'amber', 'red', 'violet');
|
||||
flex-direction: column;
|
||||
gap: $space-3;
|
||||
margin-bottom: $space-5;
|
||||
container-type: inline-size;
|
||||
}
|
||||
|
||||
.sk-kpiband {
|
||||
@@ -290,6 +291,11 @@ $sk-tones: ('accent', 'green', 'cyan', 'amber', 'red', 'violet');
|
||||
@media (max-width: 560px) {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
// Four tiles: 4 across or 2x2, never the 3+1 auto-fit gives at tablet width.
|
||||
// Measured on the band's own container, so a sidebar-narrowed page agrees.
|
||||
@container (max-width: 820px) {
|
||||
&[data-cols='4'] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||||
}
|
||||
|
||||
// Skeleton tile — same geometry as .sk-kpi so content doesn't jump on load.
|
||||
&__skel {
|
||||
@@ -1517,6 +1523,7 @@ $sk-tones: ('accent', 'green', 'cyan', 'amber', 'red', 'violet');
|
||||
&__actions {
|
||||
order: 2;
|
||||
width: 100%;
|
||||
flex-wrap: wrap;
|
||||
min-width: 0;
|
||||
justify-content: flex-start;
|
||||
overflow-x: auto;
|
||||
@@ -1528,6 +1535,11 @@ $sk-tones: ('accent', 'green', 'cyan', 'amber', 'red', 'violet');
|
||||
> *,
|
||||
> .sk-topbar__chrome > * { flex-shrink: 0; }
|
||||
|
||||
// The search takes what is left on its row and wraps to a row of its
|
||||
// own (full width) when even its minimum doesn't fit — never offscreen.
|
||||
> .sk-searchfield,
|
||||
> .sk-topbar__chrome > .sk-searchfield { flex: 1 1 180px; max-width: none; min-width: 0; }
|
||||
|
||||
&::-webkit-scrollbar { display: none; }
|
||||
}
|
||||
&__tabs { order: 3; width: 100%; margin-left: 0; justify-content: flex-start; }
|
||||
@@ -1669,6 +1681,9 @@ $sk-tones: ('accent', 'green', 'cyan', 'amber', 'red', 'violet');
|
||||
min-width: 180px;
|
||||
max-width: 420px;
|
||||
|
||||
// Inside a view bar it shrinks before its icon buttons would wrap.
|
||||
.sk-viewbar__actions > & { flex: 1 1 auto; min-width: 96px; }
|
||||
|
||||
&__icon {
|
||||
position: absolute;
|
||||
left: 11px;
|
||||
|
||||
Reference in new issue
Block a user