Skip to content

Commit 8ad71bf

Browse files
committed
feat(component): add support to customize the default and active classes in button
1 parent 4e7caf1 commit 8ad71bf

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

apps/website/src/routes/docs/tailwind/(components)/pagination/index.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,24 @@ export default component$(() => {
119119
boundaryCount={boundaryCount.value}
120120
/>
121121
</div>
122+
123+
<div class="flex flex-col gap-8">
124+
<Pagination
125+
pages={pages.value}
126+
page={page.value}
127+
onPaging$={(newValue: number) => {
128+
page.value = newValue;
129+
}}
130+
showFirstButton={showFirstButton.value}
131+
showLastButton={showLastButton.value}
132+
hideNextButton={hideNextButton.value}
133+
hidePrevButton={hidePrevButton.value}
134+
siblingCount={siblingCount.value}
135+
boundaryCount={boundaryCount.value}
136+
activeClass="!bg-cyan-500"
137+
defaultClass="bg-cyan-200"
138+
/>
139+
</div>
122140
</div>
123141
);
124142
});

packages/kit-headless/src/components/pagination/pagination.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { Button as HeadlessButton } from '@qwik-ui/primitives';
1414
* variant: outlined (show border without bg)
1515
* shape: rounded | square
1616
* size: 'sm' | 'md' | 'lg'
17-
* customArrowIcons: { previous, next }
17+
* customArrowTexts: { previous, next }
1818
* paginationRange (see https://mui.com/material-ui/react-pagination/#pagination-ranges)
1919
*
2020
* EVENTS
@@ -36,6 +36,8 @@ export interface IRenderPaginationItemProps {
3636
'aria-current'?: boolean;
3737
value: TPaginationItemValue;
3838
key?: string | number;
39+
activeClass?: string;
40+
defaultClass?: string;
3941
}
4042

4143
export type TPaginationItemValue =
@@ -75,6 +77,8 @@ export interface IGetPaginationItemsOptions {
7577
hideNextButton?: boolean;
7678
showFirstButton?: boolean;
7779
showLastButton?: boolean;
80+
activeClass?: string;
81+
defaultClass?: string;
7882
}
7983

8084
export const getPaginationItems = (
@@ -179,6 +183,8 @@ export const Pagination = component$(
179183
onPaging$,
180184
page,
181185
pages,
186+
activeClass,
187+
defaultClass,
182188
...rest
183189
}: IPaginationProps) => {
184190
const pagi = getPaginationItems(page, pages, rest);
@@ -197,6 +203,8 @@ export const Pagination = component$(
197203
<RenderDivider key={i} />
198204
) : (
199205
<RenderItem
206+
activeClass={activeClass}
207+
defaultClass={defaultClass}
200208
key={i}
201209
onClick$={() =>
202210
_onPaging$(

packages/kit-tailwind/src/components/pagination/pagination.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ export const RenderPaginationItem = component$(
3030
onClick$,
3131
key,
3232
value,
33+
activeClass,
34+
defaultClass,
3335
}: IRenderPaginationItemProps) => {
3436
return (
3537
<Button
@@ -40,6 +42,7 @@ export const RenderPaginationItem = component$(
4042
key={key}
4143
active={ariaCurrent}
4244
circle
45+
class={ariaCurrent ? activeClass : defaultClass}
4346
>
4447
{value === 'prev' ? '‹' : value === 'next' ? '›' : value}
4548
</Button>

0 commit comments

Comments
 (0)