mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 00:34:19 +00:00
Animate popups, dialogs, notices and meters
- Ease popups in with a 2px drift from their anchor and fade them out faster - Fade dialogs and their backdrops in and out - Bring notices, map pills and the lost connection card in with a short rise - Glide the memory, progress, bake and pregen meters to each new reading - Turn all of it off under reduced motion - Drop the animation classes that had no styles behind them
This commit is contained in:
1 parent
646850df43
commit
60e7d255cc
15 files changed
+116
-20
No files matched your search
@@ -86,7 +86,7 @@ function ContextMenuSubContent({
|
||||
<ContextMenuPrimitive.SubContent
|
||||
data-slot="context-menu-sub-content"
|
||||
className={cn(
|
||||
"z-50 min-w-[8rem] origin-(--radix-context-menu-content-transform-origin) overflow-hidden popup p-1 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",
|
||||
"z-50 min-w-[8rem] overflow-hidden popup p-1 popup-motion",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
@@ -104,7 +104,7 @@ function ContextMenuContent({
|
||||
<ContextMenuPrimitive.Content
|
||||
data-slot="context-menu-content"
|
||||
className={cn(
|
||||
"z-50 max-h-(--radix-context-menu-content-available-height) min-w-[8rem] origin-(--radix-context-menu-content-transform-origin) overflow-x-hidden overflow-y-auto popup p-1 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",
|
||||
"z-50 max-h-(--radix-context-menu-content-available-height) min-w-[8rem] overflow-x-hidden overflow-y-auto popup p-1 popup-motion",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
|
||||
@@ -39,7 +39,7 @@ function DialogOverlay({
|
||||
<DialogPrimitive.Overlay
|
||||
data-slot="dialog-overlay"
|
||||
className={cn(
|
||||
"fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",
|
||||
"fixed inset-0 z-50 bg-black/50 backdrop-motion",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
@@ -61,7 +61,7 @@ function DialogContent({
|
||||
<DialogPrimitive.Content
|
||||
data-slot="dialog-content"
|
||||
className={cn(
|
||||
"fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 popup bg-card p-6 duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg",
|
||||
"fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 popup bg-card p-6 outline-none dialog-motion sm:max-w-lg",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
|
||||
@@ -4,7 +4,7 @@ import { DropdownMenu as DropdownMenuPrimitive } from "radix-ui"
|
||||
import { Glyph } from "@/studio/Glyph"
|
||||
|
||||
const MENU_SURFACE =
|
||||
"z-50 min-w-[8rem] overflow-x-hidden overflow-y-auto popup p-1 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0"
|
||||
"z-50 min-w-[8rem] overflow-x-hidden overflow-y-auto popup p-1 popup-motion"
|
||||
const MENU_ROW =
|
||||
"relative flex cursor-default items-center gap-2 rounded-md px-2 py-1 text-[13px] outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50"
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ function PopoverContent({ className, align = "start", sideOffset = 4, ...props }
|
||||
align={align}
|
||||
sideOffset={sideOffset}
|
||||
className={cn(
|
||||
"z-50 popup p-2 outline-hidden data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",
|
||||
"z-50 popup p-2 outline-hidden popup-motion",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
|
||||
@@ -41,7 +41,7 @@ function TooltipContent({
|
||||
data-slot="tooltip-content"
|
||||
sideOffset={sideOffset}
|
||||
className={cn(
|
||||
"z-50 w-fit origin-(--radix-tooltip-content-transform-origin) animate-in popup px-2.5 py-1.5 text-xs text-balance fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",
|
||||
"z-50 w-fit popup px-2.5 py-1.5 text-xs text-balance popup-motion",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
|
||||
@@ -54,7 +54,7 @@ export function BakeMeter({ timing }: BakeMeterProps): React.JSX.Element {
|
||||
{timing === null ? MEASURING_LABEL : weight.label}
|
||||
</span>
|
||||
<div className="h-1 min-w-0 flex-1 rounded-full bg-muted">
|
||||
{timing !== null && <div className={cn('h-full rounded-full', weight.fillClass)} style={{ width: `${meterFill(millis) * PERCENT}%`, minWidth: MINIMUM_FILL }} />}
|
||||
{timing !== null && <div className={cn('h-full rounded-full meter-motion', weight.fillClass)} style={{ width: `${meterFill(millis) * PERCENT}%`, minWidth: MINIMUM_FILL }} />}
|
||||
</div>
|
||||
<span className="w-[46px] shrink-0 text-right text-secondary-text tabular-nums">{timing !== null && formatMillis(millis)}</span>
|
||||
</div>
|
||||
|
||||
@@ -289,8 +289,8 @@ export function MapStudio({ client, world, theme, onDisconnect }: MapStudioProps
|
||||
</div>
|
||||
)}
|
||||
{!connected && (
|
||||
<div className="absolute inset-0 flex items-center justify-center bg-background/70">
|
||||
<div className="popup p-5 text-center">
|
||||
<div className="absolute inset-0 flex items-center justify-center bg-background/70 backdrop-motion">
|
||||
<div className="popup p-5 text-center dialog-motion">
|
||||
<p className="font-medium">Lost the connection to the server</p>
|
||||
<button className="mt-3 text-link hover:underline" onClick={onDisconnect}>
|
||||
Back to the world list
|
||||
|
||||
@@ -258,7 +258,7 @@ function ValueInput({ row, onDone }: { row: SettingRow; onDone(): void }): React
|
||||
}}
|
||||
/>
|
||||
{shownProblem !== null && (
|
||||
<p className="absolute top-full left-0 z-30 mt-1 w-max max-w-[260px] popup border-destructive px-1.5 py-1 text-[11px] whitespace-normal">
|
||||
<p className="absolute top-full left-0 z-30 mt-1 w-max max-w-[260px] popup border-destructive px-1.5 py-1 text-[11px] whitespace-normal popup-motion">
|
||||
{shownProblem}
|
||||
</p>
|
||||
)}
|
||||
|
||||
@@ -318,7 +318,7 @@ function NoiseTerrainView({
|
||||
return (
|
||||
<div className="absolute inset-0">
|
||||
<SceneViewport content={content} framing={content} />
|
||||
{sampling && <div className={cn(PILL, 'top-3 left-1/2 -translate-x-1/2')}>Sampling {source.name}</div>}
|
||||
{sampling && <div className={cn(PILL, 'top-3 left-1/2 -translate-x-1/2 notice-motion')}>Sampling {source.name}</div>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ function Progress({ snapshot, onPause }: { snapshot: PregenSnapshot; onPause():
|
||||
<section className="flex flex-col gap-2 px-4 py-3 text-[12px]">
|
||||
<h2 className="text-[11px] font-semibold text-muted-foreground">{PHASE_LABELS[snapshot.phase]}</h2>
|
||||
<div className="h-1.5 overflow-hidden rounded-full bg-muted">
|
||||
<div className="h-full bg-primary" style={{ width: `${Math.min(PERCENT, progress.percent)}%` }} />
|
||||
<div className="h-full bg-primary meter-motion" style={{ width: `${Math.min(PERCENT, progress.percent)}%` }} />
|
||||
</div>
|
||||
<Row label="Done" value={`${RATE.format(progress.percent)}%`} />
|
||||
<Row label="Chunks" value={`${NUMBER.format(progress.generated)} of ${NUMBER.format(progress.totalChunks)}`} />
|
||||
|
||||
@@ -114,8 +114,8 @@ export function SavedWorldStudio({ title, client, world, onSummary, onProgress,
|
||||
}
|
||||
>
|
||||
<SceneViewport content={content} framing={content} spotActions={spotActions} />
|
||||
{reading && chosen !== null && <div className={PILL}>Reading {chosen.name}</div>}
|
||||
{!reading && chosen !== null && start === null && <div className={PILL}>Nothing finished is saved in {chosen.name}</div>}
|
||||
{reading && chosen !== null && <div className={cn(PILL, 'notice-motion')}>Reading {chosen.name}</div>}
|
||||
{!reading && chosen !== null && start === null && <div className={cn(PILL, 'notice-motion')}>Nothing finished is saved in {chosen.name}</div>}
|
||||
</ViewIsland>
|
||||
<SidebarPanel className="flex-1">
|
||||
<header className="px-4 pt-2.5 pb-2.5">
|
||||
|
||||
@@ -32,7 +32,15 @@ export function StatusBar({ viewLabel, status, notice, usage, progress }: Status
|
||||
)}
|
||||
</span>
|
||||
<span className="flex min-w-0 flex-1 items-center justify-center gap-2 truncate">
|
||||
{notice ?? (drawing ? `Drawing ${status.tilesReady} of ${status.tilesTotal} tiles` : progress !== null ? 'Reading' : '')}
|
||||
{notice !== null ? (
|
||||
<span key={notice} className="truncate notice-motion">
|
||||
{notice}
|
||||
</span>
|
||||
) : drawing ? (
|
||||
`Drawing ${status.tilesReady} of ${status.tilesTotal} tiles`
|
||||
) : progress !== null ? (
|
||||
'Reading'
|
||||
) : null}
|
||||
{notice === null && drawing && <ProgressBar fraction={status.tilesReady / status.tilesTotal} />}
|
||||
{notice === null && !drawing && progress !== null && <ProgressBar fraction={progress} />}
|
||||
</span>
|
||||
@@ -50,7 +58,7 @@ export function StatusBar({ viewLabel, status, notice, usage, progress }: Status
|
||||
function ProgressBar({ fraction }: { fraction: number }): React.JSX.Element {
|
||||
return (
|
||||
<span className="h-1 w-24 overflow-hidden rounded-full bg-secondary">
|
||||
<span className="block h-full bg-primary" style={{ width: `${fraction * 100}%` }} />
|
||||
<span className="block h-full bg-primary meter-motion" style={{ width: `${fraction * 100}%` }} />
|
||||
</span>
|
||||
)
|
||||
}
|
||||
@@ -92,7 +100,7 @@ function Reading({ high, hint, children }: ReadingProps): React.JSX.Element {
|
||||
function MemoryIndicator({ share, high, children }: { share: number; high: boolean; children: React.ReactNode }): React.JSX.Element {
|
||||
return (
|
||||
<span className="relative flex h-5 items-center overflow-hidden rounded-sm px-2">
|
||||
<span className={cn('absolute inset-y-0 left-0', high ? 'bg-warning/30' : 'bg-meter-used')} style={{ width: `${share * 100}%` }} />
|
||||
<span className={cn('absolute inset-y-0 left-0 meter-motion', high ? 'bg-warning/30' : 'bg-meter-used')} style={{ width: `${share * 100}%` }} />
|
||||
<span className="relative">{children}</span>
|
||||
</span>
|
||||
)
|
||||
|
||||
@@ -68,7 +68,7 @@ export function SuggestionInput({ value, onValue, isList, load, onKeyDown, onFoc
|
||||
}}
|
||||
/>
|
||||
{offered.length > 0 && (
|
||||
<ul className="absolute top-full right-0 left-0 z-30 mt-0.5 overflow-hidden popup py-0.5">
|
||||
<ul className="absolute top-full right-0 left-0 z-30 mt-0.5 overflow-hidden popup py-0.5 popup-motion">
|
||||
{offered.map((choice, index) => (
|
||||
<li key={choice}>
|
||||
<button
|
||||
|
||||
@@ -158,7 +158,7 @@ function NamedViews({ groups, current, onSelect }: { groups: ViewGroup[]; curren
|
||||
</button>
|
||||
</DropdownMenu.Trigger>
|
||||
<DropdownMenu.Portal>
|
||||
<DropdownMenu.Content side="right" align="end" sideOffset={8} className="popup z-50 w-56 p-1">
|
||||
<DropdownMenu.Content side="right" align="end" sideOffset={8} className="popup z-50 w-56 p-1 popup-motion">
|
||||
{groups.map((group) => (
|
||||
<DropdownMenu.Group key={group.label}>
|
||||
<DropdownMenu.Label className="px-2 pt-1.5 pb-1 text-[11px] font-semibold text-muted-foreground">{group.label}</DropdownMenu.Label>
|
||||
|
||||
@@ -137,6 +137,94 @@
|
||||
box-shadow: 0 0 0 1px var(--ring);
|
||||
}
|
||||
|
||||
/*
|
||||
* Motion after IntelliJ: popups and notices ease in quickly and leave faster, meters glide to a new reading, and
|
||||
* everything else, hover and selection included, changes at once. Reduced motion turns all of it off.
|
||||
*/
|
||||
@keyframes popup-in {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translate(var(--popup-shift-x, 0), var(--popup-shift-y, 0));
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes notice-in {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(4px);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes fade-in {
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes fade-out {
|
||||
to {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Drifts 2px away from what it is anchored to, by the side Radix places it on. */
|
||||
@utility popup-motion {
|
||||
animation: popup-in 120ms ease-out;
|
||||
&[data-side="top"] {
|
||||
--popup-shift-y: 2px;
|
||||
}
|
||||
&[data-side="bottom"] {
|
||||
--popup-shift-y: -2px;
|
||||
}
|
||||
&[data-side="left"] {
|
||||
--popup-shift-x: 2px;
|
||||
}
|
||||
&[data-side="right"] {
|
||||
--popup-shift-x: -2px;
|
||||
}
|
||||
&[data-state="closed"] {
|
||||
animation: fade-out 80ms ease-in forwards;
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
animation: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
@utility dialog-motion {
|
||||
animation: fade-in 100ms ease-out;
|
||||
&[data-state="closed"] {
|
||||
animation: fade-out 80ms ease-in forwards;
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
animation: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
@utility backdrop-motion {
|
||||
animation: fade-in 100ms ease-out;
|
||||
&[data-state="closed"] {
|
||||
animation: fade-out 80ms ease-in forwards;
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
animation: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
@utility notice-motion {
|
||||
animation: notice-in 160ms ease-out;
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
animation: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* A meter's fill, which glides to each new reading instead of jumping. */
|
||||
@utility meter-motion {
|
||||
transition: width 300ms ease-out;
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* IntelliJ draws its icons a shade off the text colour; a context that colours its icons sets this to currentColor. */
|
||||
@utility icon-tint {
|
||||
--icon-tint: currentColor;
|
||||
|
||||
Reference in new issue
Block a user