-
Notifications
You must be signed in to change notification settings - Fork 13
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: remove link-button properties and create separate classes #2364
refactor: remove link-button properties and create separate classes #2364
Conversation
Hello @kyubisation I receive this error (on navigation, but time by time also on menu, card, etc):
I added a new from my understanding of the |
I'll try to have a look.
i.e. a flatter structure then nesting the action elements in menu/menu-action. @jeripeierSBB @DavideMininni-Fincons What do you think? |
I tried it and it solved the react build problem too, so even if i don't really like it due the position of the edited: i forgot to write, but for sure there are still stuff to fix (eg, i created some new mixin but not sure about them, maybe can we merge common styles?, there are comments about |
Codecov ReportAttention:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #2364 +/- ##
=======================================
Coverage ? 93.55%
=======================================
Files ? 219
Lines ? 22098
Branches ? 2006
=======================================
Hits ? 20674
Misses ? 1389
Partials ? 35 ☔ View full report in Codecov by Sentry. |
An example of how to use the new disabled and negative mixins has been done here: After the merge of this PR, a new PR from the 'refactor/link-button-components-refactoring-applying-mixins' branch can be created. |
f41647d
to
c348e54
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic work!
c348e54
to
389e5d6
Compare
9242911
to
0edc2f6
Compare
dc807ac
to
f13ece2
Compare
Preflight Checklist
Issue
This PR Closes #2212
Pull request checklist
Please check if your PR fulfills the following requirements:
See Review Guidelines for more information what is checked during review process.
Changes
Changes in this pull request:
A new class named
SbbActionBaseElement
has been created. This is used as a base class for all the button/link related components; in particular, therenderTemplate
method must be implemented by all the derived classes, returning the inner template to render.Two other base class have been created, named
SbbButtonBaseElement
andSbbLinkBaseElement
, which both extends theSbbActionBaseElement
class, and respectively implement theButtonProperties
and theLinkProperties
interfaces. These two classes contains all the logic (attributes, interaction, render) related to the natives button and link re-implementation.Four new mixins have been created, which permits adding the negative, disabled and icon behaviors to any custom component, plus a disabled mixin customized for action elements which also handles the
tabindex
andaria-disabled
attribute's setting. The mixins have been used to replace the properties functionality wherever possible:Each of the following component, which previously implemented the
LinkButtonInterface
, has been split in two separate components; the first one extends theSbbButtonBaseElement
, the second one extends theSbbLinkBaseElement
. The extension has been done by creating another mixin, generally named<Component>CommonElementMixin
, which contains the shared logic (additional properties, styles,(dis)connectedCallback()
and so on).Affected components are:
sbb-button
: split insbb-button
andsbb-button-link
;sbb-card-action
: split insbb-card-button
andsbb-card-link
;sbb-link
: split insbb-link-button
andsbb-link
;sbb-menu-action
: split insbb-menu-button
andsbb-menu-link
;sbb-navigation-action
: split insbb-navigation-button
andsbb-navigation-link
.The
isStatic
interface has been removed from codebase; for the button and the link, two new other components, namedsbb-button-static
andsbb-link-static
, have been created to replace the button/link'sisStatic
functionality. The check for nested buttons / links has been removed too, so now consumers must check these cases, and possibly fix them using the two new static variants.The static functionality is no longer available also in
sbb-breadcrumb
,sbb-teaser
,sbb-teaser-hero
.Apart from the link-button case, these components have been extended from base class:
sbb-breadcrumb
now extendsSbbLinkBaseElement
;sbb-datepicker-next-day
now extendsSbbButtonBaseElement
;sbb-datepicker-previous-day
now extendsSbbButtonBaseElement
;sbb-expansion-panel-header
now extendsSbbButtonBaseElement
;sbb-form-field-clear
now extendsSbbButtonBaseElement
;sbb-tag
now extendsSbbButtonBaseElement
;sbb-teaser-hero
now extendsSbbLinkBaseElement
;sbb-teaser
now extendsSbbLinkBaseElement
;sbb-tooltip-trigger
now extendsSbbButtonBaseElement
;Browsers
I tested the build on the following browsers:
Screen readers
I tested the build on the following browsers:
Pull request type
Please check the type of change your PR introduces:
Does this introduce a breaking change?
BREAKING CHANGES:
All of these components has been split in two, one with only-button and one with only-link behavior.
sbb-card-action
: split insbb-card-button
andsbb-card-link
;sbb-menu-action
: split insbb-menu-button
andsbb-menu-link
;sbb-navigation-action
: split insbb-navigation-button
andsbb-navigation-link
.These components has been split in three, one with only-button and one with only-link behavior, plus a static variant.
sbb-button
: split insbb-button
,sbb-button-link
andsbb-button-static
;sbb-link
: split insbb-link
,sbb-link-button
andsbb-link-static
.Check your code and change accordingly, eg.
sbb-button
withhref
set => change tosbb-button-link
;sbb-menu-action
withname
andform
set => change tosbb-menu-button
;sbb-link
withhref
set => no changes;sbb-navigation-action
withvalue
set => change tosbb-navigation-button
;sbb-button
withisStatic
set to true => change tosbb-button-static
;sbb-link
used within an anchor tag => change tosbb-link-static
;Other information