Skip to content

Commit a444410

Browse files
arvsrnBrendonovich
andauthored
feat(app): new update button (anomalyco#30460)
Co-authored-by: Brendan Allan <[email protected]>
1 parent a3b97d9 commit a444410

2 files changed

Lines changed: 52 additions & 14 deletions

File tree

‎packages/app/src/components/titlebar.tsx‎

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,11 @@ export function Titlebar(props: { update?: TitlebarUpdate }) {
121121
const hasProjects = createMemo(() => layout.projects.list().length > 0)
122122
const nav = createMemo(() => (useV2Titlebar() ? settings.general.showNavigation() : true))
123123
const updateState = createMemo<TitlebarUpdatePillState>(() => {
124+
const installing = props.update?.installing() ?? false
124125
const version = props.update?.version()
125126
return {
126-
visible: version !== undefined,
127-
installing: props.update?.installing() ?? false,
127+
visible: version !== undefined || installing,
128+
installing,
128129
label: "Update",
129130
ariaLabel: language.t("toast.update.action.installRestart"),
130131
title: version ? `Update ${version}` : undefined,
@@ -219,9 +220,9 @@ export function Titlebar(props: { update?: TitlebarUpdate }) {
219220
return (
220221
<header
221222
classList={{
222-
"shrink-0 relative overflow-hidden flex flex-row": true,
223-
"h-9 bg-v2-background-bg-deep": useV2Titlebar(),
224-
"h-10 bg-background-base": !useV2Titlebar(),
223+
"shrink-0 relative flex flex-row": true,
224+
"h-9 bg-v2-background-bg-deep overflow-visible": useV2Titlebar(),
225+
"h-10 bg-background-base overflow-hidden": !useV2Titlebar(),
225226
}}
226227
style={{
227228
"min-height": minHeight(),
@@ -705,27 +706,39 @@ type TitlebarV2RightState = {
705706

706707
function TitlebarV2Right(props: { state: TitlebarV2RightState }) {
707708
return (
708-
<div class="flex shrink-0 items-center justify-end gap-0">
709-
<TitlebarUpdatePill state={props.state.update} />
709+
<div class="relative z-20 flex shrink-0 items-center justify-end gap-0 overflow-visible">
710+
<TitlebarUpdateIconButton state={props.state.update} />
710711
<div id="opencode-titlebar-right" class="flex shrink-0 items-center justify-end gap-0" />
711712
</div>
712713
)
713714
}
714715

715-
function TitlebarUpdatePill(props: { state: TitlebarUpdatePillState }) {
716+
function TitlebarUpdateIconButton(props: { state: TitlebarUpdatePillState }) {
716717
return (
717-
<Show when={props.state.visible}>
718+
<div class="relative isolate mr-3 size-5 shrink-0">
718719
<button
719720
type="button"
720-
class="h-5 shrink-0 rounded-[27px] bg-[var(--v2-background-bg-layer-03)] px-2.5 text-[11px] font-[530] leading-4 tracking-[0.05px] text-[var(--v2-text-text-base)] disabled:opacity-60"
721+
class="group absolute right-0 top-0 z-10 flex h-5 w-5 items-center justify-end overflow-hidden rounded-full bg-v2-icon-icon-accent/20 text-v2-icon-icon-accent transition-[width,background-color] duration-150 ease-out hover:z-30 hover:w-[68px] hover:bg-[color-mix(in_srgb,var(--v2-icon-icon-accent)_20%,var(--v2-background-bg-deep))] focus-visible:z-30 focus-visible:w-[68px] focus-visible:bg-[color-mix(in_srgb,var(--v2-icon-icon-accent)_20%,var(--v2-background-bg-deep))] focus-visible:outline-none disabled:opacity-60 motion-reduce:transition-none"
721722
onClick={props.state.onInstall}
722723
disabled={props.state.installing}
724+
aria-busy={props.state.installing}
723725
aria-label={props.state.ariaLabel}
724-
title={props.state.title}
725726
>
726-
{props.state.label}
727+
<span class="shrink-0 ml-[8px] mr-px text-[11px] text-v2-text-text-accent [font-weight:530] opacity-0 translate-x-2 motion-safe:transition-all duration-150 ease-out group-hover:opacity-100 group-hover:translate-x-0 group-focus-visible:opacity-100 group-focus-visible:translate-x-0 motion-reduce:translate-x-0">
728+
Update
729+
</span>
730+
<span class="flex size-5 shrink-0 items-center justify-center">
731+
<Show
732+
when={!props.state.installing}
733+
fallback={<span data-slot="titlebar-update-loader" aria-hidden="true" />}
734+
>
735+
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" aria-hidden="true">
736+
<path d="M7 11V3M3.5 7.63128L7 11L10.5 7.63128" stroke="currentColor" />
737+
</svg>
738+
</Show>
739+
</span>
727740
</button>
728-
</Show>
741+
</div>
729742
)
730743
}
731744

‎packages/app/src/index.css‎

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
@font-face {
1212
font-family: "Inter";
1313
src: url("/assets/Inter.ttf") format("truetype");
14-
font-weight: normal;
14+
font-weight: 100 900;
1515
font-style: normal;
1616
}
1717

@@ -137,6 +137,31 @@
137137
}
138138
}
139139

140+
[data-slot="titlebar-update-loader"] {
141+
display: block;
142+
flex-shrink: 0;
143+
margin: 1px;
144+
width: 12px;
145+
height: 12px;
146+
border-radius: 9999px;
147+
border: 2px solid color-mix(in srgb, var(--v2-icon-icon-accent) 30%, transparent);
148+
border-top-color: var(--v2-icon-icon-accent);
149+
animation: titlebar-update-loader-spin 0.67s linear infinite;
150+
transform-origin: 50% 50%;
151+
}
152+
153+
@media (prefers-reduced-motion: reduce) {
154+
[data-slot="titlebar-update-loader"] {
155+
animation: none;
156+
}
157+
}
158+
159+
@keyframes titlebar-update-loader-spin {
160+
to {
161+
transform: rotate(360deg);
162+
}
163+
}
164+
140165
@keyframes fade-in {
141166
from {
142167
opacity: 0;

0 commit comments

Comments
 (0)