Skip to content

Commit

Permalink
feat(clerk-js,types): Add appearence keys for pagination and table head
Browse files Browse the repository at this point in the history
  • Loading branch information
octoper committed Oct 2, 2023
1 parent 68259a2 commit 9fc4ae6
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,20 @@ import type { MembershipRole } from '@clerk/types';
import React from 'react';

import type { LocalizationKey } from '../../customizables';
import { Col, Flex, Spinner, Table, Tbody, Td, Text, Th, Thead, Tr, useLocalizations } from '../../customizables';
import {
Col,
descriptors,
Flex,
Spinner,
Table,
Tbody,
Td,
Text,
Th,
Thead,
Tr,
useLocalizations,
} from '../../customizables';
import { Pagination, Select, SelectButton, SelectOptionList } from '../../elements';
import type { PropsOfComponent } from '../../styledSystem';
import { roleLocalizationKey } from '../../utils';
Expand Down Expand Up @@ -54,6 +67,7 @@ export const DataTable = (props: MembersListTableProps) => {
<Tr>
{headers.map((h, index) => (
<Th
elementDescriptor={descriptors.tableHead}
key={index}
localizationKey={h}
/>
Expand Down
5 changes: 5 additions & 0 deletions packages/clerk-js/src/ui/customizables/elementDescriptors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ export const APPEARANCE_KEYS = containsAllElementsConfigKeys([
'tabButton',
'tabListContainer',

'tableHead',

'paginationPageButton',
'paginationInfoText',

'selectButton',
'selectSearchInput',
'selectButtonIcon',
Expand Down
18 changes: 7 additions & 11 deletions packages/clerk-js/src/ui/elements/Pagination.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useState } from 'react';

import { Button, Flex, localizationKeys, Text } from '../customizables';
import { Button, descriptors, Flex, localizationKeys, Text } from '../customizables';
import type { PropsOfComponent } from '../styledSystem';
import { mqu } from '../styledSystem';
import { range } from '../utils';
Expand Down Expand Up @@ -31,6 +31,7 @@ const PageButton = (props: PropsOfComponent<typeof Button> & { isActive?: boolea
},
sx,
]}
elementDescriptor={descriptors.paginationPageButton}
{...rest}
/>
);
Expand All @@ -52,32 +53,27 @@ const RowInformation = (props: RowInfoProps) => {
} = props;

return (
<Text>
<Text elementDescriptor={descriptors.paginationInfoText}>
<Text
as='span'
sx={t => ({
color: t.colors.$blackAlpha700,
})}
colorScheme='inherit'
localizationKey={localizationKeys('paginationRowText__displaying')}
/>{' '}
<Text
as='span'
colorScheme='inherit'
sx={t => ({ fontWeight: t.fontWeights.$medium })}
>
{startingRow === endingRow && [0, 1].includes(startingRow) ? startingRow : `${startingRow}${endingRow}`}
</Text>{' '}
<Text
as='span'
sx={t => ({
color: t.colors.$blackAlpha700,
})}
colorScheme='inherit'
localizationKey={localizationKeys('paginationRowText__of')}
/>{' '}
<Text
as='span'
sx={t => ({
color: t.colors.$blackAlpha700,
})}
colorScheme='inherit'
>
{allRowsCount}
</Text>
Expand Down
5 changes: 5 additions & 0 deletions packages/types/src/appearance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,11 @@ export type ElementsConfig = {
tabButton: WithOptions<never, never, never>;
tabListContainer: WithOptions<never, never, never>;

tableHead: WithOptions<never, never, never>;

paginationPageButton: WithOptions<never, never, never>;
paginationInfoText: WithOptions<never, never, never>;

selectButton: WithOptions<SelectId, never, never>;
selectSearchInput: WithOptions<SelectId, never, never>;
selectButtonIcon: WithOptions<SelectId, never, never>;
Expand Down

0 comments on commit 9fc4ae6

Please sign in to comment.