Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(APP-3490): Add custom label property for VoteProposalDataListItem component #296

Merged
merged 7 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

### Added

- Add optional `confirmationLabel` prop to the `VoteProposalDataListItem` component in order to pass a custom string
when needed.
- Add new `xs` size for core `Avatar` component

## [1.0.46] - 2024-09-21

### Added
Expand Down
10 changes: 9 additions & 1 deletion src/core/components/avatars/avatar/avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { type ResponsiveAttribute, type ResponsiveAttributeClassMap } from '../.
import { responsiveUtils } from '../../../utils';
import { AvatarBase } from '../avatarBase';

export type AvatarSize = 'sm' | 'md' | 'lg' | 'xl' | '2xl';
export type AvatarSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';

export interface IAvatarProps extends ComponentPropsWithoutRef<'img'> {
/**
Expand All @@ -25,6 +25,14 @@ export interface IAvatarProps extends ComponentPropsWithoutRef<'img'> {
}

const responsiveSizeClasses: ResponsiveAttributeClassMap<AvatarSize> = {
xs: {
default: 'size-4',
sm: 'sm:size-4',
md: 'md:size-4',
lg: 'lg:size-4',
xl: 'xl:size-4',
'2xl': '2xl:size-4',
},
sm: {
default: 'size-6',
sm: 'sm:size-6',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ export const TokenVoting: Story = {
},
};

/**
* Usage example of the VotesDataListItem module component with a custom label.
*/
export const TokenVotingCustomLabel: Story = {
args: {
proposalId: 'PIP-06',
proposalTitle: 'Introduction of Layer 2 Scaling Solutions',
voteIndicator: 'yes',
date: 1613984914000,
confirmationLabel: 'Custom label',
},
};

/**
* Usage example of the VotesDataListItem module component for a multisig vote.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,11 @@ describe('<VoteProposalDataListItemStructure /> component', () => {

expect(screen.getByText('2 days ago')).toBeInTheDocument();
});

it('renders the custom label if available', () => {
const confirmationLabel = 'Custom label';
render(createTestComponent({ confirmationLabel }));

expect(screen.getByText(confirmationLabel)).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ export type IVoteProposalDataListItemStructureProps = IDataListItemProps & {
* Date of the vote on the proposal in ISO format or as a timestamp
*/
date?: number | string;
/**
* Custom label for the tag
*/
confirmationLabel?: string;
};

export const VoteProposalDataListItemStructure: React.FC<IVoteProposalDataListItemStructureProps> = (props) => {
const { proposalTitle, proposalId, voteIndicator, date, className, ...otherProps } = props;
const { proposalTitle, proposalId, voteIndicator, date, confirmationLabel, className, ...otherProps } = props;

const { copy } = useOdsModulesContext();

Expand All @@ -37,7 +41,7 @@ export const VoteProposalDataListItemStructure: React.FC<IVoteProposalDataListIt
<span className="truncate text-neutral-800">{proposalTitle}</span>
</div>
<div className="flex items-center gap-x-1 text-sm font-normal leading-tight text-neutral-500 md:gap-x-1.5 md:text-base">
<span>{copy.voteProposalDataListItemStructure.voted}</span>
<span>{confirmationLabel ?? copy.voteProposalDataListItemStructure.voted}</span>
<Tag
variant={voteIndicatorToTagVariant[voteIndicator]}
className="capitalize"
Expand Down