feat: add Pagination and PaginationNumber components with styles and integration into index page
This commit is contained in:
@@ -1,5 +1,3 @@
|
|||||||
// Auto-generated by scripts/generate-barrel.mjs — do not edit manually.
|
|
||||||
|
|
||||||
export * from './Icons/index.ts';
|
export * from './Icons/index.ts';
|
||||||
export { default as Notification } from './Notifications/notification.astro';
|
export { default as Notification } from './Notifications/notification.astro';
|
||||||
export { default as Toggle } from './Toggle/toggle.astro';
|
export { default as Toggle } from './Toggle/toggle.astro';
|
||||||
@@ -17,3 +15,5 @@ export { default as Avatar } from './Avatar/avatar.astro';
|
|||||||
export { default as Select } from './Select/select.astro';
|
export { default as Select } from './Select/select.astro';
|
||||||
export { default as SelectOption } from './Select/selectOption.astro';
|
export { default as SelectOption } from './Select/selectOption.astro';
|
||||||
export { default as TextField } from './textField/textField.astro';
|
export { default as TextField } from './textField/textField.astro';
|
||||||
|
export { default as Pagination } from './pagination/pagination.astro';
|
||||||
|
export { default as PaginationNumber } from './pagination/paginationNumber.astro';
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
@use '../../styles/tokens/typography' as *;
|
||||||
|
|
||||||
|
.pagination {
|
||||||
|
display: flex;
|
||||||
|
gap: var(--nds-spacing-sm);
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
@use '../../styles/tokens/typography' as *;
|
||||||
|
|
||||||
|
.pagination-number {
|
||||||
|
width: 30px;
|
||||||
|
height: 30px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
border-radius: var(--nds-radius-full);
|
||||||
|
&:hover:not(.pagination-number__disabled):not(.pagination-number__selected) {
|
||||||
|
background-color: var(--nds-secondary);
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
&:active:not(.pagination-number__disabled):not(.pagination-number__selected) {
|
||||||
|
background-color: var(--nds-accent);
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
&__disabled {
|
||||||
|
background-color: var(--nds-disabled);
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
&__selected {
|
||||||
|
background-color: var(--nds-primary);
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
---
|
||||||
|
export interface Props {
|
||||||
|
defaultPage?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { defaultPage = 1 } = Astro.props;
|
||||||
|
---
|
||||||
|
|
||||||
|
<div class="pagination" data-current={defaultPage}>
|
||||||
|
<slot/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const pagination = document.querySelector('.pagination');
|
||||||
|
const numbers = pagination?.querySelectorAll('.pagination-number');
|
||||||
|
|
||||||
|
numbers?.forEach((el) => {
|
||||||
|
if (
|
||||||
|
!el.classList.contains('pagination-number__disabled') &&
|
||||||
|
el.textContent?.trim() === pagination?.getAttribute('data-current')
|
||||||
|
) {
|
||||||
|
el.classList.add('pagination-number__selected');
|
||||||
|
}
|
||||||
|
|
||||||
|
el.addEventListener('click', () => {
|
||||||
|
if (el.classList.contains('pagination-number__disabled')) return;
|
||||||
|
numbers.forEach(n => n.classList.remove('pagination-number__selected'));
|
||||||
|
el.classList.add('pagination-number__selected');
|
||||||
|
pagination?.setAttribute('data-current', el.textContent?.trim() ?? '');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
@use './pagination';
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
export interface Props {
|
||||||
|
disabled?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { disabled } = Astro.props;
|
||||||
|
|
||||||
|
const classes = [
|
||||||
|
'pagination-number',
|
||||||
|
disabled ? 'pagination-number__disabled' : ''
|
||||||
|
].filter(Boolean).join(' ');
|
||||||
|
---
|
||||||
|
|
||||||
|
<div class={classes}>
|
||||||
|
<slot/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
@use './paginationNumber';
|
||||||
|
</style>
|
||||||
@@ -16,6 +16,8 @@ import Avatar from '../components/Avatar/avatar.astro';
|
|||||||
import Select from '../components/Select/select.astro';
|
import Select from '../components/Select/select.astro';
|
||||||
import SelectOption from '../components/Select/selectOption.astro';
|
import SelectOption from '../components/Select/selectOption.astro';
|
||||||
import TextField from '../components/textField/textField.astro';
|
import TextField from '../components/textField/textField.astro';
|
||||||
|
import Pagination from '../components/pagination/pagination.astro';
|
||||||
|
import PaginationNumber from '../components/pagination/paginationNumber.astro';
|
||||||
import {
|
import {
|
||||||
Arrow2Icon, BinIcon, BurgerIcon, CalendarIcon, CheckIcon, CloseIcon,
|
Arrow2Icon, BinIcon, BurgerIcon, CalendarIcon, CheckIcon, CloseIcon,
|
||||||
CodeIcon, CubeIcon, DownloadIcon, FilterIcon, HelpIcon, HomeIcon,
|
CodeIcon, CubeIcon, DownloadIcon, FilterIcon, HelpIcon, HomeIcon,
|
||||||
@@ -30,6 +32,18 @@ const initialChecked = true;
|
|||||||
<Layout>
|
<Layout>
|
||||||
<main>
|
<main>
|
||||||
<h1>Nova Design System</h1>
|
<h1>Nova Design System</h1>
|
||||||
|
<section>
|
||||||
|
<h2>Pagination</h2>
|
||||||
|
<div style="display: flex; flex-direction: column; gap: var(--nds-spacing-md);">
|
||||||
|
<Pagination defaultPage={3}>
|
||||||
|
<PaginationNumber>1</PaginationNumber>
|
||||||
|
<PaginationNumber>2</PaginationNumber>
|
||||||
|
<PaginationNumber>3</PaginationNumber>
|
||||||
|
<PaginationNumber>4</PaginationNumber>
|
||||||
|
<PaginationNumber disabled>5</PaginationNumber>
|
||||||
|
</Pagination>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
<section>
|
<section>
|
||||||
<h2>TextField</h2>
|
<h2>TextField</h2>
|
||||||
<div style="display: flex; flex-direction: column; gap: var(--nds-spacing-md);">
|
<div style="display: flex; flex-direction: column; gap: var(--nds-spacing-md);">
|
||||||
|
|||||||
Reference in New Issue
Block a user