add mini-pagination

dev_aliyun2
harry 5 years ago
parent 35659a66d4
commit 27758790ae

@ -0,0 +1,9 @@
import React from 'react'
import MiniPagination from './components/mini-pagination'
export default () => {
function onPageChange(page) {
console.log(page, '-----------')
}
return <MiniPagination onChange={onPageChange} current={1} total={100} pageSize={16} />
}

@ -0,0 +1,32 @@
import React, { useState } from 'react'
import './index.less'
function noop() { }
export default ({ current, defaultCurrent, total, pageSize, onChange = noop }) => {
const maxPage = Math.ceil(total / pageSize)
const [page, setPage] = useState(current || defaultCurrent)
function next() {
if (page < maxPage) {
let value = page + 1
setPage(value)
onChange(value)
}
}
function prev() {
if (page > 1) {
let value = page - 1
setPage(value)
onChange(value)
}
}
return (
<div className="mini-pagination">
<a class={page === 1 ? 'disabled' : 'normal'} onClick={prev}>上一页</a>
<a class={page === maxPage ? 'disabled' : 'normal'} onClick={next} >下一页</a>
</div>
)
}

@ -0,0 +1,60 @@
.mini-pagination {
display: flex;
flex-flow: row nowrap;
justify-content: center;
align-items: center;
a {
display: block;
padding: 0 10px 0 22px;
border-width: 1px;
border-radius: 3px;
margin-right: 4px;
font-size: 12px;
line-height: 30px;
cursor: pointer;
border-style: solid;
outline: none;
border-color: #c4c6cf;
background: #fff;
color: #333;
position: relative;
&:hover {
background-color: #f2f3f7;
border-color: #a0a2ad;
text-decoration: none;
}
&:before {
position: absolute;
content: ' ';
width: 8px;
top: 10px;
left: 10px;
height: 8px;
transform: rotate(-45deg);
border-top: 1px solid #333;
border-left: 1px solid #333;
}
&:last-child {
padding: 0 22px 0 10px;
margin: 0 0 0 4px;
&:before {
left: auto;
right: 10px;
transform: rotate(135deg);
}
}
&.disabled {
cursor: not-allowed;
background-color: #f7f8fa;
border-color: #e6e7eb;
color: #e0e0e0;
}
}
}

@ -1,7 +1,7 @@
import React, { useEffect, useRef, useState } from 'react'
import * as monaco from 'monaco-editor'
import './TPIMonacoConfig'
import './monaco-editor.css'
import './index.css'
function processSize(size) {
return !/^\d+$/.test(size) ? size : `${size}px`

@ -1,7 +1,7 @@
import React from 'react'
import ReactDOM from 'react-dom'
import './index.css'
import App from './App'
import App from './app-test'
import * as serviceWorker from './serviceWorker'
window.__useKindEditor = false;

Loading…
Cancel
Save