Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/anan/pagination #25

Open
wants to merge 15 commits into
base: dev
Choose a base branch
from
Open

Feat/anan/pagination #25

wants to merge 15 commits into from

Conversation

Chulinuwu
Copy link
Collaborator

Type of Change

  • [Pagination component ] New features

Description

pagination component+ responsive

Screenshots or GIFs (if applicable)

chrome-capture-2024-10-4

Copy link
Member

@punchanabu punchanabu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://www.youtube.com/watch?v=a1wW0AjQCI8

ฟังเพลงนี้ไประหว่างแก้ pr

import Dropdown from '../Dropdown/Dropdown.svelte';

export let Arrayitem: string[] = []; // Explicitly define the type as any[]
let currentPage: number | string = 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ขอ 2 อันนี้เป็น type number หน่อย

let currentPage: number
let itemsPerPage: number

เดี่ยว backend จะส่งมาเป็น type number เหมือนกัน
และมันจะไม่ต้องไป ParseInt หลายๆที่
หลังจากเปลี่ยน type แล้วพยายามเอา ParseInt ออกไป

Comment on lines +76 to +84
<button
class={cn(
' px-4 max-md:px-4 py-2 rounded max-md:scale-75',
currentPage === page ? 'text-white bg-sucu-pink-02 ' : 'text-black bg-white border'
)}
on:click={() => changePage(page)}
>
{page}
</button>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

เอาอีก if นึงมาครอบตรงนี้มันจะได้ไม่ type error หลังจากนั้น

{#if typeof page === 'number'}
         <button>some content</button>
{/if}

Comment on lines +15 to +18
function changePage(page: number | string) {
currentPage = page;
paginateItems();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

เวลา change page ขอแบบให้มีขอบเขตหน่อย

function changePage(page: number) {
  if (page < 1) {
    currentPage = 1;
  } else if (page > totalPages) {
    currentPage = totalPages;
  } else {
    currentPage = page;
  }
}

import { faChevronLeft, faChevronRight } from '@fortawesome/free-solid-svg-icons';
import Dropdown from '../Dropdown/Dropdown.svelte';

export let Arrayitem: string[] = []; // Explicitly define the type as any[]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ลบ comment นี้ออกไปมันคือ string[] ไม่ใช่ any[]

Comment on lines 8 to 13
let currentPage: number | string = 1;
let itemsPerPage: string = '5'; // Default items per page
let totalPages: number = Math.ceil(Arrayitem.length / parseInt(itemsPerPage));
let paginatedItems: string[] = [];

const pageChoice: string[] = ['5', '10', '15'];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

พวกนี้อาจจะต้องเปลี่ยนเป็น props แทนหมายถึงต้อง export ไว้ด้วยละกันเพื่อ custom ทีหลัง

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants