Skip to content

Commit

Permalink
Update:
Browse files Browse the repository at this point in the history
a. Extract pagination logic and apply to download history page;
b. Misc Ui Updates (break-words/margin);
  • Loading branch information
ccxzhang committed Aug 9, 2024
1 parent 5b38673 commit 4b31e60
Show file tree
Hide file tree
Showing 10 changed files with 348 additions and 142 deletions.
58 changes: 58 additions & 0 deletions src/renderer/src/components/Icons.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
export const MicroChevronLeft = () => (
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 16 16"
fill="currentColor"
className="size-4"
>
<path
fillRule="evenodd"
d="M9.78 4.22a.75.75 0 0 1 0 1.06L7.06 8l2.72 2.72a.75.75 0 1 1-1.06 1.06L5.47 8.53a.75.75 0 0 1 0-1.06l3.25-3.25a.75.75 0 0 1 1.06 0Z"
clipRule="evenodd"
/>
</svg>
)

export const MicroChevronRight = () => (
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 16 16"
fill="currentColor"
className="size-4"
>
<path
fillRule="evenodd"
d="M6.22 4.22a.75.75 0 0 1 1.06 0l3.25 3.25a.75.75 0 0 1 0 1.06l-3.25 3.25a.75.75 0 0 1-1.06-1.06L8.94 8 6.22 5.28a.75.75 0 0 1 0-1.06Z"
clipRule="evenodd"
/>
</svg>
)

export const MicroArrowDownTray = () => (
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" class="size-4">
<path d="M8.75 2.75a.75.75 0 0 0-1.5 0v5.69L5.03 6.22a.75.75 0 0 0-1.06 1.06l3.5 3.5a.75.75 0 0 0 1.06 0l3.5-3.5a.75.75 0 0 0-1.06-1.06L8.75 8.44V2.75Z" />
<path d="M3.5 9.75a.75.75 0 0 0-1.5 0v1.5A2.75 2.75 0 0 0 4.75 14h6.5A2.75 2.75 0 0 0 14 11.25v-1.5a.75.75 0 0 0-1.5 0v1.5c0 .69-.56 1.25-1.25 1.25h-6.5c-.69 0-1.25-.56-1.25-1.25v-1.5Z" />
</svg>
)

export const MicroTrash = () => (
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="currentColor" class="size-4">
<path
fill-rule="evenodd"
d="M5 3.25V4H2.75a.75.75 0 0 0 0 1.5h.3l.815 8.15A1.5 1.5 0 0 0 5.357 15h5.285a1.5 1.5 0 0 0 1.493-1.35l.815-8.15h.3a.75.75 0 0 0 0-1.5H11v-.75A2.25 2.25 0 0 0 8.75 1h-1.5A2.25 2.25 0 0 0 5 3.25Zm2.25-.75a.75.75 0 0 0-.75.75V4h3v-.75a.75.75 0 0 0-.75-.75h-1.5ZM6.05 6a.75.75 0 0 1 .787.713l.275 5.5a.75.75 0 0 1-1.498.075l-.275-5.5A.75.75 0 0 1 6.05 6Zm3.9 0a.75.75 0 0 1 .712.787l-.275 5.5a.75.75 0 0 1-1.498-.075l.275-5.5a.75.75 0 0 1 .786-.711Z"
clip-rule="evenodd"
/>
</svg>
)

export const MicroArrowTopRight = () => (
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 16 16"
fill="currentColor"
className="size-4"
>
<path d="M6.22 8.72a.75.75 0 0 0 1.06 1.06l5.22-5.22v1.69a.75.75 0 0 0 1.5 0v-3.5a.75.75 0 0 0-.75-.75h-3.5a.75.75 0 0 0 0 1.5h1.69L6.22 8.72Z" />
<path d="M3.5 6.75c0-.69.56-1.25 1.25-1.25H7A.75.75 0 0 0 7 4H4.75A2.75 2.75 0 0 0 2 6.75v4.5A2.75 2.75 0 0 0 4.75 14h4.5A2.75 2.75 0 0 0 12 11.25V9a.75.75 0 0 0-1.5 0v2.25c0 .69-.56 1.25-1.25 1.25h-4.5c-.69 0-1.25-.56-1.25-1.25v-4.5Z" />
</svg>
)
75 changes: 75 additions & 0 deletions src/renderer/src/components/Pagination.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import React from 'react'
import { MicroChevronLeft, MicroChevronRight } from './Icons'

const Pagination = ({
currentPage,
totalPages,
onPageChange,
onItemsPerPageChange,
onJumpToPageSubmit,
jumpToPage,
setJumpToPage,
itemsPerPage
}) => (
<div className="flex justify-between items-center mt-4 w-full max-w-4xl mx-auto text-sm">
<div className="flex items-center">
<form onSubmit={onJumpToPageSubmit} className="flex items-center">
<label htmlFor="jumpToPage" className="mr-2">
Jump to page:
</label>
<input
type="number"
id="jumpToPage"
min="1"
max={totalPages}
value={jumpToPage}
onChange={(e) => setJumpToPage(e.target.value)}
className="px-2 py-1 border border-gray-300 rounded"
/>
<button type="submit" className="ml-2 px-4 py-2 bg-blue-500 text-white rounded">
Go
</button>
</form>
</div>
<div className="flex items-center">
<div>
<label htmlFor="itemsPerPage" className="mr-2">
Rows per page:
</label>
<select
id="itemsPerPage"
value={itemsPerPage}
onChange={onItemsPerPageChange}
className="px-2 py-1 border border-gray-300 rounded"
>
<option value={10}>10</option>
<option value={20}>20</option>
<option value={50}>50</option>
</select>
</div>
<span className="mx-4">
Page {currentPage} of {totalPages}
</span>
<div className="mx-2">
<button
onClick={() => onPageChange(currentPage - 1)}
disabled={currentPage === 1}
className="px-4 py-2 bg-blue-500 text-white rounded disabled:bg-gray-300"
>
<MicroChevronLeft />
</button>
</div>
<div className="mx-2">
<button
onClick={() => onPageChange(currentPage + 1)}
disabled={currentPage === totalPages}
className="px-4 py-2 bg-blue-500 text-white rounded disabled:bg-gray-300"
>
<MicroChevronRight />
</button>
</div>
</div>
</div>
)

export default Pagination
63 changes: 44 additions & 19 deletions src/renderer/src/output.css
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,16 @@ html {
z-index: 50;
}

.mx-2 {
margin-left: 0.5rem;
margin-right: 0.5rem;
}

.mx-4 {
margin-left: 1rem;
margin-right: 1rem;
}

.mx-auto {
margin-left: auto;
margin-right: auto;
Expand Down Expand Up @@ -755,14 +765,14 @@ html {
width: 50%;
}

.w-1\/3 {
width: 33.333333%;
}

.w-4 {
width: 1rem;
}

.w-4\/5 {
width: 80%;
}

.w-48 {
width: 12rem;
}
Expand Down Expand Up @@ -855,12 +865,6 @@ html {
margin-left: calc(0.5rem * calc(1 - var(--tw-space-x-reverse)));
}

.space-x-4 > :not([hidden]) ~ :not([hidden]) {
--tw-space-x-reverse: 0;
margin-right: calc(1rem * var(--tw-space-x-reverse));
margin-left: calc(1rem * calc(1 - var(--tw-space-x-reverse)));
}

.space-y-2 > :not([hidden]) ~ :not([hidden]) {
--tw-space-y-reverse: 0;
margin-top: calc(0.5rem * calc(1 - var(--tw-space-y-reverse)));
Expand All @@ -885,10 +889,6 @@ html {
overflow-y: auto;
}

.overflow-y-scroll {
overflow-y: scroll;
}

.whitespace-normal {
white-space: normal;
}
Expand All @@ -897,6 +897,10 @@ html {
white-space: pre-wrap;
}

.break-words {
overflow-wrap: break-word;
}

.rounded {
border-radius: 0.25rem;
}
Expand All @@ -913,6 +917,11 @@ html {
border-radius: 0.375rem;
}

.rounded-t-lg {
border-top-left-radius: 0.5rem;
border-top-right-radius: 0.5rem;
}

.border {
border-width: 1px;
}
Expand All @@ -933,6 +942,11 @@ html {
border-right-width: 1px;
}

.border-gray-200 {
--tw-border-opacity: 1;
border-color: rgb(229 231 235 / var(--tw-border-opacity));
}

.border-gray-300 {
--tw-border-opacity: 1;
border-color: rgb(209 213 219 / var(--tw-border-opacity));
Expand Down Expand Up @@ -1262,6 +1276,10 @@ html {

/* Chrome, Safari and Opera */

.\[word-break\:break-word\] {
word-break: break-word;
}

@keyframes spin {
to {
transform: rotate(360deg);
Expand Down Expand Up @@ -1308,11 +1326,6 @@ html {
background-color: rgb(249 250 251 / var(--tw-bg-opacity));
}

.hover\:bg-gray-600:hover {
--tw-bg-opacity: 1;
background-color: rgb(75 85 99 / var(--tw-bg-opacity));
}

.hover\:bg-red-600:hover {
--tw-bg-opacity: 1;
background-color: rgb(220 38 38 / var(--tw-bg-opacity));
Expand Down Expand Up @@ -1365,9 +1378,21 @@ html {
}

@media (min-width: 768px) {
.md\:mt-0 {
margin-top: 0px;
}

.md\:w-1\/2 {
width: 50%;
}

.md\:w-1\/3 {
width: 33.333333%;
}

.md\:flex-row {
flex-direction: row;
}
}

@media (min-width: 1024px) {
Expand Down
Loading

0 comments on commit 4b31e60

Please sign in to comment.