Skip to content

Commit

Permalink
Merge pull request #2612 from decentdao/ui-tweaks-2
Browse files Browse the repository at this point in the history
UI tweaks, cleanup
  • Loading branch information
DarksightKellar authored Dec 10, 2024
2 parents 711ff13 + 728b5bf commit 1f6e4bc
Show file tree
Hide file tree
Showing 18 changed files with 146 additions and 83 deletions.
3 changes: 1 addition & 2 deletions src/components/DAOTreasury/components/Transactions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,8 @@ export function PaginationCount({ shownTransactions }: { shownTransactions: numb
type="address"
value={safe.address}
p={0}
isTextLink
textStyle="labels-large"
outline="unset"
outlineOffset="unset"
borderWidth={0}
>
{t('transactionsTotalCount', { count: totalTransfers })}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ function DayStepperInput({
<InputGroup>
<Flex
flexDirection="column"
w="100%"
gap="0.5rem"
w="250px"
>
<Text color="neutral-7">{t('days', { ns: 'common' })}</Text>
<NumberStepperInput
unitHint={t('days', { ns: 'common' })}
value={inputValue}
onChange={val => onInputChange(Number(val))}
/>
Expand Down
11 changes: 6 additions & 5 deletions src/components/DaoCreator/formComponents/Multisig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,12 @@ export function Multisig(props: ICreationStepProps) {
}
isRequired
>
{/* @todo replace with stepper input */}
<NumberStepperInput
onChange={value => validateNumber(value, 'multisig.signatureThreshold')}
value={values.multisig.signatureThreshold}
/>
<Flex w="200px">
<NumberStepperInput
onChange={value => validateNumber(value, 'multisig.signatureThreshold')}
value={values.multisig.signatureThreshold}
/>
</Flex>
</LabelComponent>
</Flex>
</StepWrapper>
Expand Down
6 changes: 5 additions & 1 deletion src/components/Roles/RolePaymentDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,12 @@ export function RolePaymentDetails({
mx={4}
>
<Flex justifyContent="space-between">
<Flex gap={2}>
<Flex
alignItems="center"
gap={2}
>
<Image
h="2rem"
src={payment.asset.logo}
fallbackSrc="/images/coin-icon-default.svg"
/>
Expand Down
9 changes: 6 additions & 3 deletions src/components/SafeSettings/ERC20TokenContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { useTranslation } from 'react-i18next';
import { useFractal } from '../../providers/App/AppProvider';
import { AzoriusGovernance } from '../../types';
import { formatCoin } from '../../utils';
import { StyledBox } from '../ui/containers/StyledBox';
import { DisplayAddress } from '../ui/links/DisplayAddress';
import { BarLoader } from '../ui/loaders/BarLoader';

Expand All @@ -15,13 +14,17 @@ export function ERC20TokenContainer() {
const { votesToken } = azoriusGovernance;

return (
<StyledBox width="100%">
<Box width="100%">
<Text textStyle="heading-small">{t('governanceTokenTitle')}</Text>
{votesToken ? (
<Flex
justifyContent="space-between"
flexWrap={{ base: 'wrap', md: 'nowrap' }}
mt={4}
p="1.5rem"
borderWidth="0.06rem"
borderColor="neutral-3"
borderRadius="0.75rem"
>
{/* TOKEN NAME */}
<Box w={{ base: 'full', sm: 'auto' }}>
Expand Down Expand Up @@ -76,6 +79,6 @@ export function ERC20TokenContainer() {
<BarLoader />
</Flex>
)}
</StyledBox>
</Box>
);
}
13 changes: 9 additions & 4 deletions src/components/SafeSettings/ERC721TokensContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Flex, Grid, GridItem, Text } from '@chakra-ui/react';
import { Box, Flex, Grid, GridItem, Text } from '@chakra-ui/react';
import { useTranslation } from 'react-i18next';
import { useFractal } from '../../providers/App/AppProvider';
import { AzoriusGovernance } from '../../types';
import { StyledBox } from '../ui/containers/StyledBox';
import { DisplayAddress } from '../ui/links/DisplayAddress';
import { BarLoader } from '../ui/loaders/BarLoader';

Expand All @@ -14,7 +13,13 @@ export function ERC721TokensContainer() {
const { erc721Tokens } = azoriusGovernance;

return (
<StyledBox width="100%">
<Box
width="100%"
p="1.5rem"
borderWidth="0.06rem"
borderColor="neutral-3"
borderRadius="0.75rem"
>
<Text>{t('governanceERC721TokenTitle')}</Text>
{erc721Tokens ? (
<Flex flexWrap="wrap">
Expand Down Expand Up @@ -97,6 +102,6 @@ export function ERC721TokensContainer() {
<BarLoader />
</Flex>
)}
</StyledBox>
</Box>
);
}
2 changes: 0 additions & 2 deletions src/components/SafeSettings/SettingsContentBox.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { BoxProps } from '@chakra-ui/react';
import { PropsWithChildren } from 'react';
import { NEUTRAL_2_84 } from '../../constants/common';
import { StyledBox } from '../ui/containers/StyledBox';

export function SettingsContentBox({ children, ...props }: PropsWithChildren<BoxProps>) {
Expand All @@ -9,7 +8,6 @@ export function SettingsContentBox({ children, ...props }: PropsWithChildren<Box
w="100%"
borderTopLeftRadius={{ base: '0.75rem', md: '0' }}
borderBottomLeftRadius={{ base: '0.75rem', md: '0' }}
bg={NEUTRAL_2_84}
{...props}
>
{children}
Expand Down
7 changes: 3 additions & 4 deletions src/components/SafeSettings/Signers/SignersContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { Button, Flex, Hide, HStack, Icon, Show, Text } from '@chakra-ui/react';
import { Box, Button, Flex, Hide, HStack, Icon, Show, Text } from '@chakra-ui/react';
import { MinusCircle, PlusCircle } from '@phosphor-icons/react';
import { useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Address, getAddress } from 'viem';
import { useAccount } from 'wagmi';
import { useDaoInfoStore } from '../../../store/daoInfo/useDaoInfoStore';
import { StyledBox } from '../../ui/containers/StyledBox';
import { DisplayAddress } from '../../ui/links/DisplayAddress';
import { ModalType } from '../../ui/modals/ModalProvider';
import { useDecentModal } from '../../ui/modals/useDecentModal';
Expand Down Expand Up @@ -102,7 +101,7 @@ export function SignersContainer() {
}, [account, signers]);

return (
<StyledBox width="100%">
<Box width="100%">
<Flex justifyContent="space-between">
<Text>{t('signers', { ns: 'common' })}</Text>
{userIsSigner && (
Expand Down Expand Up @@ -131,6 +130,6 @@ export function SignersContainer() {
threshold={safe?.threshold}
/>
))}
</StyledBox>
</Box>
);
}
10 changes: 8 additions & 2 deletions src/components/ui/forms/NumberStepperInput.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {
Button,
HStack,
InputGroup,
InputRightElement,
NumberDecrementStepper,
NumberIncrementStepper,
NumberInput,
Expand All @@ -11,9 +13,11 @@ import { Plus, Minus } from '@phosphor-icons/react';
export function NumberStepperInput({
value,
onChange,
unitHint,
}: {
value?: string | number;
onChange: (val: string) => void;
unitHint?: string;
}) {
const stepperButton = (direction: 'inc' | 'dec') => (
<Button
Expand All @@ -32,11 +36,13 @@ export function NumberStepperInput({
onChange={onChange}
min={0}
focusInputOnChange
w="100%"
>
<HStack gap="0.25rem">
<NumberDecrementStepper>{stepperButton('dec')}</NumberDecrementStepper>
<NumberInputField min={0} />
<InputGroup>
<NumberInputField min={0} />
<InputRightElement mr="1rem">{unitHint}</InputRightElement>
</InputGroup>
<NumberIncrementStepper>{stepperButton('inc')}</NumberIncrementStepper>
</HStack>
</NumberInput>
Expand Down
34 changes: 23 additions & 11 deletions src/components/ui/menus/SafesMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,29 @@ export function SafesMenu() {
/>
</Button>
}
options={favoritesList.map(favorite => ({
optionKey: `${favorite.networkPrefix}:${favorite.address}`,
onClick: () => {},
renderer: () => (
<SafeMenuItem
name={favorite.name}
address={favorite.address}
network={favorite.networkPrefix}
/>
),
}))}
options={
!favoritesList.length
? [
{
optionKey: 'empty-favorites',
onClick: () => {},
renderer: () => (
<Text padding="1rem">{t('emptyFavorites', { ns: 'dashboard' })}</Text>
),
},
]
: favoritesList.map(favorite => ({
optionKey: `${favorite.networkPrefix}:${favorite.address}`,
onClick: () => {},
renderer: () => (
<SafeMenuItem
name={favorite.name}
address={favorite.address}
network={favorite.networkPrefix}
/>
),
}))
}
buttonAs={Button}
buttonProps={{
variant: 'tertiary',
Expand Down
17 changes: 14 additions & 3 deletions src/hooks/DAO/loaders/useDecentTreasury.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import {
} from '../../../types';
import { formatCoin } from '../../../utils';
import { MOCK_MORALIS_ETH_ADDRESS } from '../../../utils/address';
import { CacheExpiry, CacheKeys } from '../../utils/cache/cacheDefaults';
import { setValue } from '../../utils/cache/useLocalStorage';

export const useDecentTreasury = () => {
// tracks the current valid DAO address / chain; helps prevent unnecessary calls
Expand Down Expand Up @@ -168,12 +170,14 @@ export const useDecentTreasury = () => {
// make unique
.filter((value, index, self) => self.indexOf(value) === index)
// turn them into Address type
.map(address => getAddress(address));
.map(getAddress);

const transfersTokenInfo = await Promise.all(
tokenAddressesOfTransfers.map(async address => {
let tokenInfo: TokenInfoResponse;

try {
return await safeAPI.getToken(address);
tokenInfo = await safeAPI.getToken(address);
} catch (e) {
const fallbackTokenData = tokenBalances?.find(
tokenBalanceData => getAddress(tokenBalanceData.tokenAddress) === address,
Expand All @@ -198,14 +202,21 @@ export const useDecentTreasury = () => {
};
}

return {
tokenInfo = {
address,
name: fallbackTokenData.name,
symbol: fallbackTokenData.symbol,
decimals: fallbackTokenData.decimals,
logoUri: fallbackTokenData.logo,
};
}

setValue(
{ cacheName: CacheKeys.TOKEN_INFO, tokenAddress: address },
tokenInfo,
CacheExpiry.NEVER,
);
return tokenInfo;
}),
);

Expand Down
8 changes: 7 additions & 1 deletion src/hooks/DAO/loaders/useHatsTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ const useHatsTree = () => {
? secondsTimestampToDate(lockupLinearStream.cliffTime)
: undefined;

const logo =
getValue({
cacheName: CacheKeys.TOKEN_INFO,
tokenAddress: getAddress(lockupLinearStream.asset.address),
})?.logoUri || '';

return {
streamId: lockupLinearStream.id,
contractAddress: lockupLinearStream.contract.address,
Expand All @@ -213,7 +219,7 @@ const useHatsTree = () => {
name: lockupLinearStream.asset.name,
symbol: lockupLinearStream.asset.symbol,
decimals: lockupLinearStream.asset.decimals,
logo: '', // @todo - how do we get logo?
logo,
},
amount: {
bigintValue: BigInt(lockupLinearStream.depositAmount),
Expand Down
Loading

0 comments on commit 1f6e4bc

Please sign in to comment.