Skip to content

Commit

Permalink
fix(pagination): fix pagination splash screen bug
Browse files Browse the repository at this point in the history
  • Loading branch information
yehuozhili committed Jun 5, 2020
1 parent 6b5afb3 commit 31980aa
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 24 deletions.
14 changes: 14 additions & 0 deletions src/components/Carousel/carousel.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';



function Carousel(){
return(
<div>

</div>
)
}


export default Carousel
3 changes: 3 additions & 0 deletions src/components/Pagination/pagination.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,7 @@ import Pagination from './pagination';
</Preview>



## 属性详情

<Props of={Pagination} ></Props>
51 changes: 39 additions & 12 deletions src/components/Pagination/pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,33 +60,45 @@ function Pagination(props:PropsWithChildren<PaginationProps>){
const totalPage = useMemo(()=>{
let number =Math.ceil(total/pageSize!)
if(number>barMaxSize!){
setState(new Array(barMaxSize).fill(1).map((x,y)=>y+1))
let statetmp=new Array(barMaxSize).fill(1).map((x,y)=>y+1)
setState(statetmp)
let arr=calculateMove(defaultCurrent!,statetmp,number)
if(arr){
setState(arr)
}
}else{
setState(new Array(number).fill(1).map((x,y)=>y+1))
}
return number
},[barMaxSize, pageSize, total])
useEffect(()=>{
if(state.length>0){
let arr=calculateMove(current,state,totalPage)
let statetmp=new Array(number).fill(1).map((x,y)=>y+1)
setState(statetmp)
let arr=calculateMove(defaultCurrent!,statetmp,number)
if(arr){
setState(arr)
}
}
},[current, state, totalPage])
return number
},[barMaxSize, defaultCurrent, pageSize, total])


return(
<ul className='bigbear-pagination-wrapper'>
<li className="bigbear-pagination-up"><Button
disabled={current===1?true:false}
onClick={()=>{
if(state&&state[0]>1){
setState(state.map((x)=>x-1))
let statetmp=state.map((x)=>x-1)
setState(statetmp)
setCurrent(current-1)
let arr=calculateMove(current-1,statetmp,totalPage)
if(arr){
setState(arr)
}
if(callback)callback(current-1)
}else{
if(current!==state[0]){
setCurrent(current-1)
let arr=calculateMove(current-1,state,totalPage)
if(arr){
setState(arr)
}
if(callback)callback(current-1)
}
}
Expand All @@ -97,20 +109,35 @@ function Pagination(props:PropsWithChildren<PaginationProps>){
return (
<li className={`bigbear-pagination-item ${current===x?'pagination-active':''}`} key={i}><Button
btnType={current===x?'primary':'default'}
onClick={()=>{setCurrent(x); if(callback)callback(x)}}>{x}</Button></li>
onClick={()=>{setCurrent(x);
let arr=calculateMove(x,state,totalPage)
if(arr){
setState(arr)
}

if(callback)callback(x)}}>{x}</Button></li>
)
})
}
<li className="bigbear-pagination-down"><Button
disabled={current===totalPage?true:false}
onClick={()=>{
if(state&&state[barMaxSize!-1]<totalPage){
setState(state.map((x)=>x+1))
let statetmp=state.map((x)=>x+1)
setState(statetmp)
setCurrent(current+1)
let arr=calculateMove(current+1,statetmp,totalPage)
if(arr){
setState(arr)
}
if(callback)callback(current+1)
}else{
if(current!==totalPage){
setCurrent(current+1)
let arr=calculateMove(current+1,state,totalPage)
if(arr){
setState(arr)
}
if(callback)callback(current+1)
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/components/Select/select.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,6 @@ css会将option下的div选中设置样式,如果不想用默认样式,可



## 属性详情

<Props of={Select} ></Props>
12 changes: 0 additions & 12 deletions src/styles/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,24 @@
//button
@import "../components/Button/style";


//menu
@import "../components/Menu/style";


//icon
@import "../components/Icon/style";



//alert
@import "../components/Alert/style";


//message

@import "../components/Message/style";


//input

@import "../components/Input/style";

//autocomplete
@import "../components/AutoComplete/style";


//List
@import "../components/List/style";

Expand All @@ -50,15 +41,12 @@

@import "../components/Switch/style";


//select

@import "../components/Select/style";

//multiselect
@import "../components/MultiSelect/style";


//radio
@import "../components/Radio/style";

Expand Down

0 comments on commit 31980aa

Please sign in to comment.