Needs work
Project:
Drupal core
Version:
main
Component:
theme system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
17 Apr 2014 at 14:53 UTC
Updated:
20 May 2026 at 00:48 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
sunWorking implementation, including proper test coverage.
Comment #2
sunComment #3
sun2: link.button.2.patch queued for re-testing.
Comment #5
sunMerged HEAD
Comment #6
marvil07 commentedAfter this patch was created a new class get into D8, RenderTest, I guess we want to reuse it.
Comment #7
joelpittetI"m not sure this is inline with the classy theme to move classes to the classy theme and remove them from stark. I'll send @mortendk and @davidhernandez over here to check into this.
Comment #8
joelpittetIs there a prevision for the case of not wanting any classes on buttons? Or removing the 'button' class?
Comment #9
mortendk commentedooooh these prerendered classes are a pita to work with later on & one of the things that have haunted themers down when they wanted to add in other frameworks, that lets say used the
.buttonfor something specific (and you dont wanna maintain your own version of that framework offcourse)Heres an idea - what if we prefix that kinda stuff with, so its clear where it comes from, and dont end up taking common classnames (yes i know im anal about this)
drupal-button ?
drupal-button--
By at least using some kind of name spacing we know where it comes from & the chance of it colliding with an exisiting css framework is small.
What i would Looooooooove to see was instead
button.html.twigand used addClass(' button--mucho-danger') instead, that would make it clear for the themer where to fix this class thingieComment #10
davidhernandezYeah, I was going to say the exact same thing as Morten. Not the class prefix part ;) but the template part. We are trying to eliminate, as much as possible, classes being generated, so I don't think we want to add more. The problem is how we are styling/creating buttons in core. It would be much nicer if we had a button template, and pass a variable of the button type to it. Then themers could deal with it as they want, including changing how the markup works.
Comment #11
marvil07 commentedI was wrong about RenderTest, it's not a base test as the one added here.
Here an updated patch, based on what sun proposed, creates a twig template for links, which is needed in order to add classes on the template.
I modified the implementation to follow several drupal changes like link theme variables.
Also I'm using it on the LinkGenerator class.
Notes:
Comment #13
mortendk commented@marvil yeah for templates ! - could we call it
button-link.html.twigin that its clear for the themer that dont know anything what the template might is about.Comment #14
joelpittetWhat about just
link--button-danger.html.twigand just add to the template suggestions of the existing template?Comment #15
marvil07 commentedA new patch, here I'm trying to use theme suggestions to pick either link.html.twig or link--button.html.twig depending on the use of the new '#button_type' property, BTW since logic is now in php we can again differentiate between isset() and empty() cases, which seems to be not possible in twig.
In any case, I'm not sure if I'm using theme suggestions correctly, since they seem to be picked up, but the template in use is always link.html.twig, any suggestion is welcome.
Comment #16
marvil07 commentedI forgot the interdiff
Comment #18
marvil07 commentedKernelTestBase already have a render(), reuse it, question about how to use twig templates is still open.
Comment #22
marvil07 commentedActually use \Drupal\Tests\Core\Render\RendererTestBase
Comment #23
tim.plunkettThis should be injected.
This can be removed
public function
Why is this redclaring assertRaw and friends? Please use AssertContentTrait.
Comment #37
smustgrave commentedThank you for creating this issue to improve Drupal.
We are working to decide if this task is still relevant to a currently supported version of Drupal. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or is no longer relevant. Your thoughts on this will allow a decision to be made.
Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.
Thanks!
Comment #38
smustgrave commentedWanted to bump 1 more time.
Comment #40
smustgrave commentedMay still be relevant looking at it a third time, definitely needs a summary update.