New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Layouts API testing #103
Comments
I've updated this a bit. New code:
And this will fix #45
|
In 747ed04, the layout image is now working. So, define the image URLs when registering layouts to see them in the customizer. |
Very nice. What do you think about using the text label as a title attribute on the image? |
The text label is the |
It would just give a tooltip of sorts in case the images weren't self explanatory enough. |
Looking at it now, WordPress really only gives hover effects on buttons. Which for this particular case, these kind of are buttons. But they also kind of aren't... So maybe I was just being picky. 😒 |
I'm looking for something similar in core. The closest thing is their image/media modal. The images there don't get anything on hover. I'm might just go with a |
You're not being too picky either. That's why I have this up here -- feedback. That last commit adds a little extra styling. |
This looks cool. Like most of the stuff in 3.0. Note that title attribute can be problematic for accessibility. Is there any way to just show text (2 colums: Sidebar / Content) under or aside the image? |
I was thinking the same thing about the title attribute, which is one of the reasons I've gotten rid of most of them. It's not necessarily a no-no, but I'm thinking that it's not a good use of them here. Users can always enable image alt text tooltips if their browser doesn't support such a thing out of the box. As for just showing the text, that's not an option to me for this. The user will be getting instant feedback (live preview) anyway when they click a button. |
Live preview indeed, that's enough. 👍 |
Rather than Following this concept, the array keys might be best named Additionally, making the list of default supported CPTs (when the meta is value is simply |
@brichards - For the per-post-type layouts, I really, really love that idea. I'm about to play around with it. The only "issue" I have with switching back to That got me to thinking that we should have:
Those deal with things on an object-type level, regardless of the UI (customizer, meta box, etc.). Rather than 'is_post_layout' => true it would be interesting to see post_type-specific layouts. You could adopt a convention similar to how core handles CPT registration, using true to utilize sane defaults and an array to get into specifics. Following this concept, the array keys might be best named show_in_metaboxand show_in_customizer. Setting the show_in_metabox value to true would put it on all appropriate CPTs just as it does currently. Setting it to an array of slugs would relegate the layout metabox for those specific post types only. Additionally, making the list of default supported CPTs (when the meta is value is simply true) filterable would create some extreme flexibility here. Anyway, I've been going back and forth on how to best name these boolean parameters. |
Per post-type layouts would be awesome. Actually @justintadlock you read my mind with the "Category Archive Layout" below the "Global Layout". I've been trying to figure how to do that exact thing for a couple days now. Is it currently possible? |
The basic customizer stuff:
You'd need to still write custom JS to handle live preview. And, you'd need to filter |
So I'm able to remove the category layout options from global layout and posts by setting |
I'm working on allow theme authors to set which layouts they want in the customizer. The
That's fine. There's more than one way to skin a cat, as they say. |
In c8ea289, you can pass an array of layouts to the customizer control like so:
If not set, it'll fall back to all layouts. |
So my global layout is a note: I'm using |
That's a different issue. See #83. |
Hybrid Base crashes because get_post_layout() is gone. I haven't been able to follow all the details here, is there transition documentation yet? |
This is a development version of Hybrid Core. The Hybrid Base theme will be updated when Hybrid Core 3.0.0 is released. There's no documentation on new features/changes because we're not there yet. |
Is there a reason why we need to represent the "default" within the actual settings metabox? Couldn't we just eliminate this option entirely and have the "default" layout selected by default rather than including a separate option for it? The main issue I'm having with this is that there's really no good way to create an icon which represents default, so the UI ends up being extremely weird with a bunch of images and one that's text on an image... I know this is basically the same question as #45 but I think I'm still not quite understanding. I did try the |
As an update, I did just notice that it's possible to omit the image setting for default entirely, which kinda takes care of the issue... but not entirely. If you do this, then there's no indication to the user what layout is currently selected if the default is being used. Is there any way to highlight the "default" layout when none has been selected? |
One solution I have is something like the following. However, I don't like breaking up the UI like that. It doesn't feel intuitive. Another solution might be something like the "Featured Image" meta box with a "Set post layout" button/link. When clicking it, it reveals the available non-default boxes and shows the "Remove post layout" button/link underneath. Clicking the remove button would remove the selected layout and hide the choices. I'm not sure I like this other idea either because 1) it involves an additional click and 2) adds two extra text strings to the framework (something we're trying to avoid). |
Both of those seem overly complicated to me. I don't think anything really needs to be done, other than highlight the default layout. Is there a technical reason why that isn't possible? |
The problem with highlighting the default (global) layout is that we're using radio inputs. The global layout will then get stored as post meta. That's all great until the user changes their global layout. Then, we might ask ourselves what about just not saving if the post layout matches the global layout? Wait, was it the user's intent to actually choose that layout permanently for that post? There must be a way to choose "default" (i.e., no choice). |
Hmm... I see the issue, but it still feels like anything other than indicating which layout is currently in use is overly complicated from a UI point of view. Is there a way to fake out the selection? IE, make it appear selected without actually selecting it unless the user specifically chooses a layout? Would it require using something other than radio selection inputs? Some kind of JS trickery? |
I'm not really sure right now. Honestly, in the years that we've had the layouts feature I haven't had a regular user ask a support question about this. The only people talking about it are us devs. With that said, the new image-based system makes the existing issue more prominent. It might be best to just see what kind of user feedback we get. It is possible to allow a user to de-check a radio input with some custom JS. That is a possible route to take, but it's non-standard and no one would actually know how to do it without instructions. Sidenote: This is also one of the reasons I'd love to eventually get this into the customizer (on a per-post basis). |
Unless someone has a better idea, rolling it out and waiting for feedback sounds like a good plan to me. The option in the screenshot you posted seems like it's the simplest option without making any major changes. |
I think either one of the solutions you mention would work, Justin. All we can really do at this point is make assumptions about what the user's thinking. As for the link, an extra click may not be a bad thing. I sometimes wonder if the user feels like they "need" to choose a layout when I would actually prefer them to stick with the default. The standard radio does break the consistency a little but I'd be willing to bet it's more natural looking than what some theme authors may come up with to represent "default". Images of text are generally just BAD. The only "default" I can think of currently in wordpress is the color customizer control. Something like that may be a better fit aesthetically but I don't know what'd be the best way to show it active since it's pretty much just a reset button. What we're using now isn't bad or a big deal but it probably could improve. But, honestly, if this is where the "API Testing" conversation has ended up, I think it's safe to say the API is pretty solid. |
Noticed the radio buttons showing next to images a few days ago. I'm not doing a pull request since minifiers can all do things a little differently. |
It should be fixed now. For some reason, that file wasn't getting updated. I had to restart the program on my computer to get it to minify. But, yeah, never send over a minified file in a PR. That's actually a part of the new contributing guide I've added. :) https://github.com/justintadlock/hybrid-core/blob/dev/contributing.md#script-and-style-files |
How about if it uncheck layout if user click a selected layout (in meta box). to see what i mean: note: it's not using hybrid core v.3 but it's a fork of Theme Layouts in HC v.2. |
Here's on idea that I just pushed live: 9f8765b Basically, it shows the default layout as a plain text radio input if it doesn't have an image. I'd be more than happy to merge a PR or patch that allows a user to uncheck a radio input though. |
I'm not sure where to add that js code in HC v.3 I think you can use I want to use Maybe related: |
Here's a jQuery-based solution: c535fb4
I don't think you can use
It gets deleted if it's set to I figured it's best to handle that in the |
I think you are right about the infinite loop :) and I think that currently this is the best solution so far to enable user use global/default layout without complex UI. btw, if anyone need layout image (thumbnail) feel free to use mine |
not sure if you need this, the idea is to add different border color to the global layout if no layout is selected yet. so user can know the current active layout. in tamatebako i use lighter blue color. what do you think? |
@ejoweb - That was one of my proposals earlier: #103 (comment) I like what we have now though. A little JS to uncheck works fine. I haven't tested keyboard access yet. It should work the same though. |
I just want to say thanks to everyone involved with testing this and providing feedback. The overhaul of this feature is something I've been wanting to do for a long while. I feel like we're at a really good place with it right now and can close this ticket. |
Can I just clarify something: so is it intended that if user does not specifically select a layout none of the layout images are highlighted? even if a default has been specified in add_theme_support and that layout is in the list? as currently this is how it's working for me i.e. no layout highlighted for new pages added. |
Yes. |
This is something I've been wanting to do for about a year now. I wanted to pull Theme Layouts from the
/extensions
folder and integrate it more directly in the framework. I wanted to have a good, robust API for working with layouts. And, I knew that doing all that registering in theadd_theme_support()
call would get messy.If you grab the latest code, at least from commit 9b942ed, you can see the changes.
Here's the new usage:
This change will effectively fix #45 with a little code like this:
The text was updated successfully, but these errors were encountered: