Authentication-Results: mail-b.sr.ht; dkim=pass header.d=gmail.com header.i=@gmail.com Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) by mail-b.sr.ht (Postfix) with ESMTPS id BBC1011EFF3 for <~avery/public-inbox@lists.sr.ht>; Thu, 1 Sep 2022 16:58:02 +0000 (UTC) Received: by mail-lj1-f178.google.com with SMTP id p18so15208846ljc.9 for <~avery/public-inbox@lists.sr.ht>; Thu, 01 Sep 2022 09:58:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=gDmNfsEn4GC0BQIIn5hKt5LA5W7Xmzk5a1HLA1tcOuo=; b=obrMGqKXxuT8d1gKfe6Kg/XKig73YLugGyPfrabWwM4VJ80yAa+tpqWMAODLMNVZcA 3rcNlIApF6LoWkAsq9Wg06OZOstQbzsab4cqgqkhIcYP+CNZlHixy+i6Wzorn3Gx0WNx OjwWucRthDST+fD0XJVsc3Iz8Fu4NEGUuoKCx/fMJbC0cIN2Uh2a3xM96H672Vk9XK+a /fojmIEPojnQOkMLPbgC3VJBPsKPw+I0J5JjH4z07WSBcmY5Ab+XZjMFMBYqAGuwqhLG 6hDKeUAmAxqRVywZeuxUfmDoJie7CoPpkBIpM1udREjHurgCWWEBGwekkYzhPhOIcMtH 3ePA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=gDmNfsEn4GC0BQIIn5hKt5LA5W7Xmzk5a1HLA1tcOuo=; b=gY8Eao1rS/MiRjdgeKuNm3WOGjHwtX4WgJmAVhO6b2qkpHkCb+QzVwh4P1ONBxsJei 6eRpEk7ffKCrn1+Uvn5R68vdiR5LggqVzYpnykQtWz5oya1wgR3EXucp21+CysWHC+Qk bmZHkQAvDMUwEeMPaJZf/q2OMIpgtZygJWO99PhLV6Sk8vzzSI2yYCWKwfDpFEbUjCs4 cWyQ/lpw/ZiJNoaJHt8zlWp5PoMYEwYBTGyppxpbUZBEISAPYWNokdlQu3G/4cvnFJe/ CiHES+koLtXgYRva21Zuv30Z0uA3kg3WSwPKywcLo9ZUPQUaJkijEAUdmNpnBfsyqnf/ NOyQ== X-Gm-Message-State: ACgBeo11P/CgHceqf4UhL3WFR4dra9tXgpOhbM13qrKf0Mt+cDe+x/TS SHVknJE5BKmUFGe+IN3hiuScPFYHj6LgSA== X-Google-Smtp-Source: AA6agR5eorKV9g5FcnaDHLI8vqyrChQjHanZAexdLRb6KqSE/KI2LHQ2Xc7QNVCKb34Lgn5l4sNk0w== X-Received: by 2002:a05:651c:105a:b0:267:5d3d:2b25 with SMTP id x26-20020a05651c105a00b002675d3d2b25mr4099014ljm.370.1662051480846; Thu, 01 Sep 2022 09:58:00 -0700 (PDT) Received: from localhost.localdomain (c188-151-223-206.bredband.tele2.se. [188.151.223.206]) by smtp.gmail.com with ESMTPSA id b7-20020a056512070700b004948b667d95sm688343lfs.265.2022.09.01.09.58.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Sep 2022 09:58:00 -0700 (PDT) From: =?UTF-8?q?Jaras=C5=82a=C5=AD=20Viktor=C4=8Dyk?= To: ~avery/public-inbox@lists.sr.ht Cc: =?UTF-8?q?Jaras=C5=82a=C5=AD=20Viktor=C4=8Dyk?= Subject: [PATCH crankshaft v2 2/3] Restyle plugins page to match Steam Deck Date: Thu, 1 Sep 2022 18:57:44 +0200 Message-Id: <20220901165745.197501-2-ugzuzg@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220901165745.197501-1-ugzuzg@gmail.com> References: <20220901165745.197501-1-ugzuzg@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit --- injected/src/gamepad/gamepad.ts | 16 +- .../menu-manager/deck/menu-injector-deck.css | 138 +++++++++++++++--- .../menu-manager/deck/menu-injector-deck.tsx | 98 +++++++++++-- injected/src/ui/buttons.tsx | 2 +- injected/src/ui/index.ts | 3 +- 5 files changed, 217 insertions(+), 40 deletions(-) diff --git a/injected/src/gamepad/gamepad.ts b/injected/src/gamepad/gamepad.ts index a7577c5..fbd2b67 100644 --- a/injected/src/gamepad/gamepad.ts +++ b/injected/src/gamepad/gamepad.ts @@ -79,23 +79,27 @@ export class GamepadHandler { async cleanup() { await this.smm.ButtonInterceptors.removeAfter(gamepadRoot(this.id)); await this.smm.ButtonInterceptors.removeInterceptor(gamepadRoot(this.id)); - this.root - .querySelectorAll('.cs-gp-focus') - .forEach((node) => node.classList.remove('cs-gp-focus')); + this.root.querySelectorAll('.cs-gp-focus').forEach((node) => { + node.classList.remove('cs-gp-focus'); + node.blur(); + }); } updateFocused(newFocusPath: string) { const curFocus = this.tree[this.focusPath]; if (curFocus) { curFocus.el.classList.remove('cs-gp-focus'); + curFocus.el.blur(); } - document - .querySelectorAll('.cs-gp-focus') - .forEach((node) => node.classList.remove('cs-gp-focus')); + document.querySelectorAll('.cs-gp-focus').forEach((node) => { + node.classList.remove('cs-gp-focus'); + node.blur(); + }); const newFocusEl = this.tree[newFocusPath].el; newFocusEl.classList.add('cs-gp-focus'); + newFocusEl.focus(); this.focusPath = newFocusPath; diff --git a/injected/src/menu-manager/deck/menu-injector-deck.css b/injected/src/menu-manager/deck/menu-injector-deck.css index 2621f37..c2f0150 100644 --- a/injected/src/menu-manager/deck/menu-injector-deck.css +++ b/injected/src/menu-manager/deck/menu-injector-deck.css @@ -9,47 +9,110 @@ background-color: #23262e; } -[data-smm-menu-page-container] > ul:first-child { - flex: 1 0 auto; +[data-smm-menu-page-container].animate-in { + transition-property: opacity, transform; + transition-duration: 400ms; + transition-timing-function: cubic-bezier(0, 0, 0.1, 1); + transition-delay: 100ms; +} +[data-smm-menu-page-container].animate-out { + transition-property: opacity, transform; + transition-duration: 100ms; + transition-timing-function: cubic-bezier(0.6, 0, 1, 1); +} +[data-smm-menu-page-container].animate-in-end, +[data-smm-menu-page-container].animate-out-start { + opacity: 1; + transform: scale(1); +} +[data-smm-menu-page-container].animate-out-end, +[data-smm-menu-page-container].animate-in-start { + opacity: 0; + transform: scale(0.9); +} - max-width: 200px; - height: 100%; +[data-smm-menu-page-container] h1 { + font-size: 22px !important; +} + +[data-smm-menu-page-container] h2 { + font-size: 16px; +} + +[data-smm-menu-page-container] > ul:first-child { + min-width: 240px; + max-width: 40%; + height: calc(100% - 16px * 2); margin: 0; - padding: 0; + padding: 16px 0; list-style: none; - background-color: rgba(255, 255, 255, 2%); + + background: #23262e; + border-right: 1px solid #0e141b; + + flex: 1; + display: flex; + flex-direction: column; + position: relative; + overflow-x: hidden; } [data-smm-menu-page-container] > ul:first-child > li { cursor: pointer; border: solid 1px transparent; - - transition: all 200ms; } [data-smm-menu-page-container] > ul:first-child > li.cs-gp-focus { outline: none; - border-color: white; +} + +[data-smm-menu-page-container] + > ul:first-child + > li.cs-gp-focus + > .smm-menu-item-button { + transform: scale(1.1); + background: #3d4450; } .smm-menu-item-button { width: 100%; - padding: 8px 24px; + border: none; + background: none; - background-color: rgba(255, 255, 255, 2%); - color: rgba(255, 255, 255, 90%); + font-weight: normal; font-size: 16px; - border: none; + font-style: normal; + line-height: 20px; + text-align: left; + text-decoration: none; + text-indent: 0; + text-shadow: none; + text-transform: none; + letter-spacing: 0px; + color: #fff; + padding: 10px calc(12px + 1.4vw); + color: #b8bcbf; cursor: pointer; - - transition: all 150ms; + display: flex; + flex-direction: row; + transform: scale(1) rotateX(1deg); + line-height: 22px; + scroll-margin: 2.5em 0; + transition-property: transform, background-color; + transition-duration: 0.32s, 0s; + transition-timing-function: cubic-bezier(0.17, 0.45, 0.14, 0.83); + transform-origin: 12% 50%; + animation-timing-function: cubic-bezier(0.17, 0.45, 0.14, 0.83); + animation-duration: 0.5s; + animation-fill-mode: forwards; + transform: scale(1) rotateX(1deg); } .smm-menu-item-button:hover { - background-color: rgba(255, 255, 255, 4%); + background-color: #23262e; } .smm-menu-item-button.active { @@ -60,5 +123,46 @@ width: 100%; height: 100%; overflow: auto; - background-color: #23262e; + background: #0e141b; + position: relative; +} + +[data-smm-plugin-page] { + position: absolute; + top: 0; + width: 100%; + height: 100%; + overflow: hidden; +} + +[data-smm-plugin-page].animate-out-top, +[data-smm-plugin-page].animate-out-bottom { + transition-property: opacity, transform; + transition-duration: 80ms; + transition-timing-function: cubic-bezier(0.6, 0, 1, 1); +} +[data-smm-plugin-page].animate-in-top, +[data-smm-plugin-page].animate-in-bottom { + transition-property: opacity, transform; + transition-duration: 320ms; + transition-timing-function: cubic-bezier(0, 0, 0.1, 1); + transition-delay: 80ms; +} + +[data-smm-plugin-page].animate-out-top-start, +[data-smm-plugin-page].animate-out-bottom-start, +[data-smm-plugin-page].animate-in-top-end, +[data-smm-plugin-page].animate-in-bottom-end { + opacity: 1; + transform: translateY(0); +} +[data-smm-plugin-page].animate-out-bottom-end, +[data-smm-plugin-page].animate-in-top-start { + opacity: 0; + transform: translateY(-8%); +} +[data-smm-plugin-page].animate-out-top-end, +[data-smm-plugin-page].animate-in-bottom-start { + opacity: 0; + transform: translateY(8%); } diff --git a/injected/src/menu-manager/deck/menu-injector-deck.tsx b/injected/src/menu-manager/deck/menu-injector-deck.tsx index f6949a9..f8a82a8 100644 --- a/injected/src/menu-manager/deck/menu-injector-deck.tsx +++ b/injected/src/menu-manager/deck/menu-injector-deck.tsx @@ -8,6 +8,21 @@ import styles from './menu-injector-deck.css'; // @use-dom-chef +const animate = ( + node: HTMLElement, + animationName: string, + duration: number +) => { + node.classList.add(animationName, `${animationName}-start`); + setTimeout(() => { + node.classList.remove(`${animationName}-start`); + node.classList.add(`${animationName}-end`); + }, 0); + setTimeout(() => { + node.classList.remove(animationName, `${animationName}-end`); + }, duration); +}; + export class MenuInjectorDeck implements MenuInjector { private readonly smm: SMM; private readonly menuManager: MenuManager; @@ -18,17 +33,21 @@ export class MenuInjectorDeck implements MenuInjector { // List of plugins in page private menuList!: HTMLUListElement; private menuItemNodes: Record; + private menuItems: MenuItem[]; // Root to render plugin contents private menuPage!: HTMLDivElement; private menuListGamepad?: GamepadHandler; private activePluginGamepad?: GamepadHandler; + private activePluginId?: string; + private activePluginEl?: HTMLDivElement; constructor(smm: SMM, menuManager: MenuManager) { this.smm = smm; this.menuManager = menuManager; this.enteredWithNavigate = false; this.menuItemNodes = {}; + this.menuItems = []; this.injectMenuStyles(); this.createPageContainer(); @@ -103,11 +122,13 @@ export class MenuInjectorDeck implements MenuInjector { } private async closePluginsPage(forward = false) { + this.activePluginId = undefined; + this.activePluginEl = undefined; // Clear active menu item window.csMenuActiveItem = undefined; window.csMenuUpdate?.(); - deleteAll('[data-smm-menu-page-container]'); + this.hidePageContainer(); if (!forward) window.coolClass.NavigateBackOrOpenMenu(); } @@ -116,11 +137,19 @@ export class MenuInjectorDeck implements MenuInjector { document .querySelector(DECK_SELECTORS.topLevelTransitionSwitch) ?.appendChild(this.pageContainer); + animate(this.pageContainer, 'animate-in', 600); } - createMenuItem({ id, label, render }: MenuItem) { + private hidePageContainer() { + animate(this.pageContainer, 'animate-out', 100); + setTimeout(() => deleteAll('[data-smm-menu-page-container]'), 100); + } + + createMenuItem(menuItem: MenuItem) { + const { id, label, render } = menuItem; const newMenuItem = dcCreateElement(
  • { - this.openPluginPage(render); + this.openPluginPage(id, render, true); + }} + onFocus={() => { + this.openPluginPage(id, render); }} >