-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
306 additions
and
72 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
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
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
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,6 @@ | ||
--- | ||
group: Feedback | ||
title: Skeleton | ||
--- | ||
|
||
## API |
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,5 @@ | ||
--- | ||
title: 骨架屏 | ||
--- | ||
|
||
## API |
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,31 @@ | ||
import { usePrefixConfig, useComponentConfig } from '../../hooks'; | ||
import { registerComponentMate, getClassName } from '../../utils'; | ||
|
||
export interface DSkeletonProps extends React.HTMLAttributes<HTMLDivElement> { | ||
dVariant?: 'text' | 'circular' | 'rect'; | ||
} | ||
|
||
const { COMPONENT_NAME } = registerComponentMate({ COMPONENT_NAME: 'DSkeleton' }); | ||
export function DSkeleton(props: DSkeletonProps): JSX.Element | null { | ||
const { | ||
children, | ||
dVariant = 'text', | ||
|
||
...restProps | ||
} = useComponentConfig(COMPONENT_NAME, props); | ||
|
||
//#region Context | ||
const dPrefix = usePrefixConfig(); | ||
//#endregion | ||
|
||
return ( | ||
<div {...restProps} className={getClassName(restProps.className, `${dPrefix}skeleton`, `${dPrefix}skeleton--${dVariant}`)}> | ||
{dVariant === 'text' && ( | ||
<div className={`${dPrefix}skeleton__placeholder`} aria-hidden> | ||
t | ||
</div> | ||
)} | ||
{children} | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
title: | ||
en-US: Basic | ||
zh-Hant: 基本 | ||
--- | ||
|
||
# en-US | ||
|
||
The simplest usage. | ||
|
||
# zh-Hant | ||
|
||
最简单的用法。 | ||
|
||
```tsx | ||
import { useState } from 'react'; | ||
|
||
import { DSkeleton } from '@react-devui/ui'; | ||
|
||
export default function Demo() { | ||
return ( | ||
<> | ||
<DSkeleton></DSkeleton> | ||
<br /> | ||
<DSkeleton dVariant="circular" style={{ width: 40, height: 40 }}></DSkeleton> | ||
<br /> | ||
<DSkeleton dVariant="rect" style={{ width: '100%', height: 100 }}></DSkeleton> | ||
</> | ||
); | ||
} | ||
``` |
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,70 @@ | ||
--- | ||
title: | ||
en-US: Common Use Cases | ||
zh-Hant: 常见用例 | ||
--- | ||
|
||
# en-US | ||
|
||
This example shows common usage. | ||
|
||
# zh-Hant | ||
|
||
该例展示了常见的使用。 | ||
|
||
```tsx | ||
import { useState } from 'react'; | ||
|
||
import { DSkeleton, DSwitch, DCard, DCardContent, DAvatar } from '@react-devui/ui'; | ||
import { UserOutlined } from '@react-devui/ui/icons'; | ||
|
||
export default function Demo() { | ||
const [loading, setLoading] = useState(true); | ||
|
||
return ( | ||
<> | ||
<DSwitch dModel={loading} onModelChange={setLoading}> | ||
Loading | ||
</DSwitch> | ||
<br /> | ||
<br /> | ||
<DCard style={{ width: 300 }}> | ||
<DCardContent> | ||
{loading ? ( | ||
<div style={{ display: 'flex', alignItems: 'center', gap: '0 8px' }}> | ||
<DSkeleton dVariant="circular" style={{ width: 40, height: 40 }}></DSkeleton> | ||
<DSkeleton style={{ flex: '1 0 0' }}></DSkeleton> | ||
</div> | ||
) : ( | ||
<div style={{ display: 'flex', alignItems: 'center', gap: '0 8px' }}> | ||
<DAvatar dImg={{ src: '/assets/logo.svg', alt: 'logo' }}></DAvatar> | ||
<span>DevUI</span> | ||
</div> | ||
)} | ||
</DCardContent> | ||
<div style={{ margin: '0 -1px' }}> | ||
{loading ? ( | ||
<DSkeleton dVariant="rect" style={{ width: '100%', height: 150 }}></DSkeleton> | ||
) : ( | ||
<img | ||
style={{ width: '100%', borderRadius: 'var(--d-border-radius) var(--d-border-radius) 0 0' }} | ||
src="/assets/imgs/bg-1.png" | ||
alt="bg-1" | ||
/> | ||
)} | ||
</div> | ||
<DCardContent> | ||
{loading ? ( | ||
<> | ||
<DSkeleton style={{ marginBottom: 8 }}></DSkeleton> | ||
<DSkeleton style={{ width: '60%' }}></DSkeleton> | ||
</> | ||
) : ( | ||
<span>Display a placeholder preview of your content before the data gets loaded to reduce load-time frustration.</span> | ||
)} | ||
</DCardContent> | ||
</DCard> | ||
</> | ||
); | ||
} | ||
``` |
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 @@ | ||
export * from './Skeleton'; |
Oops, something went wrong.