-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add pure image col type to leaderboard and add pure code driven…
… leaderboard tool Signed-off-by: frank-zsy <[email protected]>
- Loading branch information
Showing
7 changed files
with
64 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
# 排行榜 | ||
|
||
在该页面中,您可以通过输入数据和配置表头的方式生成具有一定样式的排行榜供您分享。 | ||
|
||
import Leaderboard from '@site/src/components/Leaderboard'; | ||
import SimpleLeaderboard from '@site/src/components/SimpleLeaderboard'; | ||
|
||
在该页面中,您可以通过输入数据和配置表头的方式生成具有一定样式的排行榜供您分享。 | ||
|
||
<Leaderboard /> | ||
|
||
下面为一个使用纯数据配置的排行榜,输入为一个 JSON 对象,包含 title、data 和 options 三个字段,分别对应表的标题、数据和表头配置。 | ||
|
||
<SimpleLeaderboard /> |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import styles from './styles.module.css'; | ||
|
||
interface PureImageProps { | ||
url: string; | ||
rounded?: boolean; | ||
} | ||
|
||
export const PureImage = ({ url, rounded }: PureImageProps) => { | ||
return ( | ||
<div className={styles.nameContainer}> | ||
{(url && url != '') ? | ||
<img src={url} alt="" className={`${styles.icon} ${rounded ? styles.iconRounded : ''}`} /> : null} | ||
</div> | ||
) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React, { useState } from 'react'; | ||
import SimpleTable from '../SimpleTable'; | ||
import styles from '../Leaderboard/styles.module.css'; | ||
|
||
export default (): JSX.Element => { | ||
const [title, setTitle] = useState<string>(''); | ||
const [data, setData] = useState<any[]>([]); | ||
const [options, setOptions] = useState<any[]>([]); | ||
const onDataInputBlur = e => { | ||
try { | ||
const inputValue = e.target.value; | ||
const newData = inputValue ? JSON.parse(inputValue) : { title: '', data: [], options: [] }; | ||
setTitle(newData.title); | ||
setData(newData.data); | ||
setOptions(newData.options); | ||
} catch { | ||
alert('Not valid JSON'); | ||
} | ||
}; | ||
return ( | ||
<div> | ||
<div className={styles.inputRow}> | ||
<input className={styles.dataInput} autoComplete='false' spellCheck='false' onBlur={onDataInputBlur} /> | ||
</div> | ||
<SimpleTable title={title} data={data} options={options} /> | ||
</div> | ||
); | ||
}; |