Commit fcdf8d98 authored by tom goriunov's avatar tom goriunov Committed by GitHub

New styles for pagination and "Add / Remove" buttons (#2791)

* update styles for add / remove buttons

* update pagination styles

* change border color for filled inputs

* change row gap for alerts

* update icons and screenshots

* fix tests

* update buttons for contract method form

* update screenshot
parent 7f10c98e
<svg viewBox="0 0 16 2" fill="none" xmlns="http://www.w3.org/2000/svg"> <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20">
<path d="M.5 1a.937.937 0 0 1 .938-.938h13.124a.938.938 0 0 1 0 1.875H1.438A.937.937 0 0 1 .5 1Z" fill="currentColor"/> <g clip-path="url(#a)">
<path fill="currentColor" d="M8.857 9H17a1 1 0 0 1 1 1v.286a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V10a1 1 0 0 1 1-1h5.857Z"/>
</g>
<defs>
<clipPath id="a">
<path fill="currentColor" d="M0 0h20v20H0z"/>
</clipPath>
</defs>
</svg> </svg>
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"> <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20">
<path d="M8 .5a.937.937 0 0 1 .938.938v5.625h5.624a.937.937 0 0 1 0 1.875H8.939v5.624a.937.937 0 0 1-1.876 0V8.939H1.438a.937.937 0 1 1 0-1.876h5.625V1.438A.937.937 0 0 1 8 .5Z" fill="currentColor"/> <g clip-path="url(#a)">
<path fill="currentColor" d="M7.857 9.052a1 1 0 0 0 1-1V3.195a1 1 0 0 1 1-1h.286a1 1 0 0 1 1 1v4.857a1 1 0 0 0 1 1H17a1 1 0 0 1 1 1v.286a1 1 0 0 1-1 1h-4.857a1 1 0 0 0-1 1v4.857a1 1 0 0 1-1 1h-.286a1 1 0 0 1-1-1v-4.857a1 1 0 0 0-1-1H3a1 1 0 0 1-1-1v-.286a1 1 0 0 1 1-1h4.857Z"/>
</g>
<defs>
<clipPath id="a">
<path fill="currentColor" d="M0 0h20v20H0z"/>
</clipPath>
</defs>
</svg> </svg>
...@@ -3,7 +3,7 @@ import React from 'react'; ...@@ -3,7 +3,7 @@ import React from 'react';
import { Button, type ButtonProps } from './button'; import { Button, type ButtonProps } from './button';
export interface IconButtonProps extends Omit<ButtonProps, 'size'> { export interface IconButtonProps extends Omit<ButtonProps, 'size'> {
size?: '2xs' | 'md'; size?: '2xs' | '2xs_alt' | 'md';
} }
export const IconButton = React.forwardRef<HTMLButtonElement, IconButtonProps>( export const IconButton = React.forwardRef<HTMLButtonElement, IconButtonProps>(
...@@ -13,7 +13,7 @@ export const IconButton = React.forwardRef<HTMLButtonElement, IconButtonProps>( ...@@ -13,7 +13,7 @@ export const IconButton = React.forwardRef<HTMLButtonElement, IconButtonProps>(
// FIXME: I have to clone the children instead of using _icon props because of style overrides // FIXME: I have to clone the children instead of using _icon props because of style overrides
// in some pw tests for some reason the _icon style will be applied before the style of child (IconSvg component) // in some pw tests for some reason the _icon style will be applied before the style of child (IconSvg component)
const child = React.Children.only<React.ReactElement>(children as React.ReactElement); const child = React.Children.only<React.ReactElement>(children as React.ReactElement);
const clonedChildren = size ? React.cloneElement(child, { boxSize: 5 } as React.HTMLAttributes<HTMLElement>) : child; const clonedChildren = size ? React.cloneElement(child, { boxSize: size === '2xs_alt' ? 3 : 5 } as React.HTMLAttributes<HTMLElement>) : child;
const sizeStyle = (() => { const sizeStyle = (() => {
switch (size) { switch (size) {
...@@ -24,6 +24,13 @@ export const IconButton = React.forwardRef<HTMLButtonElement, IconButtonProps>( ...@@ -24,6 +24,13 @@ export const IconButton = React.forwardRef<HTMLButtonElement, IconButtonProps>(
borderRadius: 'sm', borderRadius: 'sm',
}; };
} }
case '2xs_alt': {
return {
_icon: { boxSize: 3 },
boxSize: 5,
borderRadius: 'sm',
};
}
case 'md': { case 'md': {
return { return {
_icon: { boxSize: 5 }, _icon: { boxSize: 5 },
......
import React from 'react';
import type { IconButtonProps } from 'toolkit/chakra/icon-button';
import { IconButton } from 'toolkit/chakra/icon-button';
import IconSvg from 'ui/shared/IconSvg';
interface Props extends IconButtonProps {}
const AddButton = (props: Props) => {
return (
<IconButton
aria-label="Add item"
variant="icon_secondary"
size="md"
{ ...props }
>
<IconSvg name="plus"/>
</IconButton>
);
};
export default React.memo(AddButton);
import React from 'react';
import type { IconButtonProps } from 'toolkit/chakra/icon-button';
import { IconButton } from 'toolkit/chakra/icon-button';
import IconSvg from 'ui/shared/IconSvg';
interface Props extends IconButtonProps {}
const RemoveButton = (props: Props) => {
return (
<IconButton
aria-label="Remove item"
variant="icon_secondary"
size="md"
{ ...props }
>
<IconSvg name="minus"/>
</IconButton>
);
};
export default React.memo(RemoveButton);
...@@ -64,6 +64,18 @@ const semanticTokens: ThemingConfig['semanticTokens'] = { ...@@ -64,6 +64,18 @@ const semanticTokens: ThemingConfig['semanticTokens'] = {
selected: { value: { _light: '{colors.blue.50}', _dark: '{colors.whiteAlpha.100}' } }, selected: { value: { _light: '{colors.blue.50}', _dark: '{colors.whiteAlpha.100}' } },
}, },
}, },
pagination: {
fg: {
DEFAULT: { value: { _light: '{colors.blackAlpha.800}', _dark: '{colors.gray.50}' } },
selected: { value: { _light: '{colors.blue.700}', _dark: '{colors.gray.50}' } },
},
bg: {
selected: { value: { _light: '{colors.blue.50}', _dark: '{colors.whiteAlpha.100}' } },
},
border: {
DEFAULT: { value: { _light: '{colors.gray.100}', _dark: '{colors.whiteAlpha.100}' } },
},
},
hero: { hero: {
bg: { bg: {
DEFAULT: { DEFAULT: {
...@@ -251,7 +263,7 @@ const semanticTokens: ThemingConfig['semanticTokens'] = { ...@@ -251,7 +263,7 @@ const semanticTokens: ThemingConfig['semanticTokens'] = {
DEFAULT: { value: { _light: '{colors.gray.100}', _dark: '{colors.gray.700}' } }, DEFAULT: { value: { _light: '{colors.gray.100}', _dark: '{colors.gray.700}' } },
hover: { value: { _light: '{colors.gray.200}', _dark: '{colors.gray.500}' } }, hover: { value: { _light: '{colors.gray.200}', _dark: '{colors.gray.500}' } },
focus: { value: '{colors.blue.400}' }, focus: { value: '{colors.blue.400}' },
filled: { value: { _light: '{colors.gray.300}', _dark: '{colors.gray.600}' } }, filled: { value: { _light: '{colors.gray.100}', _dark: '{colors.gray.700}' } },
readOnly: { value: { _light: '{colors.gray.200}', _dark: '{colors.gray.800}' } }, readOnly: { value: { _light: '{colors.gray.200}', _dark: '{colors.gray.800}' } },
error: { value: '{colors.red.500}' }, error: { value: '{colors.red.500}' },
}, },
......
...@@ -253,6 +253,28 @@ export const recipe = defineRecipe({ ...@@ -253,6 +253,28 @@ export const recipe = defineRecipe({
color: 'link.primary.hover', color: 'link.primary.hover',
}, },
}, },
pagination: {
borderWidth: '2px',
borderStyle: 'solid',
bg: 'transparent',
color: 'button.pagination.fg',
borderColor: 'button.pagination.border',
_hover: {
bg: 'transparent',
color: 'link.primary.hover',
borderColor: 'link.primary.hover',
},
_selected: {
bg: 'button.pagination.bg.selected',
color: 'button.pagination.fg.selected',
borderColor: 'transparent',
_hover: {
bg: 'button.pagination.bg.selected',
color: 'button.pagination.fg.selected',
borderColor: 'transparent',
},
},
},
}, },
size: { size: {
'2xs': { '2xs': {
......
...@@ -21,7 +21,7 @@ test.describe.configure({ mode: 'serial' }); ...@@ -21,7 +21,7 @@ test.describe.configure({ mode: 'serial' });
let addressApiUrl: string; let addressApiUrl: string;
test.beforeEach(async({ mockApiResponse, page }) => { test.beforeEach(async({ mockApiResponse, page }) => {
await page.route('https://cdn.jsdelivr.net/npm/monaco-editor@0.33.0/**', (route) => { await page.route('https://cdn.jsdelivr.net/npm/monaco-editor@0.52.2/**', (route) => {
route.abort(); route.abort();
}); });
addressApiUrl = await mockApiResponse('general:address', addressMock.contract, { pathParams: { hash: addressMock.contract.hash } }); addressApiUrl = await mockApiResponse('general:address', addressMock.contract, { pathParams: { hash: addressMock.contract.hash } });
......
...@@ -38,7 +38,7 @@ const ContractDetailsAlerts = ({ data, isLoading, addressData, channel }: Props) ...@@ -38,7 +38,7 @@ const ContractDetailsAlerts = ({ data, isLoading, addressData, channel }: Props)
}); });
return ( return (
<Flex flexDir="column" rowGap={ 2 } mb={ 6 } _empty={{ display: 'none' }}> <Flex flexDir="column" rowGap={ 1 } mb={ 6 } _empty={{ display: 'none' }}>
{ data?.is_blueprint && ( { data?.is_blueprint && (
<Box> <Box>
<span>This is an </span> <span>This is an </span>
......
import { chakra } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
import { IconButton } from 'toolkit/chakra/icon-button'; import type { IconButtonProps } from 'toolkit/chakra/icon-button';
import IconSvg from 'ui/shared/IconSvg'; import AddButton from 'toolkit/components/buttons/AddButton';
import RemoveButton from 'toolkit/components/buttons/RemoveButton';
interface Props { interface Props extends Omit<IconButtonProps, 'type'> {
index: number; index: number;
onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;
isDisabled?: boolean;
type: 'add' | 'remove'; type: 'add' | 'remove';
className?: string;
} }
const ContractMethodArrayButton = ({ className, type, index, onClick, isDisabled }: Props) => { const ContractMethodArrayButton = ({ type, index, onClick, ...props }: Props) => {
const handleClick = React.useCallback((event: React.MouseEvent<HTMLButtonElement>) => { const handleClick = React.useCallback((event: React.MouseEvent<HTMLButtonElement>) => {
event.stopPropagation(); event.stopPropagation();
onClick(event); onClick?.(event);
}, [ onClick ]); }, [ onClick ]);
const Button = type === 'add' ? AddButton : RemoveButton;
return ( return (
<IconButton <Button
as="div"
className={ className }
aria-label={ type }
data-index={ index } data-index={ index }
variant="outline" size="2xs_alt"
boxSize={ 5 }
onClick={ handleClick } onClick={ handleClick }
disabled={ isDisabled } { ...props }
> />
<IconSvg name={ type === 'remove' ? 'minus' : 'plus' } boxSize={ 3 }/>
</IconButton>
); );
}; };
export default React.memo(chakra(ContractMethodArrayButton)); export default React.memo(ContractMethodArrayButton);
...@@ -34,7 +34,7 @@ const ContractMethodFieldAccordion = ({ label, level, children, onAddClick, onRe ...@@ -34,7 +34,7 @@ const ContractMethodFieldAccordion = ({ label, level, children, onAddClick, onRe
{ label } { label }
</Box> </Box>
{ onRemoveClick && index !== undefined && <ContractMethodArrayButton index={ index } onClick={ onRemoveClick } type="remove"/> } { onRemoveClick && index !== undefined && <ContractMethodArrayButton index={ index } onClick={ onRemoveClick } type="remove"/> }
{ onAddClick && index !== undefined && <ContractMethodArrayButton index={ index } onClick={ onAddClick } type="add" ml={ 2 }/> } { onAddClick && index !== undefined && <ContractMethodArrayButton index={ index } onClick={ onAddClick } type="add" ml={ 1 }/> }
</AccordionItemTrigger> </AccordionItemTrigger>
<AccordionItemContent display="flex" flexDir="column" rowGap={ 1 } pl="18px" pr="6px"> <AccordionItemContent display="flex" flexDir="column" rowGap={ 1 } pl="18px" pr="6px">
{ children } { children }
......
...@@ -140,7 +140,7 @@ const ContractMethodFieldInputArray = ({ ...@@ -140,7 +140,7 @@ const ContractMethodFieldInputArray = ({
const itemData = transformDataForArrayItem(data, index); const itemData = transformDataForArrayItem(data, index);
return ( return (
<Flex key={ registeredIndex } alignItems="flex-start" columnGap={ 3 }> <Flex key={ registeredIndex } alignItems="flex-start" columnGap={ 2 }>
<ContractMethodFieldInput <ContractMethodFieldInput
data={ itemData } data={ itemData }
hideLabel hideLabel
......
...@@ -5,13 +5,12 @@ import React from 'react'; ...@@ -5,13 +5,12 @@ import React from 'react';
import type { AdvancedFilterParams } from 'types/api/advancedFilter'; import type { AdvancedFilterParams } from 'types/api/advancedFilter';
import { IconButton } from 'toolkit/chakra/icon-button';
import { Input } from 'toolkit/chakra/input'; import { Input } from 'toolkit/chakra/input';
import { InputGroup } from 'toolkit/chakra/input-group'; import { InputGroup } from 'toolkit/chakra/input-group';
import { Select } from 'toolkit/chakra/select'; import { Select } from 'toolkit/chakra/select';
import AddButton from 'toolkit/components/buttons/AddButton';
import { ClearButton } from 'toolkit/components/buttons/ClearButton'; import { ClearButton } from 'toolkit/components/buttons/ClearButton';
import TableColumnFilter from 'ui/shared/filters/TableColumnFilter'; import TableColumnFilter from 'ui/shared/filters/TableColumnFilter';
import IconSvg from 'ui/shared/IconSvg';
const FILTER_PARAM_TO_INCLUDE = 'to_address_hashes_to_include'; const FILTER_PARAM_TO_INCLUDE = 'to_address_hashes_to_include';
const FILTER_PARAM_FROM_INCLUDE = 'from_address_hashes_to_include'; const FILTER_PARAM_FROM_INCLUDE = 'from_address_hashes_to_include';
...@@ -76,15 +75,10 @@ const AddressFilterInput = ({ address, mode, onModeChange, onChange, onClear, is ...@@ -76,15 +75,10 @@ const AddressFilterInput = ({ address, mode, onModeChange, onChange, onClear, is
<Input value={ address } onChange={ onChange } placeholder="Smart contract / Address (0x...)*" size="sm" autoComplete="off"/> <Input value={ address } onChange={ onChange } placeholder="Smart contract / Address (0x...)*" size="sm" autoComplete="off"/>
</InputGroup> </InputGroup>
{ isLast && ( { isLast && (
<IconButton <AddButton
aria-label="add"
variant="outline"
size="md"
ml={ 2 } ml={ 2 }
onClick={ onAddFieldClick } onClick={ onAddFieldClick }
> />
<IconSvg name="plus"/>
</IconButton>
) } ) }
</Flex> </Flex>
); );
......
...@@ -87,7 +87,7 @@ test('flatten source code method +@dark-mode +@mobile', async({ render, page }) ...@@ -87,7 +87,7 @@ test('flatten source code method +@dark-mode +@mobile', async({ render, page })
await page.getByRole('option', { name: 'Solidity (Single file)' }).click(); await page.getByRole('option', { name: 'Solidity (Single file)' }).click();
await page.getByText(/add contract libraries/i).click(); await page.getByText(/add contract libraries/i).click();
await page.locator('button[aria-label="add"]').click(); await page.locator('button[aria-label="Add item"]').click();
await expect(component).toHaveScreenshot({ timeout: 10_000 }); await expect(component).toHaveScreenshot({ timeout: 10_000 });
}); });
......
...@@ -3,10 +3,10 @@ import React from 'react'; ...@@ -3,10 +3,10 @@ import React from 'react';
import type { FormFields } from '../types'; import type { FormFields } from '../types';
import { IconButton } from 'toolkit/chakra/icon-button'; import AddButton from 'toolkit/components/buttons/AddButton';
import RemoveButton from 'toolkit/components/buttons/RemoveButton';
import { FormFieldAddress } from 'toolkit/components/forms/fields/FormFieldAddress'; import { FormFieldAddress } from 'toolkit/components/forms/fields/FormFieldAddress';
import { FormFieldText } from 'toolkit/components/forms/fields/FormFieldText'; import { FormFieldText } from 'toolkit/components/forms/fields/FormFieldText';
import IconSvg from 'ui/shared/IconSvg';
import ContractVerificationFormRow from '../ContractVerificationFormRow'; import ContractVerificationFormRow from '../ContractVerificationFormRow';
...@@ -42,26 +42,16 @@ const ContractVerificationFieldLibraryItem = ({ index, fieldsLength, onAddFieldC ...@@ -42,26 +42,16 @@ const ContractVerificationFieldLibraryItem = ({ index, fieldsLength, onAddFieldC
<Text color="text.secondary" fontSize="sm">Contract library { index + 1 }</Text> <Text color="text.secondary" fontSize="sm">Contract library { index + 1 }</Text>
<Flex columnGap={ 5 }> <Flex columnGap={ 5 }>
{ fieldsLength > 1 && ( { fieldsLength > 1 && (
<IconButton <RemoveButton
aria-label="delete"
variant="outline"
size="md"
onClick={ handleRemoveButtonClick } onClick={ handleRemoveButtonClick }
disabled={ isDisabled } disabled={ isDisabled }
> />
<IconSvg name="minus"/>
</IconButton>
) } ) }
{ fieldsLength < LIMIT && ( { fieldsLength < LIMIT && (
<IconButton <AddButton
aria-label="add"
variant="outline"
size="md"
onClick={ handleAddButtonClick } onClick={ handleAddButtonClick }
disabled={ isDisabled } disabled={ isDisabled }
> />
<IconSvg name="plus"/>
</IconButton>
) } ) }
</Flex> </Flex>
</Flex> </Flex>
......
...@@ -4,9 +4,9 @@ import { useFieldArray, useFormContext } from 'react-hook-form'; ...@@ -4,9 +4,9 @@ import { useFieldArray, useFormContext } from 'react-hook-form';
import type { FormFields } from '../types'; import type { FormFields } from '../types';
import { IconButton } from 'toolkit/chakra/icon-button'; import AddButton from 'toolkit/components/buttons/AddButton';
import RemoveButton from 'toolkit/components/buttons/RemoveButton';
import { FormFieldAddress } from 'toolkit/components/forms/fields/FormFieldAddress'; import { FormFieldAddress } from 'toolkit/components/forms/fields/FormFieldAddress';
import IconSvg from 'ui/shared/IconSvg';
const LIMIT = 20; const LIMIT = 20;
...@@ -45,30 +45,20 @@ const PublicTagsSubmitFieldAddresses = () => { ...@@ -45,30 +45,20 @@ const PublicTagsSubmitFieldAddresses = () => {
placeholder="Smart contract / Address (0x...)" placeholder="Smart contract / Address (0x...)"
/> />
</GridItem> </GridItem>
<GridItem display="flex" alignItems="center" columnGap={ 5 } justifyContent={{ base: 'flex-end', lg: 'flex-start' }}> <GridItem display="flex" alignItems="center" columnGap={ 3 } justifyContent={{ base: 'flex-end', lg: 'flex-start' }}>
{ fields.length < LIMIT && index === fields.length - 1 && ( { fields.length < LIMIT && index === fields.length - 1 && (
<IconButton <AddButton
aria-label="add"
data-index={ index } data-index={ index }
variant="outline"
size="md"
onClick={ handleAddFieldClick } onClick={ handleAddFieldClick }
disabled={ isDisabled } disabled={ isDisabled }
> />
<IconSvg name="plus"/>
</IconButton>
) } ) }
{ fields.length > 1 && ( { fields.length > 1 && (
<IconButton <RemoveButton
aria-label="delete"
data-index={ index } data-index={ index }
variant="outline"
size="md"
onClick={ handleRemoveFieldClick } onClick={ handleRemoveFieldClick }
disabled={ isDisabled } disabled={ isDisabled }
> />
<IconSvg name="minus"/>
</IconButton>
) } ) }
</GridItem> </GridItem>
</React.Fragment> </React.Fragment>
......
...@@ -6,13 +6,13 @@ import type { FormFields, FormFieldTag } from '../types'; ...@@ -6,13 +6,13 @@ import type { FormFields, FormFieldTag } from '../types';
import type { PublicTagType } from 'types/api/addressMetadata'; import type { PublicTagType } from 'types/api/addressMetadata';
import useIsMobile from 'lib/hooks/useIsMobile'; import useIsMobile from 'lib/hooks/useIsMobile';
import { IconButton } from 'toolkit/chakra/icon-button'; import AddButton from 'toolkit/components/buttons/AddButton';
import RemoveButton from 'toolkit/components/buttons/RemoveButton';
import { FormFieldColor } from 'toolkit/components/forms/fields/FormFieldColor'; import { FormFieldColor } from 'toolkit/components/forms/fields/FormFieldColor';
import { FormFieldText } from 'toolkit/components/forms/fields/FormFieldText'; import { FormFieldText } from 'toolkit/components/forms/fields/FormFieldText';
import { FormFieldUrl } from 'toolkit/components/forms/fields/FormFieldUrl'; import { FormFieldUrl } from 'toolkit/components/forms/fields/FormFieldUrl';
import { colorValidator } from 'toolkit/components/forms/validators/color'; import { colorValidator } from 'toolkit/components/forms/validators/color';
import EntityTag from 'ui/shared/EntityTags/EntityTag'; import EntityTag from 'ui/shared/EntityTags/EntityTag';
import IconSvg from 'ui/shared/IconSvg';
import PublicTagsSubmitFieldTagType from './PublicTagsSubmitFieldTagType'; import PublicTagsSubmitFieldTagType from './PublicTagsSubmitFieldTagType';
...@@ -93,33 +93,23 @@ const PublicTagsSubmitFieldTag = ({ index, isDisabled, errors, onAddClick, onRem ...@@ -93,33 +93,23 @@ const PublicTagsSubmitFieldTag = ({ index, isDisabled, errors, onAddClick, onRem
<GridItem py={{ lg: '10px' }}> <GridItem py={{ lg: '10px' }}>
<Flex <Flex
alignItems="center" alignItems="center"
columnGap={ 5 } columnGap={ 3 }
justifyContent={{ base: 'flex-end', lg: 'flex-start' }} justifyContent={{ base: 'flex-end', lg: 'flex-start' }}
h={{ base: 'auto', lg: '60px' }} h={{ base: 'auto', lg: '60px' }}
> >
{ onAddClick && ( { onAddClick && (
<IconButton <AddButton
aria-label="add"
data-index={ index } data-index={ index }
variant="outline"
size="md"
onClick={ handleAddClick } onClick={ handleAddClick }
disabled={ isDisabled } disabled={ isDisabled }
> />
<IconSvg name="plus"/>
</IconButton>
) } ) }
{ onRemoveClick && ( { onRemoveClick && (
<IconButton <RemoveButton
aria-label="delete"
data-index={ index } data-index={ index }
variant="outline"
size="md"
onClick={ handleRemoveClick } onClick={ handleRemoveClick }
disabled={ isDisabled } disabled={ isDisabled }
> />
<IconSvg name="minus"/>
</IconButton>
) } ) }
</Flex> </Flex>
{ !isMobile && ( { !isMobile && (
......
...@@ -7,7 +7,6 @@ import type { PublicTagType } from 'types/api/addressMetadata'; ...@@ -7,7 +7,6 @@ import type { PublicTagType } from 'types/api/addressMetadata';
import type { SelectOption } from 'toolkit/chakra/select'; import type { SelectOption } from 'toolkit/chakra/select';
import { FormFieldSelect } from 'toolkit/components/forms/fields/FormFieldSelect'; import { FormFieldSelect } from 'toolkit/components/forms/fields/FormFieldSelect';
import IconSvg from 'ui/shared/IconSvg';
interface Props { interface Props {
index: number; index: number;
tagTypes: Array<PublicTagType> | undefined; tagTypes: Array<PublicTagType> | undefined;
...@@ -15,27 +14,14 @@ interface Props { ...@@ -15,27 +14,14 @@ interface Props {
const PublicTagsSubmitFieldTagType = ({ index, tagTypes }: Props) => { const PublicTagsSubmitFieldTagType = ({ index, tagTypes }: Props) => {
const getItemIcon = React.useCallback((type: PublicTagType) => {
switch (type.type) {
case 'name':
return <IconSvg name="publictags_slim" boxSize={ 5 } flexShrink={ 0 }/>;
case 'protocol':
case 'generic':
return <span>#</span>;
default:
return null;
}
}, []);
const collection = React.useMemo(() => { const collection = React.useMemo(() => {
const items = tagTypes?.map((type) => ({ const items = tagTypes?.map((type) => ({
value: type.type, value: type.type,
label: capitalize(type.type), label: capitalize(type.type),
icon: getItemIcon(type),
})) ?? []; })) ?? [];
return createListCollection<SelectOption>({ items }); return createListCollection<SelectOption>({ items });
}, [ tagTypes, getItemIcon ]); }, [ tagTypes ]);
return ( return (
<FormFieldSelect<FormFields, `tags.${ number }.type`> <FormFieldSelect<FormFields, `tags.${ number }.type`>
......
import type { HTMLChakraProps } from '@chakra-ui/react'; import type { HTMLChakraProps } from '@chakra-ui/react';
import { Center, Flex } from '@chakra-ui/react'; import { Flex } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
import type { PaginationParams } from './types'; import type { PaginationParams } from './types';
...@@ -28,7 +28,7 @@ const Pagination = (props: Props) => { ...@@ -28,7 +28,7 @@ const Pagination = (props: Props) => {
> >
<Skeleton loading={ showSkeleton } mr={ 3 }> <Skeleton loading={ showSkeleton } mr={ 3 }>
<Button <Button
variant="outline" variant="pagination"
size="sm" size="sm"
onClick={ resetPage } onClick={ resetPage }
disabled={ page === 1 || isLoading } disabled={ page === 1 || isLoading }
...@@ -38,7 +38,7 @@ const Pagination = (props: Props) => { ...@@ -38,7 +38,7 @@ const Pagination = (props: Props) => {
</Skeleton> </Skeleton>
<IconButton <IconButton
aria-label="Prev page" aria-label="Prev page"
variant="outline" variant="pagination"
boxSize={ 8 } boxSize={ 8 }
onClick={ onPrevPageClick } onClick={ onPrevPageClick }
disabled={ !canGoBackwards || isLoading || page === 1 } disabled={ !canGoBackwards || isLoading || page === 1 }
...@@ -46,26 +46,21 @@ const Pagination = (props: Props) => { ...@@ -46,26 +46,21 @@ const Pagination = (props: Props) => {
> >
<IconSvg name="arrows/east-mini" boxSize={ 5 }/> <IconSvg name="arrows/east-mini" boxSize={ 5 }/>
</IconButton> </IconButton>
<Skeleton loading={ showSkeleton } mx={ 2 } > <Button
<Center variant="pagination"
display="flex" size="sm"
alignItems="center" selected={ !showSkeleton }
justifyContent="center" pointerEvents="none"
h={ 8 } loadingSkeleton={ showSkeleton }
minW={ 8 } mx={ 2 }
px={ 2 } minW={ 8 }
fontWeight="semibold" px={ 2 }
bgColor={{ _light: 'blue.50', _dark: 'whiteAlpha.100' }} >
color={{ _light: 'blue.700', _dark: 'gray.50' }} { page }
borderRadius="base" </Button>
textStyle="sm"
>
{ page }
</Center>
</Skeleton>
<IconButton <IconButton
aria-label="Next page" aria-label="Next page"
variant="outline" variant="pagination"
boxSize={ 8 } boxSize={ 8 }
onClick={ onNextPageClick } onClick={ onNextPageClick }
disabled={ !hasNextPage || isLoading } disabled={ !hasNextPage || isLoading }
......
...@@ -93,6 +93,11 @@ const IconButtonShowcase = () => { ...@@ -93,6 +93,11 @@ const IconButtonShowcase = () => {
<IconSvg name="star_outline"/> <IconSvg name="star_outline"/>
</IconButton> </IconButton>
</Sample> </Sample>
<Sample label="size: 2xs_alt">
<IconButton size="2xs_alt" variant="icon_secondary" outline="1px dashed lightpink">
<IconSvg name="plus"/>
</IconButton>
</Sample>
<Sample label="size: md"> <Sample label="size: md">
<IconButton size="md" variant="icon_secondary" outline="1px dashed lightpink"> <IconButton size="md" variant="icon_secondary" outline="1px dashed lightpink">
<IconSvg name="star_outline"/> <IconSvg name="star_outline"/>
......
...@@ -6,7 +6,7 @@ import MaintenanceAlert from './alerts/MaintenanceAlert'; ...@@ -6,7 +6,7 @@ import MaintenanceAlert from './alerts/MaintenanceAlert';
const HeaderAlert = () => { const HeaderAlert = () => {
return ( return (
<Flex flexDir="column" rowGap={ 3 } mb={{ base: 6, lg: 3 }} _empty={{ display: 'none' }}> <Flex flexDir="column" rowGap={ 1 } mb={{ base: 6, lg: 3 }} _empty={{ display: 'none' }}>
<MaintenanceAlert/> <MaintenanceAlert/>
<IndexingBlocksAlert/> <IndexingBlocksAlert/>
</Flex> </Flex>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment