Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
For 8.2 only warning messages were styled for the off canvas tray singe they were only needed for the tabledrag save alert. As more modules extend the offcanvas tray all messages will need to be supported.
Proposed resolution
Style all messages for the off-canvas tray.
Warning:
Error:
Status:
Message Multiple:
Message long:
Remaining tasks
- Style warnings
- Style errors
- Style alerts
- Add rtl styles
- Add hover states
- Test in all themes
- Teas cros browser
- Test for touch devices
- Test responsive
User interface changes
All messages are styled for the off canvas tray (dark background)
API changes
None
Data model changes
None
Comment | File | Size | Author |
---|---|---|---|
#41 | 2799611-messages-41.patch | 3.41 KB | tkoleary |
#37 | 2799611-messages-37.patch | 5.34 KB | tkoleary |
#35 | Screen Shot 2017-01-16 at 1.50.44 PM.png | 23.29 KB | tkoleary |
#35 | Screen Shot 2017-01-16 at 1.55.28 PM.png | 22.89 KB | tkoleary |
#35 | Screen Shot 2017-01-16 at 1.55.45 PM.png | 23.01 KB | tkoleary |
Comments
Comment #2
tkoleary CreditAttribution: tkoleary at Acquia commentedComment #3
tkoleary CreditAttribution: tkoleary at Acquia commentedComment #4
tkoleary CreditAttribution: tkoleary at Acquia commentedThere is no patch yet until the patch at #2781577: Properly style outside-in off canvas tray lands but anyone who wants to can look test this by applying the patch from #2781577, adding this CSS file, then adding this: @import
url("/core/modules/outside_in/css/outside_in.messages.css");
to the top of outside-in.theme.css.Doing it that way ftm instead of adding to libraries.yml because it needs to load last and a function has been added to the module to load the outside-in.theme.css last.
Comment #5
tkoleary CreditAttribution: tkoleary at Acquia commentedInitial patch
Comment #6
tkoleary CreditAttribution: tkoleary at Acquia commentedComment #7
tkoleary CreditAttribution: tkoleary at Acquia commentedComment #8
tkoleary CreditAttribution: tkoleary at Acquia commentedComment #9
tim.plunkettCan be
background: #000 no-repeat 10px 18px; /* LTR */
Can be
padding: 15px 10px 15px 35px; /* LTR */
Can be
margin: 10px -20px;
Can be
border: 0 solid;
Definitely should not be doing this manually. *.libraries.yml should be sufficient to order things correctly.
Comment #10
tkoleary CreditAttribution: tkoleary at Acquia commented@tim.plunkett
On 1-4: Not using shorthand is intentional here. In many instances listing all properties is more readable and maintainable. For example if we have:
It's pretty difficult to parse what's going on even if I know the shorthand property order pretty well.
However if I have:
It's immediately clear that I'm setting 4px border left for ltr, 4px right for rtl, and 1px bottom on hover. I have also not repeated properties that don't change (which someone else might unwittingly change the second instance of later).
Yeah, I agree, the reason for doing it this way is to gang the component with styles and take advantage of the function you created to load that last. After the todo around that is resolved this should be dealt with by libraries.
Or we could just add this file to the css alter function if you think that would be better? In any event if it doesn't load last it gets overridden by messages.css from Bartik and/or classy.
Comment #11
tkoleary CreditAttribution: tkoleary at Acquia commentedThis is working now since I added group 200 (ie. not being overridden by any theme) but the precise logic of how the css order is generated is still somewhat of a mystery to me, and I suspect that I'm alone in this.
Comment #12
tkoleary CreditAttribution: tkoleary at Acquia commentedRemoved styling that changes background color because there is work in another patch to have both a dark and light version of the tray and the background styling can be set there.
Comment #14
tkoleary CreditAttribution: tkoleary at Acquia commentedRerolled
Comment #15
tkoleary CreditAttribution: tkoleary at Acquia commentedComment #17
corbacho CreditAttribution: corbacho as a volunteer commentedSmall fix on libraries.yml to pass the tests.
Screenshot in Chrome-OSX
The current message "You have unsaved changes" is an ad-hoc JavaScript error message by tabledrag.js, I would like to test it with normal drupal_set_messages messages, but I can't figure it out.
Also I tried to set form errors, to test different messages styles or multiple messages, but I can't figure it out how to do it. (Validation doesn't display in the settings tray, it will jump to a different page)
A bit of help on how to test, is welcome.
Comment #18
tkoleary CreditAttribution: tkoleary at Acquia commented@corbacho
Great work! Thanks.
The way I have been testing how this works for other messages is kind of a hack but it gets part way there. I just open chrome inspector, select the element in the markup and manually change the class to check the other types of messages.
That wil at least tell you whether the CSS classes are applying correctly until the issue about moving DSMs into the tray lands. #2785047: In Outside In mode, form validation messages should appear in the off-canvas tray, not the main page
Comment #19
prestonso CreditAttribution: prestonso commentedThere is a fine balance between readability and maintainability of code and allowing CSS code size to balloon. In my opinion, those contributing to CSS should be able to interpret shorthand property values. As such, I advocate the following, in which exceptional declarations (e.g. in selectors having more specificity) avoid shorthand to aid readability, while overarching declarations employ shorthand to aid efficiency:
For what it's worth, our CSS formatting guidelines have a few examples where shorthand is used generically.
Comment #20
tkoleary CreditAttribution: tkoleary at Acquia commented@prestonso
Personally I'd find it more readable to see the attribute that is changing in longhand both in it's default and it's pseudo-class state, but I think this is a pretty good compromise, though it is somewhat reliant on the rules being directly consecutive, which they may not always be.
Comment #21
tkoleary CreditAttribution: tkoleary at Acquia commentedUpdated per CSS suggestion from @prestonso
Comment #23
tkoleary CreditAttribution: tkoleary at Acquia commented@corbacho
I think I regressed your change that made it pass tests. Not sure what's going on. Could you take a look?
Comment #24
tim.plunkettYou need a string here, either 'base', 'layout', 'component', 'state', or 'theme'.
The dashes are invalid.
Comment #25
tedbowHere is a fix the libraries file.
@tkoleary checkout the interdiff here to see the problem that @tim.plunkett was talking about.
Comment #26
yoroy CreditAttribution: yoroy at Roy Scholten commentedComment #27
tedbow@corbacho nice work here. re "I would like to test it with normal drupal_set_messages messages, but I can't figure it out."
I actually don't think it is possible. This Drupal dialog system problem not a Settings Tray specific problem. I have tried adding a drupal_set_message directly to \Drupal\outside_in\Form\SystemBrandingOffCanvasForm::buildConfigurationForm and it doesn't work. The other place place I tried was force a form validation error but that actually will bring up the form outside of the dialog on a new page. Right now all the forms we have just have required field validation which will be enforced on the client side so that is probably why we didn't notice this.
I have also just tested a simple callback using dialog and this does not display drupal_set_messages either. You can checkout my test module if you are interested https://github.com/tedbow/D8-Tester goto /tester-modal-link
So I think we shouldn't worry about drupal_set_message message right now. Will change the title. We may need create a more generic follow up to deal with dialogs including modal and the tray with other messages. But since we are using the regular dialog library we should solve that there. No need wait on that to make JS messages look better though.
Presumably if we got drupal_set_message to work with the dialog library the change made here should take effect because it uses the same classes but no way to test that out.
Comment #28
tkoleary CreditAttribution: tkoleary at Acquia commentedReviewed css and tested in simplytest.me. Working perfectly.
re "I would like to test it with normal drupal_set_messages messages, but I can't figure it out." there is another issue to move those messages into the tray: #2785047: In Outside In mode, form validation messages should appear in the off-canvas tray, not the main page
Comment #30
tkoleary CreditAttribution: tkoleary at Acquia commentedDon't know why this is saying #25 failed when the patch is green.
Comment #32
tedbowRandom test failure,ArgumentPlaceholderUpdatePathTest, back to RTBC, rinse and repeat ;)
Comment #33
alexpottDon't we need to reset the border-left-color on the rtl classes. Plus the ltr versions are missing the comment.
Here is how seven is doing something similar:
It'd be good to have rtl and ltr screenshots given the nature of the CSS being changed.
Comment #34
tkoleary CreditAttribution: tkoleary at Acquia commentedRe-rolled to fix RTL issues and add back the dark background color from the issue summary per comment from @webchick in slack.
Comment #35
tkoleary CreditAttribution: tkoleary at Acquia commentedAnd screenshots as requested.
Note that the closeness of the asterisk to the icon is only because the screen is RTL, but the language is ltr. :)
Comment #37
tkoleary CreditAttribution: tkoleary at Acquia commentedRebased on 8.3.x on 3af6a3e and re-rolled patch
Comment #38
tkoleary CreditAttribution: tkoleary at Acquia commentedComment #40
tedbow@tkoleary I thin thi
My guess is the test failed because you removed the "component" and "theme" levels of the libraries file. Those are needed as far as I can tell. You cannot put the resource directly under "css:"
Comment #41
tkoleary CreditAttribution: tkoleary at Acquia commentedFixed libraries per #40
Comment #43
Wim LeersIs this still relevant?
Comment #44
tedbowClosing this has duplicate of #2826722: Add a 'fence' around settings tray with aggressive CSS reset.
Since that is doing a hard-reset it has to provide default style for messages.
Comment #45
tedbowChanging to new settings_tray.module component. @drpal thanks for script help! :)