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 4 commits into
base: main
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:

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
slash/react/src/Button/Button.tsx Outdated Show resolved Hide resolved
min-width: 10rem;
padding: 0.8rem 1.2rem;
border: 0;
--button-padding-h: #{common.px-to-rem(16)};
Copy link
Contributor

Choose a reason for hiding this comment

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

question: je me demande si utiliser ces mixins c'est malin si on se dit qu'a terme on vire sass ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

effectivement c'est une question à débattre, sass or not sass, perso je serais d'avis, au moins dans un premier temps faire en sorte que sass ne soit pas require pour les consommateur de la lib.
après à voir si tous ce que l'on peux faire en sass est possible en css, certaine mixins peuvent surement être remplacer par des class utilitaires, mais je reste je sais pas trop.

slash/css/src/Button/Button.scss Outdated Show resolved Hide resolved
@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
) => (
<button
type="button"
className={classNames(
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 pour virer le classModifier
je ne suis pas fan de cette notion de classModifier alors que le className fait déjà très bien le travail et évite de devoir aller voir la doc pour savoir comment surcharger le css d'un composant

Copy link
Contributor Author

Choose a reason for hiding this comment

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

C'est l'objectif principale de la v2 de slash.

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 482485e to e4d1851 Compare January 23, 2025 08:27
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
48.3% Coverage on New Code (required ≥ 80%)
6.4% 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

@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

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.

5 participants