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

WIP feat(APP-3508): Remove title and description props from ProposalVoting module component #327

Closed
wants to merge 5 commits into from
Closed
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

## Changed

- Remove `title` and `description` properties from `ProposalVoting` module component

## [1.0.52] - 2024-10-30

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,6 @@ const getMultisigSettings = (minApprovals: number) => [
*/
export const MultiStage: Story = {
args: {
title: 'Voting',
description:
'The proposal must pass all governance stages to be accepted and potential onchain actions to execute.',
activeStage: '0',
className: 'max-w-[560px]',
},
Expand Down Expand Up @@ -183,8 +180,6 @@ export const MultiStage: Story = {
*/
export const SingleStage: Story = {
args: {
title: 'Voting',
description: 'The proposal must pass the voting to be accepted and potential onchain actions to execute.',
className: 'max-w-[560px]',
},
render: (args) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ type Story = StoryObj<typeof ProposalVoting.Container>;
/**
* Default usage example of the ProposalVoting.Container component.
*/
export const Default: Story = {
args: {
title: 'Proposal voting',
description: 'The proposal must pass the voting to be accepted and potential onchain actions to execute.',
},
};
export const Default: Story = {};

export default meta;
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,12 @@ import { type IProposalVotingContainerProps, ProposalVotingContainer } from './p
describe('<ProposalVotingContainer /> component', () => {
const createTestComponent = (props?: Partial<IProposalVotingContainerProps>) => {
const completeProps: IProposalVotingContainerProps = {
title: '',
description: '',
...props,
};

return <ProposalVotingContainer {...completeProps} />;
};

it('renders the proposal voting title and description', () => {
const title = 'Proposal voting';
const description = 'Description for the voting terminal';
render(createTestComponent({ title, description }));
expect(screen.getByRole('heading', { level: 2, name: title })).toBeInTheDocument();
expect(screen.getByText(description)).toBeInTheDocument();
});

it('renders an accordion container when having more than one child', () => {
const children = [
<ProposalVotingStage key="0" status={ProposalVotingStatus.ACCEPTED} startDate={0} endDate={0} />,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,22 @@
import classNames from 'classnames';
import React, { Children, type ComponentProps } from 'react';
import { Accordion, Card, Heading } from '../../../../../core';
import { Accordion, Card } from '../../../../../core';

export interface IProposalVotingContainerProps extends ComponentProps<'div'> {
/**
* Title displayed on top.
*/
title: string;
/**
* Description of the proposal voting.
*/
description: string;
/**
* Active stage that will be expanded by default for multi-stage proposals.
*/
activeStage?: string;
}

export const ProposalVotingContainer: React.FC<IProposalVotingContainerProps> = (props) => {
const { title, description, className, children, activeStage, ...otherProps } = props;
const { className, children, activeStage, ...otherProps } = props;

const processedChildren = Children.toArray(children);
const isMultiStage = processedChildren.length > 1;

return (
<Card className={classNames('flex flex-col overflow-hidden', className)} {...otherProps}>
<div className={classNames('flex flex-col gap-2 p-4 md:gap-3 md:p-6', { 'pb-2 md:pb-3': !isMultiStage })}>
<Heading size="h2">{title}</Heading>
<p className="text-base font-normal leading-normal text-neutral-500">{description}</p>
</div>
<Card className={classNames('flex w-full flex-col overflow-hidden', className)} {...otherProps}>
thekidnamedkd marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The full component alignment with the new design can be done later, but without the title and description the component looks off. We can probably update the paddings and gap to have a better temporary version of the component
Screenshot 2024-11-04 at 15 50 42

{isMultiStage && (
<Accordion.Container isMulti={false} defaultValue={activeStage}>
{processedChildren.map((child, index) =>
Expand Down