-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(progress): complete progress componenet
- Loading branch information
1 parent
4223446
commit 88097bd
Showing
10 changed files
with
181 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
.bigbear-progress-wrapper{ | ||
width: 100%; | ||
display:flex; | ||
align-items: center; | ||
padding:5px; | ||
.bigbear-progress-bar{ | ||
position: relative; | ||
width: 100%; | ||
@include ringwrapper($white,$neu-whiteshadow1,$neu-whiteshadow2); | ||
border-radius: $porgress-radius; | ||
padding: 1px; | ||
flex:1; | ||
.bigbear-progress-inner{ | ||
background-color: $primary; | ||
border-radius: $porgress-radius; | ||
transition:all .4s cubic-bezier(.08,.82,.17,1) 0s ; | ||
@include neufactory-noactive($primary,$neu-blueshadow1,$neu-blueshadow2); | ||
background-image: linear-gradient(to right, $primary, $info); | ||
&::before{ | ||
position: absolute; | ||
top:0; | ||
right: 0; | ||
bottom: 0; | ||
left: 0; | ||
background: $white; | ||
border-radius: 10px; | ||
content: ''; | ||
opacity: 0; | ||
animation: bigbear-progress-active 2.4s cubic-bezier(.23,1,.32,1) infinite; | ||
} | ||
|
||
} | ||
} | ||
.bigbear-progress-number{ | ||
min-width: 50px; | ||
display: inline-block; | ||
margin-left: 10px; | ||
text-align: center; | ||
padding: 5px; | ||
font-weight: $font-weight-bold; | ||
@include neu-textshadow($neu-whiteshadow1,$neu-whiteshadow2); | ||
} | ||
} | ||
|
||
@keyframes bigbear-progress-active{ | ||
0% { width: 0px; opacity: 0.1; } | ||
20% { width: 0px; opacity: 0.5; } | ||
100% { width: 100%; opacity: 0; } | ||
} | ||
|
||
|
||
|
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,3 @@ | ||
import Progress from "./progress"; | ||
|
||
export default Progress; |
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,18 @@ | ||
import React, { useState } from "react"; | ||
import Button from "../Button"; | ||
import Progress from "./progress"; | ||
|
||
|
||
|
||
export function ProgressExample(){ | ||
const [count,setCount]=useState(30) | ||
return ( | ||
<div> | ||
<Button onClick={()=>setCount(count+1)}>+1</Button> | ||
<Button onClick={()=>setCount(count-1)}>-1</Button> | ||
<Button onClick={()=>setCount(count+10)}>+10</Button> | ||
<Button onClick={()=>setCount(count-10)}>-10</Button> | ||
<Progress count={count}></Progress> | ||
</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,58 @@ | ||
import { Meta, Story, Props ,Preview } from '@storybook/addon-docs/blocks'; | ||
import Progress from './progress'; | ||
import {ProgressExample}from './progress.example'; | ||
|
||
|
||
|
||
<Meta title='REACTION |Progress 进度条' component={Progress} /> | ||
|
||
<br/> | ||
|
||
# Progress 进度条 | ||
<br/> | ||
|
||
## 基本使用 | ||
|
||
|
||
<Preview> | ||
<Story name='progress'> | ||
<Progress count={22}></Progress> | ||
</Story> | ||
</Preview> | ||
|
||
## 可操作 | ||
|
||
```tsx | ||
export function ProgressExample(){ | ||
const [count,setCount]=useState(30) | ||
return ( | ||
<div> | ||
<Button onClick={()=>setCount(count+1)}>+1</Button> | ||
<Button onClick={()=>setCount(count-1)}>-1</Button> | ||
<Button onClick={()=>setCount(count+10)}>+10</Button> | ||
<Button onClick={()=>setCount(count-10)}>-10</Button> | ||
<Progress count={count}></Progress> | ||
</div> | ||
) | ||
} | ||
``` | ||
|
||
<Preview> | ||
<Story name='progress dynamic'> | ||
<ProgressExample count={22}></ProgressExample> | ||
</Story> | ||
</Preview> | ||
|
||
## 不要文字 | ||
|
||
|
||
<Preview> | ||
<Story name='progress notext'> | ||
<Progress count={99} countNumber={false}></Progress> | ||
</Story> | ||
</Preview> | ||
|
||
|
||
## 属性详情 | ||
|
||
<Props of={Progress} /> |
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,14 +1,44 @@ | ||
import React from 'react'; | ||
import React, { useState, useMemo } from 'react'; | ||
|
||
|
||
interface ProgressType{ | ||
/** 传入数字*/ | ||
count:number, | ||
/** 是否要末尾计数文本*/ | ||
countNumber?:boolean; | ||
/** 进度条高度*/ | ||
height?:number; | ||
} | ||
|
||
function Progress(props:ProgressType){ | ||
const {count,countNumber,height}=props; | ||
const [state,setState]=useState(0) | ||
useMemo(()=>{ | ||
if(count<0){ | ||
setState(0) | ||
}else if(count>100){ | ||
setState(100) | ||
}else{ | ||
setState(count) | ||
} | ||
},[count]) | ||
|
||
function Progress(){ | ||
return( | ||
<div></div> | ||
<div className='bigbear-progress-wrapper'> | ||
|
||
<div className='bigbear-progress-bar'> | ||
<div className='bigbear-progress-inner' style={{width:`${state}%`,height:`${height?height:8}px`}}> | ||
</div> | ||
</div> | ||
{countNumber&&<div className="bigbear-progress-number" style={{lineHeight:`${height?height:8}px`}}>{state}%</div>} | ||
</div> | ||
) | ||
} | ||
|
||
Progress.defaultProps={ | ||
countNumber:true | ||
} | ||
|
||
|
||
|
||
export default Progress; |
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