Problem/Motivation
In #2784443: Move off-canvas functionality from Settings tray module into drupal.dialog.ajax library so that other modules can use it we are separating the off-canvas dialog tray from the rest of the Setting Tray module.
This will allow other modules to use the tray.
We are not including the css that resets form styles because the tray could be used for front end style things and backend/forms style things
But it would be very nice for modules to be able to specify that they want the css reset or other css to be loaded for specific off-canvas links.
Proposed resolution
Introduce a new "main_content_renderer.off_canvas_admin" renderer service. It uses the same render class put just sends in a new optional argument $mode = "admin".
Add a new setting,"Off-canvas dialog administration theme" to the Administration Theme fieldset on /admin/appearance. This would allow choosing:
- Administration theme
- Default Theme
- (all other compatible themes)
Themes can provide CSS for the Off-canvas dialog by specifying "off_canvas_admin_stylesheets" in their *.info.yml files. The setting from the theme's base theme can also be used.(this functionality is borrowed from the QuickEdit module)
Remaining tasks
- Extract the CSS in drupal.outside_in library that only deals with the dialog styles into a new library.
- Pick a main selector class for the dialog in "admin" mode. Maybe "ui-dialog-offcanvas__admin"
- Attach that library in the extract library if in admin mode
User interface changes
None, but would allow offcanvas links to have different looks
API changes
Links can either use
'data-dialog-renderer' => 'offcanvas_admin',
or
'data-dialog-renderer' => 'offcanvas',
Data model changes
None
To Test
- Enable offcanvas_test module
- Goto /offcanvas-test-links
- There should be 4 links that open in off-canvas.
- "Click Me Admin!" will be styled differently
- The "Quick Edit" block links can still be used.
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | interdiff17_19.txt | 887 bytes | Munavijayalakshmi |
| #19 | 2847522-19.patch | 20.9 KB | Munavijayalakshmi |
| #17 | 2847522-17.patch | 20.89 KB | tedbow |
| #17 | interdiff-14-17.txt | 1.87 KB | tedbow |
| #14 | interdiff-13-14.txt | 3.67 KB | tedbow |
Comments
Comment #2
tedbowHere is the patch
Comment #3
tedbowComment #4
tim.plunkettI'm not really sure that this is a good idea. But, that aside...
It's weird you specify it with hyphens and then it's lowerCamelCase later
PHP--
lol
IMO should be an array of libraries
Extra blank line
Comment #5
tedbowStarting to think this might be crazy overly complicated.
It seems there are really 2 main use case,
For #1 you don't need to do anything
For #2 you need to load your back-end styles and do a reset.
The easiest way would just be to add the another 'data-dialog-renderer' option. Maybe 'off-canvas-admin'
You could also have a site wide setting that says load x theme for off-canvas-admin.
Options
Comment #8
tedbowOk this patch takes a much simpler approach of just introducing a new "main_content_renderer.off_canvas_admin" renderer service. It uses the same render class put just sends in a new optional argument $mode = "admin".
When in "admin" mode the service will attach a reset library(not made yet) and a dialog class.
I have updated the issue summary including the steps to test.
Comment #9
tkoleary commentedComment #10
tedbowOk I have added the a setting on "/admin/appearance" for the admin to choose which theme should be used for the Off Canvas dialog.
Then the selected theme will able to add style sheets in the same manner as quickedit. In this can add off_canvas_admin_stylesheets to the info file.
Only themes that have this setting will show up in the select.
I have added a new test theme 'off_canvas_admin_theme' that has this settings. If you enable this theme and select it you should see the background become black on the dialog.
@todo I have not written the test to test if this is loaded yet.
Comment #12
tedbowupdated test to match new constructor signature
Comment #13
tedbowUpdated \Drupal\outside_in\Tests\Ajax\OffCanvasDialogTest to include coverage for drupal_dialog_offcanvas_admin format.
Comment #14
tedbowOk this is just improvements to the comments.
Comment #15
tedbowComment #17
tedbowI canceled the test in #14 because there were a couple other small changes.
Changed the test theme name
Change the order the options in the theme select so admin theme is first.
Comment #18
Munavijayalakshmi commentedLine exceeding 80 characters
Comment #19
Munavijayalakshmi commentedComment #20
GrandmaGlassesRopeManAfter talking with @webchick, @Gábor Hojtsy and @yoroy, this seems not necessary for an MVP.
If you want to override the styles globally used in settings tray, you can override or extend the library in your theme/module.
Additionally, if you want to change it each time the tray is opened you can specify
dialogClassin the dialogOptions attribute, and have your CSS keyed from that.Comment #21
tkoleary commentedI can see the argument that this is not MVP, however it is a valuable thing to have and we should look at putting it in next release.
Comment #22
wim leersThis is indeed adding a lot of complexity while it's not clear it's actually really solving the problem.
With #2826722: Add a 'fence' around settings tray with aggressive CSS reset., we should have all the protection we need. If that's not enough, then "default" and "admin" also won't do, because they're both theme-specific, which means we'll need one of these "renderers" per theme. AFAIK the whole point of #2826722: Add a 'fence' around settings tray with aggressive CSS reset. is that it's a theme-agnostic reset.
Restoring state from #20.
Comment #23
tedbowChanging to new settings_tray.module component. @drpal thanks for script help! :)