Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add default loading skeleton #1512

Merged
merged 32 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
abbba95
feat: add global loading logic
Wxh16144 Feb 28, 2023
c2e592f
Merge branch 'master' into wuxh/feat-1463
Wxh16144 Aug 21, 2023
90631ee
chore: update
Wxh16144 Aug 21, 2023
ec9ce09
chore: update lock file
Wxh16144 Aug 21, 2023
b6cfc8d
docs: update dingtalk qrcode
PeachScript Oct 19, 2023
d24b60f
fix: conventional 2-level nav lost in localized routes (#1951)
PeachScript Oct 26, 2023
2675e58
chore: bump @babel/traverse from 7.22.8 to 7.23.2 (#1947)
dependabot[bot] Oct 26, 2023
31fd13c
build: release 2.2.14
PeachScript Oct 26, 2023
3753b1b
docs: correct spelling of code sandbox
PeachScript Nov 23, 2023
d87114e
fix: unexpected transformation of colon symbol (#1962)
DBSDs Dec 7, 2023
ef4835a
chore: bump browserify-sign from 4.2.1 to 4.2.2 (#1954)
dependabot[bot] Dec 7, 2023
1c2a6fb
fix: color select disappeared unexpectedly on simulator (#1976)
binyellow Dec 7, 2023
8f9e80b
fix: wrong search scroll position of 1-level heading in current page …
binyellow Dec 11, 2023
7131d3e
fix: api table does not respect ignore flag (#1981)
PeachScript Dec 11, 2023
fdc9672
build: release 2.2.15
PeachScript Dec 11, 2023
65e9759
fix: handle unexpected oneof and allof for api metadata (#1982)
PeachScript Dec 13, 2023
7975dca
refactor: cache dir config can control compile fs cache location (#1984)
PeachScript Dec 13, 2023
4d1b823
refactor: use async way to parse theme modules (#1983)
xierenyuan Dec 13, 2023
4246aff
build: release 2.2.16
PeachScript Dec 13, 2023
b2489ac
Merge branch 'master' into wuxh/feat-1463
Wxh16144 Dec 15, 2023
6eeac57
chore: revert change
Wxh16144 Dec 15, 2023
fee192f
Revert "chore: revert change"
Wxh16144 Dec 15, 2023
7b2897c
chore: remove
Wxh16144 Dec 15, 2023
9ee8f22
feat: add loadcomp logic
Wxh16144 Dec 15, 2023
f373a03
chore: making the simple complicated is commonplace
Wxh16144 Dec 15, 2023
d609dc7
Revert "Revert "chore: revert change""
Wxh16144 Dec 26, 2023
b3af251
Merge branch 'feature/2.3.0' into wuxh/feat-1463_2.3.0
Wxh16144 Dec 26, 2023
45f7bd6
chore: ?
Wxh16144 Dec 26, 2023
255baf2
chore: clean code
Wxh16144 Dec 26, 2023
b8119b4
chore: update lock file
Wxh16144 Dec 26, 2023
43ca3b5
chore: update
Wxh16144 Dec 26, 2023
ff42b74
chore: update style
Wxh16144 Dec 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
"react-copy-to-clipboard": "^5.1.0",
"react-error-boundary": "^4.0.10",
"react-intl": "^6.4.4",
"react-loading-skeleton": "^3.1.1",
"react-simple-code-editor": "^0.13.1",
"rehype-autolink-headings": "^6.1.1",
"rehype-remove-comments": "^5.0.0",
Expand Down
19 changes: 15 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/client/pages/Loading.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// allow customize loading via theme slots or ./dumi/loading.tsx
export { default } from 'dumi/theme/slots/Loading';
20 changes: 20 additions & 0 deletions src/client/theme-default/slots/Loading/index.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@import (reference) '../../styles/variables.less';

@skeleton-cls: react-loading-skeleton;

.@{prefix}-loading-skeleton {
.@{skeleton-cls} {
margin-block-end: 0.38em;

&.first-line {
width: calc(100% - 2em);
margin-inline-start: 2em;
}

// ======== dark mode ========
@{dark-selector} & {
--highlight-color: fade(@c-text-dark, @dark-light-amount);
--base-color: @c-text;
}
}
}
14 changes: 14 additions & 0 deletions src/client/theme-default/slots/Loading/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import Skeleton from 'react-loading-skeleton';
import 'react-loading-skeleton/dist/skeleton.css';
import './index.less';

const Loading: React.FC = () => (
<div className="dumi-default-loading-skeleton">
<Skeleton className="first-line" count={1} />
<Skeleton count={2} />
<Skeleton count={1} width="75%" />
</div>
);

export default Loading;
13 changes: 6 additions & 7 deletions src/features/theme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ import { safeExcludeInMFSU } from '../derivative';
import loadTheme, { IThemeLoadResult } from './loader';

const DEFAULT_THEME_PATH = path.join(__dirname, '../../../theme-default');
const DEFAULT_LOADING_PATH = winPath(
path.resolve(__dirname, '../../client/pages/Loading'),
);

/**
* get pkg theme name
Expand Down Expand Up @@ -273,7 +276,7 @@ export default (api: IApi) => {
// execute before umi tmpFiles plugin
stage: -Infinity,
fn() {
const { globalLoading } = api.appData;
const { globalLoading = DEFAULT_LOADING_PATH } = api.appData;
const enableNProgress = !!api.config.themeConfig.nprogress;

// replace original loading component data
Expand All @@ -291,12 +294,8 @@ export default (api: IApi) => {
)}';
import './nprogress.css';`
: ''
}${
globalLoading
? `
import UserLoading from '${globalLoading}';`
: ''
}
import UserLoading from '${globalLoading}';
import React, { useLayoutEffect, type FC } from 'react';
import { useSiteData } from 'dumi';
Expand All @@ -321,7 +320,7 @@ const DumiLoading: FC = () => {
}
}, []);
return ${globalLoading ? '<UserLoading />' : 'null'};
return <UserLoading />
}
export default DumiLoading;
Expand Down
Loading