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: improve pro label #545

Merged
merged 5 commits into from
Nov 7, 2024
Merged

feat: improve pro label #545

merged 5 commits into from
Nov 7, 2024

Conversation

oliviercperrier
Copy link
Contributor

FEAT

  • relates to CLIN-2923

Description

Make ProLabel supports Popover and Tooltip for the info icon.

[JIRA LINK]

Acceptance Criterias

Validation

  • [ x] Storybook add or modified
  • [ x] version Update in package.json and Release.md
  • Code Approved
  • QA Done
  • Design/UI Approved from design

Screenshot

Screenshot 2024-11-06 at 4 00 26 PM

Mention

@kstonge @luclemo

@oliviercperrier oliviercperrier changed the title Feat/improve pro label feat: improve pro label Nov 6, 2024
packages/ui/package.json Outdated Show resolved Hide resolved
Copy link

github-actions bot commented Nov 6, 2024

Coverage report for packages/ui

St.
Category Percentage Covered / Total
🟢 Statements 100% 0/0
🟢 Branches 100% 0/0
🟢 Functions 100% 0/0
🟢 Lines 100% 0/0

Test suite run success

0 tests passing in 0 suite.

Report generated by 🧪jest coverage report action from dfecd73

Copy link

github-actions bot commented Nov 6, 2024

Project Coverage and Test

Statements : 33.65% ( 10612/31532 )
Branches : 55.3% ( 631/1141 )
Functions : 31.82% ( 197/619 )
Lines : 33.65% ( 10612/31532 )

Test Suites: 58 passed, 58 total
Tests: 262 passed, 262 total
Snapshots: 0 total
Time: 88.664 s
Ran all test suites.

Comment on lines 8 to 23
export interface IProLabelProps {
export type IProLabelProps = {
title: string;
className?: string;
popoverProps?: PopoverProps;
colon?: boolean;
size?: 'small' | 'default';
requiredMark?: boolean;
}
} & (
| {
popoverProps?: PopoverProps;
tooltipProps?: never;
}
| {
popoverProps?: never;
tooltipProps?: TooltipProps;
}
);
Copy link
Contributor

Choose a reason for hiding this comment

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

C'est chimique le join que tu fais la, pourquoi ne pas juste rajouter le nouveau prop en optionnel dans l'interface actuelle ? De cette manière tu réduits les chances d'impacter l'existant, car l'interface est exportée.

export interface IProLabelProps {
    title: string;
    className?: string;
    popoverProps?: PopoverProps;
    tooltipProps?: TooltipProps;
    colon?: boolean;
    size?: 'small' | 'default';
    requiredMark?: boolean;
}

Copy link
Contributor Author

@oliviercperrier oliviercperrier Nov 7, 2024

Choose a reason for hiding this comment

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

@atoulous Ca s'appel du conditional typing c'est loin d'être chimique hahah.

tooltipProps ne peut pas être défini en meme temps que popoverProps, d'où le conditional typing.

Ca n'impacte en rien l'existant.

Je peux faire ce que tu dis, mais en faisant cela, on se retrouve avec des components qui ont des props qui peuvent être définies mais qui ne font rien au final, ce qui est selon moi une mauvaise pratique.

Je peux te le mettre plus beau en séparant les types si c'est le visuel qui t'achale 😉

Copy link
Contributor

Choose a reason for hiding this comment

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

Garde comme ça si c'est ce que tu préconises 👍
Selon moi l'optional typing suffisait, mais pour le conditional je te partage une solution que je trouve plus lisible avec du naming

interface IProLabelBaseProps {
    title: string;
    className?: string;
    colon?: boolean;
    size?: 'small' | 'default';
    requiredMark?: boolean;
}

interface IProLabelWithPopover extends IProLabelBaseProps {
    popoverProps: PopoverProps;
    tooltipProps?: never;
}

interface IProLabelWithTooltip extends IProLabelBaseProps {
    tooltipProps: TooltipProps;
    popoverProps?: never;
}

export type IProLabelProps = IProLabelWithPopover | IProLabelWithTooltip;

Copy link
Contributor

Choose a reason for hiding this comment

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

je viens mettre mon petit grain de sel mais vous pouvez l'ignorer 😄
J'avoue que je trouve plus lisible la solution d'Aymeric mais les 2 me vont pour du conditional et in fine ça fait la même chose.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sinon, voici ce que j'ai fait

interface IProLabelWithPopover {
    popoverProps?: PopoverProps;
    tooltipProps?: never;
}

interface IProLabelWithTooltip {
    popoverProps?: never;
    tooltipProps?: TooltipProps;
}

export type IProLabelProps = {
    title: string;
    className?: string;
    colon?: boolean;
    size?: 'small' | 'default';
    requiredMark?: boolean;
} & (IProLabelWithPopover | IProLabelWithTooltip);

Copy link
Collaborator

@francisl francisl left a comment

Choose a reason for hiding this comment

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

👍

@francisl
Copy link
Collaborator

francisl commented Nov 7, 2024

@oliviercperrier tu vas juste devoir faire un rebase et mettre a jour ta version a 10.13.0 (new features)

@oliviercperrier oliviercperrier merged commit 5d7cde9 into master Nov 7, 2024
7 checks passed
@oliviercperrier oliviercperrier deleted the feat/improve-pro-label branch November 7, 2024 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants