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.
Spin-off from #1734642: Move breakpoint module into core. That issue is working on a UI for configuring breakpoints. This issue is just the ability for themes to identify their own breakpoints, at this time, presumed to be static (i.e., corresponding to the media queries within the their CSS files).
The benefit of this is to allow #1775530: Move picture into core to proceed independently of #1734642: Move breakpoint module into core.
Comment | File | Size | Author |
---|---|---|---|
#16 | i1775774-breakpoints-16.patch | 1 KB | effulgentsia |
#13 | interdiff.txt | 984 bytes | attiks |
#13 | i1775774-breakpoints-13.patch | 3.84 KB | attiks |
#11 | interdiff.txt | 642 bytes | attiks |
#11 | i1775774-breakpoints-11.patch | 3.92 KB | attiks |
Comments
Comment #1
effulgentsia CreditAttribution: effulgentsia commentedThis patch uses the theme's .info file for specifying breakpoints, since that's where stylesheets are specified. It adds a system_breakpoint_list() function that mimics system_region_list().
In #1734642-8: Move breakpoint module into core, there's discussion about this belonging in config rather than .info, and I think that's a good point for when a UI is added, but in this issue, let's keep breakpoint definition in the same place as stylesheet definition.
Also, it's possible that the Layouts initiative will decouple page-level layout building from themes, and if/when that happens, we'll want to tie breakpoint definitions to layouts rather than to themes, but since as of now, themes handle their own layout, they must be the ones to define their breakpoints. We can adjust later when that changes.
Comment #2
attiks CreditAttribution: attiks commentedPatch applies cleanly and all breakpoints correspondent to what's defined inside the css.
I adapted breakpoints module to support this new syntax, mainly to see if it works (and it does ;-)), but there's one thing left: the picture module uses 'breakpoint groups' to do his work, so we at least need a basic API to handle that.
I created a new issue to split the module into two parts: #1776236: Split breakpoints into API and UI module
Comment #3
webchickHm. Dries will probably want to have a look at this. He has never been a fan over overloading .info files.
Comment #4
attiks CreditAttribution: attiks commentedAlternative patch as proof-of-concept using yml files
Comment #5
attiks CreditAttribution: attiks commentedusing $theme_key.breakpoints.yml
Comment #7
attiks CreditAttribution: attiks commentedI had to add
config_install_default_config('theme', 'seven');
to the test otherwise the config wasn't loaded.Comment #8
effulgentsia CreditAttribution: effulgentsia commented#7 could work once we figure out how to remove the
config_install_default_config('theme', 'seven');
from the test. Will it work without that if we test the active theme of the test (Bartik? Stark?)?But I'd like to hear back from Dries on whether config is preferable to .info. My reasoning in #1 still stands: at this time, I think this info belongs in the same place as where stylesheets are added, and moving it to config should happen as part of making it UI configurable. But I'm okay being overruled on that if Dries or others feel strongly against adding new stuff to .info.
Comment #9
aspilicious CreditAttribution: aspilicious commentedAdd newline at the end of your config files
Comment #10
attiks CreditAttribution: attiks commentedAlex, I uploaded the patches because I heard the same as #3, I'll try the tests with other themes to see what's going on.
Personally the more I work with config, the more I like it.
Comment #11
attiks CreditAttribution: attiks commentedIt looks like the config ins't loaded by the test framework, I added theme_enable(array('seven')) to force it.
Comment #12
aspilicious CreditAttribution: aspilicious commentedStill no newlines at the end of the config files
Comment #13
attiks CreditAttribution: attiks commentedComment #14
moshe weitzman CreditAttribution: moshe weitzman commentedPersonally, I could go with either .info or .yml. I think extensions should probably all be yml and we should ditch .info but thats for another issue. Anyway, lets let committers decide between effulgentsia's patch and attik's latest.
For me, the Test isn't worth the time it takes to run. It sets up a whole Drupal just to show that we can do a $config->get() [already tested elsewhere] and return an item out of its array. If this were a pure unit test of system_breakpoint_list(), then it would be very fast (but still pointless!). No idea how feasible a unit test is for this in today's simpletest.
Comment #15
sunOverall, the config file approach makes much more sense to me for this use-case.
In #1712250: Convert theme settings to configuration system and some related issues, we're considering to move some of the theme .info stuff into a
[theme].settings
configuration object. A[theme].breakpoints
would nicely complement that.So +1 for using config. :)
On the patch:
Can we move this test into Drupal\system\Tests\Theme ?
I don't really understand why this function is part of system.module -- the configuration clearly seems to belong to a particular theme (not system module), so why don't we put it into theme.inc as
theme_get_breakpoints()
?
What do you think?
Comment #16
effulgentsia CreditAttribution: effulgentsia commentedIf we're using config, then I don't think we need a wrapper function at all, or, per #14, a test. So here's just the config files and that's it.
Comment #17
webchickNice. :) Unassigning from Dries as this makes this a lot less controversial.
Comment #18
moshe weitzman CreditAttribution: moshe weitzman commentedNice one.
Comment #19
attiks CreditAttribution: attiks commentedQuick question: we expect module builders to know that there might be a config called $theme_key.breakpoints? Is a wrapper function not easier for developers?
Comment #20
aspilicious CreditAttribution: aspilicious commentedThey will be used to the config system. So I don't see a reason why it should be bad for dx.
Comment #21
attiks CreditAttribution: attiks commentedWith the code in #13 the breakpoints module could just call
system_breakpoint_list($theme_key);
to get a possible list of defined breakpoints by the theme, without a wrapper function I'll need to do something likeMeaning I will provide my own wrapper function, as well as probably any other module wanting to use this, hence the question.
Comment #22
aspilicious CreditAttribution: aspilicious commentedThis is the case for a lot of other config conversions. We can't write a wrapper for all of them. But yeah I can see contrib code dealing with breakpoints write a wrapper for it.
Comment #23
attiks CreditAttribution: attiks commented@aspilicious true, so RTBC for me as well
Comment #25
effulgentsia CreditAttribution: effulgentsia commentedRe #21: I'm pretty sure that
config($theme_key . '.breakpoints')->get()
returns an empty array if the config object doesn't exist, so the only reasons I can think of to create a wrapper function for this one line statement are:- If we want to default $theme_key to the current theme.
- If we don't want calling code to be coupled to the name of the config file, or want to allow for future logic that does something in addition to just getting the config data.
Perhaps once we start using this, we'll see value in the above, and can add a wrapping function at that time.
Comment #26
catchDoes theme config actually get copied to the config directory when themes are enabled? My assumption would be that it doesn't yet. That notwithstanding I'm also much happier with this in config than .info.
Comment #27
attiks CreditAttribution: attiks commentedI just checked, it doesn't get copied but it is accessible.
Comment #28
catchIf it doesn't get copied, then it won't be available to config() no? If it's not I think we need to add that here, although not sure if that would introduce a dependency on #1067408: Themes do not have an installation status then?
Comment #29
attiks CreditAttribution: attiks commentedThere's something strange going on, I now have a config directory called "Array" and it contains bartik.breakpoints.yml
I did a full clean install with the patch from #16 and now the config contains bartik.breakpoints.yml, but not seven.breakpoints.yml.
I changed the admin theme to bartik, disabled seven, enabled seven and now seven.breakpoints.yml is also there.
So only problem is that the installer doesn't copy seven.breakpoints.yml if that needs to be fixed in this issue change to status, for now back to RTBC.
Comment #30
catchOK so standard_install() doesn't enable seven:
http://api.drupal.org/api/drupal/core%21profiles%21standard%21standard.i...
We should at least change that here I think.
Comment #31
attiks CreditAttribution: attiks commentedIs there're a reason why it is enabled like this:
If not we can just do
Comment #32
effulgentsia CreditAttribution: effulgentsia commentedGood question. Posted it on #1712352-5: Configuration system does not support themes.
Comment #33
attiks CreditAttribution: attiks commentedBack to RTBC, #30 is solved in #1712352: Configuration system does not support themes
Comment #34
Gábor HojtsyAn interesting related problem is declaring layouts from themes: #1787846: Themes should declare their layouts. Do you agree that CMI .yml files would be appropriate for that use case as well or something else should be used. This approach inspired me to propose that there. It would such if things use different technologies. Eg. regions are in the .info file, breakpoints are in .yml and then layouts would be yet another discovery system and/or file format. Feedback welcome there!
Comment #35
RobW CreditAttribution: RobW commentedI think most anything that you're able to alter through a UI fits well with config. In my view, .Info files generally contain hard and final information that can't be changed without breaking the theme itself (like regions, required css and js files, etc.).
Comment #36
Gábor Hojtsy@RobW: as per the intent of this issue, these breakpoints are just a static copy-paste from the breakpoints already defind in CSS to inform the rest of the system.
Comment #37
attiks CreditAttribution: attiks commentedCan this get committed or are there still some problems left?
Comment #38
webchickWe're over thresholds atm so I unfortunately can't commit any feature patches. :( Help with smashing critical and major bugs would be greatly appreciated.
Comment #39
hass CreditAttribution: hass commented~6 clicks. Apply patch > Commit > Push to remote > Password > Ok. Takes me half a minute. That's why nothing get's forward with core patches? Please grant me commit permission, I can help.
Comment #40
RobW CreditAttribution: RobW commentedHass, I think the threshold Webchick is talking about is the number of critical bugs in Drupal 8. If it's over a certain amount, no new features will be committed until the bugs are fixed. So in order to get this committed more quickly you would have to help fix the current Drupal 8 critical bugs.
See the "issue thresholds" section on drupal.org/node/1201874.
Comment #41
hass CreditAttribution: hass commentedThe wrong way is "wait until D8 is fixed" to get a properly working D7 core. Than D8 will be released later - who cares. We cannot use unready banana D7 and this is more important than future releases. We are in the situation that we are waiting e.g. a shiny SSL patch #961508: Dual http/https session cookies interfere with drupal_valid_token() or #1067120: Missing hook_taxonomy_term_view() or hook_entity_view() when viewing a term for D8 and this hold back to fix a totally broken D7 core. Great! And then we start with D9 and miss D7 and D8 again.
I have a very good understanding about regressions, but what we are doing here is plain wrong. We make D7 users waiting for over-designed patches for a future core version (that may also never get ready) and block them from implementing current (un-)stable D7 versions. Something with the focus is really wrong.
Comment #42
attiks CreditAttribution: attiks commented@hass I understand your problem, but polluting this issue isn't going to solve much, I think it's better to create a separate issue to discuss this.
Comment #43
webchickActually, even better is to just fix bugs, then this becomes a non-issue. :)
Comment #44
hass CreditAttribution: hass commentedThere are D7 real life bugfixes in queue, 2+ years RTBC, still no commit.
Comment #45
catch@hass, which of the 7 issues currently RTBC for 7.x has been there for 2 years?
Comment #46
webchickYeah, that sounds like a pretty egregious exaggeration.
In any case, we are now below thresholds, and this patch looks like a great first step to supporting responsive layouts and images in Drupal 8! I did find it confusing that these were added without an API or UI or something to use them. Alex informed me that these are going to be added in subsequent issues (e.g. picture element) and this is an unblocker. It looks like catch's concerns were addressed in #1712352: Configuration system does not support themes.
Therefore, committed and pushed to 8.x. Thanks!!
I'm pretty sure at this point we don't need a change notice, although at whatever spot we end up adding an API/UI to use these, we might.
Comment #47
webchickPost-emptively tagging "Spark."
Comment #49
xjm