From a795a86423b813a9f189d15b89ab92bd2188fbbb Mon Sep 17 00:00:00 2001 From: Yilun Sun Date: Thu, 16 May 2024 14:08:36 +0800 Subject: [PATCH] fix: icon unexpected intermediate state while loading the page - solution from: https://github.com/vercel/next.js/issues/44125#issuecomment-1372270391 --- package.json | 1 + pnpm-lock.yaml | 9 +++-- src/app/globals.css | 21 +++++++++++ src/app/layout.tsx | 35 ++++++++++++++---- src/app/viewer/json-viewer.css | 18 ++++++---- src/app/viewer/json-viewer.tsx | 21 +++++++++-- src/app/viewer/viewer.css | 21 +---------- src/app/viewer/viewer.tsx | 65 +++++++++++++++++++++------------- 8 files changed, 128 insertions(+), 63 deletions(-) diff --git a/package.json b/package.json index 74127f0..d1cbceb 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "copy-vendor": "cp -R vendor/ .next/server/vendor/" }, "dependencies": { + "@ant-design/cssinjs": "^1.20.0", "@fortawesome/fontawesome-svg-core": "^6.5.2", "@fortawesome/free-brands-svg-icons": "^6.5.2", "@fortawesome/free-solid-svg-icons": "^6.5.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 602d6e4..70b798a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5,6 +5,9 @@ settings: excludeLinksFromLockfile: false dependencies: + '@ant-design/cssinjs': + specifier: ^1.20.0 + version: 1.20.0(react-dom@18.2.0)(react@18.2.0) '@fortawesome/fontawesome-svg-core': specifier: ^6.5.2 version: 6.5.2 @@ -98,8 +101,8 @@ packages: '@ctrl/tinycolor': 3.6.1 dev: false - /@ant-design/cssinjs@1.19.1(react-dom@18.2.0)(react@18.2.0): - resolution: {integrity: sha512-hgQ3wiys3X0sqDKWkqCJ6EYdF79i9JCvtavmIGwuuPUKmoJXV8Ff0sY+yQQSxk2dRmMyam/bYKo/Bwor45hnZw==} + /@ant-design/cssinjs@1.20.0(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-uG3iWzJxgNkADdZmc6W0Ci3iQAUOvLMcM8SnnmWq3r6JeocACft4ChnY/YWvI2Y+rG/68QBla/O+udke1yH3vg==} peerDependencies: react: '>=16.0.0' react-dom: '>=16.0.0' @@ -764,7 +767,7 @@ packages: react-dom: '>=16.9.0' dependencies: '@ant-design/colors': 7.0.2 - '@ant-design/cssinjs': 1.19.1(react-dom@18.2.0)(react@18.2.0) + '@ant-design/cssinjs': 1.20.0(react-dom@18.2.0)(react@18.2.0) '@ant-design/icons': 5.3.6(react-dom@18.2.0)(react@18.2.0) '@ant-design/react-slick': 1.1.2(react@18.2.0) '@babel/runtime': 7.24.4 diff --git a/src/app/globals.css b/src/app/globals.css index df84034..7a1a665 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -26,3 +26,24 @@ body { text-wrap: balance; } } + +.ant-breadcrumb > ol { + flex-wrap: nowrap !important; + align-items: center; + overflow-x: auto; +} + +.ant-dropdown-menu-sub { + max-height: 50vh; + overflow-y: auto; + box-shadow: + 0 6px 16px 0 rgba(0, 0, 0, 0.08), + 0 3px 6px -4px rgba(0, 0, 0, 0.12), + 0 9px 28px 8px rgba(0, 0, 0, 0.05); + border-radius: 8px; +} + +.ant-dropdown-menu-submenu-title { + display: flex; + align-items: center; +} diff --git a/src/app/layout.tsx b/src/app/layout.tsx index fed2b15..68407c0 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -1,13 +1,34 @@ -import type { Metadata } from 'next'; +'use client'; import { Inter } from 'next/font/google'; +import { createCache, extractStyle, StyleProvider } from '@ant-design/cssinjs'; +import { useState } from 'react'; +import { useServerInsertedHTML } from 'next/navigation'; import './globals.css'; const inter = Inter({ subsets: ['latin'] }); -export const metadata: Metadata = { - title: 'PHP AST Viewer', - description: 'View the Abstract Syntax Tree (AST) of PHP code parsed by the PHP-Parser library.', -}; +// https://github.com/vercel/next.js/issues/44125#issuecomment-1372270391 +function StyleProviderLayout({ children }: { children: React.ReactNode }) { + const [cache] = useState(() => createCache()); + + const render = <>{children}; + + useServerInsertedHTML(() => { + return ( +