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

Refactor Button Component with New Variants and Props #772

Open
wants to merge 5 commits into
base: slash-releases/2.0.0
Choose a base branch
from

Conversation

pplancq
Copy link
Contributor

@pplancq pplancq commented Jan 20, 2025

Description:

This PR introduces significant changes to the button component, including a restyle with the new-look Slash DS and the introduction of variant props instead of classModifier. The following breaking changes are included

closes #751

Breaking Changes:

  1. Restyle Button with New-Look Slash DS

    • Removed universes variant; use custom class if needed.
    • Removed hasIconLeft/hasIconRight; CSS now auto-detects use of SVG or glyphicon.
    • Renamed reverse variant to secondary.
    • Renamed success variant to validated.
    • Removed disabled variant; now use button's disabled prop.
    • Removed circle variant.
  2. Introduction of Variant Props

    • Prop className no longer removes default style.
    • Removed prop classModifier; use props variant, size, leftIcon, and rightIcon instead.

Additional Information:

For the CSS part, I have introduced the use of CSS variables for colors, fonts, etc., as well as mixins to provide various shortcuts for creating our CSS classes. All these modifications are open to discussion and may lead to the drafting of an ADR on CSS best practices.

Screanshot:

msedge_rt4ODxIcu4

@pplancq pplancq added agent-slash Component for the agent theme component component needs to be worked on css-package Affects the CSS package breaking-change labels Jan 20, 2025
@pplancq pplancq self-assigned this Jan 20, 2025
@pplancq pplancq force-pushed the feature/slash-button branch from bf061fe to bace0b6 Compare January 20, 2025 14:11
@pplancq pplancq force-pushed the feature/slash-button branch from 6b3538d to 16d1064 Compare January 20, 2025 15:43
@pplancq pplancq force-pushed the feature/slash-button branch from 16d1064 to 482485e Compare January 21, 2025 12:32
@pplancq pplancq force-pushed the feature/slash-button branch from 482485e to e4d1851 Compare January 23, 2025 08:27
@johnmeunier
Copy link
Contributor

Lorsqu'il y a des breaking change impliqué par une PR, il faudrait que cette PR mette à jour tout de suite le guide de Migration, ca évitera de le faire au dernier moment avant la livraison de la nouvelle version.

Je vois qu'ici il n'y a que le guide de migration depuis le premier toolkit. Le MIGRATION.md peut être initialisé grâce à cette PR.

@pplancq
Copy link
Contributor Author

pplancq commented Jan 24, 2025

Lorsqu'il y a des breaking change impliqué par une PR, il faudrait que cette PR mette à jour tout de suite le guide de Migration, ca évitera de le faire au dernier moment avant la livraison de la nouvelle version.

Je vois qu'ici il n'y a que le guide de migration depuis le premier toolkit. Le MIGRATION.md peut être initialisé grâce à cette PR.

Yes pas faux j'ai complément zapper le guide de migration, je le fais des que possible

@pplancq pplancq force-pushed the feature/slash-button branch from e4d1851 to 267af16 Compare January 29, 2025 13:42
@pplancq pplancq changed the base branch from main to slash-releases/2.0.0 January 29, 2025 13:43
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
48.8% Coverage on New Code (required ≥ 80%)
6.8% Duplication on New Code (required ≤ 3%)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@pplancq pplancq force-pushed the feature/slash-button branch from 267af16 to 6ddfa45 Compare February 6, 2025 08:04
@pplancq pplancq force-pushed the feature/slash-button branch 3 times, most recently from 53747d6 to 79407ee Compare February 12, 2025 13:50
johnmeunier
johnmeunier previously approved these changes Feb 14, 2025
Comment on lines +10 to +13
@mixin label {
font-family: var(--font-family-base);
font-size: var(--font-size-16);
font-weight: var(--font-weight-bold);
line-height: var(--font-line-height-20);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

je ne vois pas l'intéret de cette mixin. Passons nous en !

Copy link
Contributor Author

Choose a reason for hiding this comment

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

le est d'avoir des mixin utilitaire que corresponde au fonts style du DS https://zeroheight.com/4b1e27a45/v/latest/p/9506de-fonts-style
Afin que si cela change on est à le changé qu'a un seul endroit, maintenant vue qu'on c'est dit de minimiser l'utilisation de sass je pense qu'il faudrait transformer la mixin en class css utilitaire.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@JLou afin de te montrer ma vision des choses et de ne pas surcharger cette PR j'ai séparé cette partie dans une autre PR #890

n'hésite pas à me dire ce que tu en penses.

@pplancq pplancq force-pushed the feature/slash-button branch from 79407ee to 50ea1cb Compare February 17, 2025 14:26
import "@axa-fr/design-system-slash-css/dist/Button/Button.scss";

import { ComponentPropsWithoutRef, PropsWithChildren } from "react";
import { getComponentClassName } from "../utilities";
export type Variant = "primary" | "secondary" | "validated" | "danger";
Copy link
Contributor

Choose a reason for hiding this comment

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

question: Est ce que c'est utile de mettre "primary" dans les variants ?
Ca peut éviter de mettre une condition sur === "primary"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Je vois ce que tu veux dire, ou alors on veut faire un truc à la bootstrat a savoir ajouter une classe css af-btn--primary
(d'ailleurs idem pour le size) cela évitera la condition on aurait juste classNames(DEFAULT_CLASS_NAME, ${DEFAULT_CLASS_NAME}--${variant}, ${DEFAULT_CLASS_NAME}--${size}, className)

Parce que perso je ne suis pas fan du fait de ne pas mettre le variant primary. mais c'est juste une pref perso.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

J'ai fais des changements j'ai pris exemple sur le fonctionnement de bootstrap ou il faut mettre les class af-btn et af-btn--primary au minimum.
et j'ai passer la props size en small en mode boolean.

dit moi ce que tu en penses.

@pplancq pplancq force-pushed the feature/slash-button branch from 50ea1cb to b487419 Compare February 19, 2025 09:56
BREAKING CHANGE: **button**, removed universes variant; use custom class if needed
BREAKING CHANGE: **button**, removed hasIconLeft/hasIconRight; CSS auto-detects use of SVG or glyphicon
BREAKING CHANGE: **button**, variant reverse is now renamed to secondary
BREAKING CHANGE: **button**, variant success is now renamed to validated
BREAKING CHANGE: **button**, removed disabled variant; now use button's disabled prop
BREAKING CHANGE: **button**, removed circle variant
…on button component

BREAKING CHANGE: **button**, prop `className` no longer removes default style
BREAKING CHANGE: **button**, prop `classModifier` is removed; use props `variant`, `size`, `leftIcon`, and `rightIcon` instead
@pplancq pplancq force-pushed the feature/slash-button branch from b487419 to 48d3299 Compare February 20, 2025 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent-slash Component for the agent theme breaking-change component component needs to be worked on css-package Affects the CSS package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Slash] [UX] - Button Component
5 participants