-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(deps): upgrade @rstack-dev/doc-ui 1.4.2 (#1384)
- Loading branch information
Showing
10 changed files
with
78 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 0 additions & 54 deletions
54
packages/document/theme/components/Benchmark/ProgressBar.tsx
This file was deleted.
Oops, something went wrong.
66 changes: 0 additions & 66 deletions
66
packages/document/theme/components/Benchmark/index.module.scss
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
html { | ||
--rs-benchmark-bar-background: linear-gradient( | ||
to right, | ||
#514fe6, | ||
#6a93f1, | ||
#2fa5e0 | ||
); | ||
} |
164 changes: 58 additions & 106 deletions
164
packages/document/theme/components/Benchmark/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,111 +1,63 @@ | ||
import { useState } from 'react'; | ||
import { Tabs, Tab } from 'rspress/theme'; | ||
import { NoSSR, useI18n } from 'rspress/runtime'; | ||
import { ProgressBar } from './ProgressBar'; | ||
import { | ||
Benchmark as BaseBenchmark, | ||
type BenchmarkData, | ||
} from '@rstack-dev/doc-ui/benchmark'; | ||
import './index.scss'; | ||
|
||
const BENCHMARK_DATA = { | ||
start: [ | ||
{ | ||
name: 'Rspress', | ||
// The unit is seconds | ||
time: 0.786, | ||
}, | ||
{ | ||
name: 'Docusaurus', | ||
time: 8.46, | ||
}, | ||
{ | ||
name: 'Nextra', | ||
time: 8.2, | ||
}, | ||
], | ||
hmr: [ | ||
{ | ||
name: 'Rspress', | ||
time: 0.07, | ||
}, | ||
{ | ||
name: 'Docusaurus', | ||
time: 0.12, | ||
}, | ||
{ | ||
name: 'Nextra', | ||
time: 0.18, | ||
}, | ||
], | ||
build: [ | ||
{ | ||
name: 'Rspress', | ||
time: 2.51, | ||
}, | ||
{ | ||
name: 'Docusaurus', | ||
time: 14.91, | ||
}, | ||
{ | ||
name: 'Nextra', | ||
time: 17.25, | ||
}, | ||
], | ||
const BENCHMARK_DATA: BenchmarkData = { | ||
rspress: { | ||
label: 'Rspress', | ||
metrics: [ | ||
{ | ||
time: 0.07, | ||
desc: 'hmr', | ||
}, | ||
{ | ||
time: 0.786, | ||
desc: 'dev', | ||
}, | ||
{ | ||
time: 2.51, | ||
desc: 'build', | ||
}, | ||
], | ||
}, | ||
docusaurus: { | ||
label: 'Docusaurus', | ||
metrics: [ | ||
{ | ||
time: 0.12, | ||
desc: 'hmr', | ||
}, | ||
{ | ||
time: 8.46, | ||
desc: 'dev', | ||
}, | ||
{ | ||
time: 14.91, | ||
desc: 'build', | ||
}, | ||
], | ||
}, | ||
nextra: { | ||
label: 'Nextra', | ||
metrics: [ | ||
{ | ||
time: 0.18, | ||
desc: 'hmr', | ||
}, | ||
{ | ||
time: 8.2, | ||
desc: 'dev', | ||
}, | ||
{ | ||
time: 17.25, | ||
desc: 'build', | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
export function Benchmark() { | ||
const SCENE = ['start', 'hmr', 'build']; | ||
const t = useI18n(); | ||
const [activeScene, setActiveScene] = | ||
useState<keyof typeof BENCHMARK_DATA>('start'); | ||
const performanceInfoList = BENCHMARK_DATA[activeScene]; | ||
return ( | ||
<NoSSR> | ||
<div className="relative flex flex-col justify-center py-10 mt-15 h-auto"> | ||
<div | ||
className="flex flex-col items-center z-1" | ||
style={{ | ||
padding: '16px 0', | ||
}} | ||
> | ||
<Tabs | ||
values={SCENE.map(item => ({ | ||
label: t(item as keyof typeof BENCHMARK_DATA), | ||
}))} | ||
onChange={index => | ||
setActiveScene(SCENE[index] as keyof typeof BENCHMARK_DATA) | ||
} | ||
tabPosition="center" | ||
> | ||
{SCENE.map(scene => ( | ||
<Tab key={scene}> | ||
{performanceInfoList.map(info => ( | ||
<div | ||
key={info.name} | ||
className="flex flex-center justify-start flex-col sm:flex-row" | ||
style={{ | ||
margin: '16px 16px 16px 0', | ||
}} | ||
> | ||
{ | ||
<> | ||
<p | ||
className="mr-2 mb-2 w-20 text-center text-gray-500 dark:text-light-500" | ||
style={{ minWidth: '140px' }} | ||
> | ||
{info.name} | ||
</p> | ||
<ProgressBar | ||
value={info.time} | ||
max={Math.max( | ||
...performanceInfoList.map(info => info.time), | ||
)} | ||
/> | ||
</> | ||
} | ||
</div> | ||
))} | ||
</Tab> | ||
))} | ||
</Tabs> | ||
</div> | ||
</div> | ||
</NoSSR> | ||
); | ||
return <BaseBenchmark data={BENCHMARK_DATA} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,9 @@ | |
padding-top: 5rem; | ||
padding-bottom: 6rem; | ||
height: auto; | ||
|
||
max-width: 72rem; | ||
margin: 0 auto; | ||
} | ||
|
||
.header { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.