Problem/Motivation
We are experiencing bigger inconsistencies with paragraph buttons while using default Seven theme. In https://www.drupal.org/project/paragraphs/issues/3111075 we introduced the .button--small class to various buttons in order to display them correctly in Claro, but didn't notice these side effects.
For example, the dropdown buttons are very small, "Add paragraphs" button is small, while the Edit button is big.
Proposed resolution
Discuss how to tackle this issue and fix it properly. Maybe reset those paddings for Seven specifically?
Had a quick discussion with @saschaeggi on Slack. His words were "From a Design System point of view the Edit button in the table view should be a small one button--small but the Add paragraph ones can be regular ones", but I am guessing that this applies for Claro only?
Also while at it, the "Add more" button is missing the button--small class, we need to add it there too. See the screenshots attached.
Comments
Comment #2
sasanikolic commentedHere is an initial patch that resets the .button--small definition for the Seven theme and that adds that class to the field-add-more-submit button.
Also attaching a test with smaller edit buttons.
Comment #4
sasanikolic commentedThis should fix the failing test.
Comment #5
pivica commentedA bit of an unfortunate situation because module is applying CSS classes and fixes for themes instead of inverted situation where themes should be doing this. But what to do I guess it would be very hard for Claro theme to inject needed button--small CSS class on theme level.
I see more additional stuff from Claro like button--extrasmall CSS class added to paragraph code. This, and maybe more CSS classes we will add from Claro in future, could potentially create problems - it could randomly clash with contrib modules CSS rules, etc.
Anyway
Minor thing but, not sure should we use @at-root here to keep this in context of current scope - this is a fix that is fixing both current and .paragraphs-add-wrapper scopes. I would move this outside of current scope so we do not need to write @at-root.
This rule is restoring regular button size because of applying `button--small` CSS class rule. Shouldn't we use here `button--small` instead of `button` and state in CSS selector exactly why this rule is applied?
Beside this, tested current patch and it does solve issues described in description.
Comment #6
sasanikolic commentedThanks for the review @pivica. While I know the issues you mentioned above, I don't see any other possible solutions currently than to reset those styles in the paragraphs module.
Did those changes that you mentioned above now and found another case for the dropbuttons, fixed also those.
Comment #8
pivica commentedChanges looks good. Just one thingy:
Instead of this can we just write:
Tried this for first two selectors and it seems it works fine. I can't reproduce `.paragraphs-dropbutton-wrapper` selector but I guess it will also work?
Comment #9
sasanikolic commentedRight, I also think we can remove those selectors.
Comment #11
berdircontent is the name of the block id, while it is usually like this, it doesn't seem like a good idea to hardcode this. It's not nice, but what we could do is check the active them and then add a separate library with a separate file for seven specific overrides. in a follow-up, we could consider moving other seven specific styling in there as well.
if (\Drupal::theme()->getActiveTheme()->getName() == 'seven') {
add second seven specific library
}
Comment #12
sasanikolic commentedMoved the code to a separate paragraphs.seven.css file. Noticed that the selector is not strong enough, because seven's buttons.css is loaded after our css, so I had to make it more specific.
Comment #14
sasanikolic commentedMissed the buttons in the modal. Need to also change the selector there.
Comment #16
pivica commentedChecked latest changes in the patch, looks good.
Tested against Drupal 8.9.3 and Drupal 9.0.3 with latest paragraphs dev version and this patch. Buttons in Seven theme looks good, and I don't see any special problem with Claro related to buttons.
Comment #18
berdirThanks everyone.