As of #1787846: Themes should declare their layouts, both themes and modules have the ability to define layouts. The nitty-gritty details on how to do this are over here: http://drupal.org/node/1813372

At a high-level, a layout looks like this:

http://drupalcode.org/project/drupal.git/tree/refs/heads/8.x:/core/modul...

1) A layout.yml file that defines properties such as title and regions:

title: Two column
category: Columns: 2
template: two-col
stylesheets:
  - two-col.css
regions:
  left: 'Left side'
  right: 'Right side'

2) A layout.tpl.php file with the markup to create a layout inside:

<?php
/**
 * @file
 * Template for a 2 column layout.
 *
 * This template provides a two column display layout, with each column equal in
 * width.
 *
 * Variables:
 * - $content: An array of content, each item in the array is keyed to one
 *   region of the layout. This layout supports the following sections:
 *   - $content['left']: Content in the left column.
 *   - $content['right']: Content in the right column.
 */
?>
<div class="layout-display layout-two-col clearfix">
  <div class="layout-region layout-col-left">
    <div class="inside"><?php print $content['left']; ?></div>
  </div>

  <div class="layout-region layout-col-right">
    <div class="inside"><?php print $content['right']; ?></div>
  </div>
</div>

The goal? Make one or two of these whose markup doesn't make front-end developers want to stab their eyes out with hot pokers. :D

CommentFileSizeAuthor
#87 1814520_87.patch443 bytesseutje
#80 1814520_80.patch4.78 KBseutje
#78 1814520_78.patch4.75 KBseutje
#70 1814520_70.patch4.42 KBseutje
#70 1814520_70-floats.patch4.32 KBseutje
#67 1814520_67.patch4.41 KBseutje
#68 1814520_68.patch4.43 KBseutje
#66 1814520_66.patch4.37 KBseutje
#56 inline-block-with-sidebar.png76.97 KBAnonymous (not verified)
#56 inline-block-100%.png24.6 KBAnonymous (not verified)
#57 inline-block-full-width.png24.6 KBAnonymous (not verified)
#55 1814520_55.patch4.4 KBStalski
#48 1814520_48.patch4.41 KBStalski
#46 css_original_panel.zip674 bytesAnonymous (not verified)
#46 layout_draft_html_and_css.zip1.77 KBAnonymous (not verified)
#42 onecol.tpl_.php_.txt536 bytesAnonymous (not verified)
#42 two-col.tpl_.php_.txt651 bytesAnonymous (not verified)
#33 onecol.tpl_.php_.txt546 bytesAnonymous (not verified)
#31 two-col.tpl_.php_.patch1.5 KBAnonymous (not verified)
#31 three-col-25-50-25-stacked.tpl_.php_.patch2.84 KBAnonymous (not verified)
#28 three_col_25_50_25_stacked.tpl_.php_.txt1.29 KBAnonymous (not verified)
#28 two_col.tpl_.php_.txt662 bytesAnonymous (not verified)
#14 1814520-14.patch3.7 KBswentel
#12 1814520_12.patch2.83 KBStalski
#11 1814520_11.patch2.97 KBStalski
#3 threecol_25_50_25_stacked.png208 bytesjenlampton
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

webchick’s picture

Issue summary: View changes

Updated issue summary.

webchick’s picture

Priority: Normal » Major

And this is really a more appropriate status. We got Layout module in, but without any sample layouts because we didn't want to piss off the people working so hard in the Twig initiative to make Drupal's markup sane. :)

JohnAlbin’s picture

I really hate how clearfix is used all over Drupal's templates, but the one place it is really useful is in a layout template file. :-)

Also, <div class="inside"> is completely unnecessary. How about:

<div class="layout-FOO clearfix">
  <div class="layout-FOO--col-left">
    <?php print $content['left']; ?>
  </div>
  <div class="layout-FOO--col-right">
    <?php print $content['right']; ?>
  </div>
</div>

Personally, I would use Sass to .layout-FOO { @extend .clearfix; }, but that's a pipe dream for Drupal before code freeze.

jenlampton’s picture

FileSize
208 bytes

I'm going to paste in a more complex example layout to get some front-end eyes on this too, since the two col is fairly straightforward. This is the three-col-stacked layout

<?php
/**
 * @file
 * Template for a 3 column panel layout.
 *
 * This template provides a three column 25%-50%-25% panel display layout, with
 * additional areas for the top and the bottom.
 *
 * Variables:
 * - $id: An optional CSS id to use for the layout.
 * - $content: An array of content, each item in the array is keyed to one
 *   panel of the layout. This layout supports the following sections:
 *   - $content['top']: Content in the top row.
 *   - $content['left']: Content in the left column.
 *   - $content['middle']: Content in the middle column.
 *   - $content['right']: Content in the right column.
 *   - $content['bottom']: Content in the bottom row.
 */
?>
<div class="panel-display panel-3col-stacked clearfix" <?php if (!empty($css_id)) { print "id=\"$css_id\""; } ?>>
  <?php if ($content['top']): ?>
    <div class="panel-panel panel-col-top">
      <div class="inside"><?php print $content['top']; ?></div>
    </div>
  <?php endif ?>

  <div class="center-wrapper">
    <div class="panel-panel panel-col-first">
      <div class="inside"><?php print $content['left']; ?></div>
    </div>

    <div class="panel-panel panel-col">
      <div class="inside"><?php print $content['middle']; ?></div>
    </div>

    <div class="panel-panel panel-col-last">
      <div class="inside"><?php print $content['right']; ?></div>
    </div>
  </div>

  <?php if ($content['bottom']): ?>
    <div class="panel-panel panel-col-bottom">
      <div class="inside"><?php print $content['bottom']; ?></div>
    </div>
  <?php endif ?>
</div>
dcmouyard’s picture

Here's my recommended markup:

<div class="row cols-2">
  <div class="col">
    <?php print $content['left']; ?>
  </div>
  <div class="col">
    <?php print $content['right']; ?>
  </div>
</div>

And I would have .row and .col use the clearfix css.

pixelwhip’s picture

I agree that <div class="inside"> is unnecessary. I would also remove <div class="center-wrapper"> from around the 3 middle columns of three-col-stacked layout.

dcmouyard’s picture

Here's how I would do the more complicated layout:

<?php 
$wrapper_open = '';
$wrapper_close = '';

if (!empty($css_id)) { 
  $wrapper_open = '<div id="' . $css_id . '">';
  $wrapper_close = '</div>';
}
?>

<?php print $wrapper_open; ?>

<div class="row">
  <div class="col col-top">
    <?php print $content['top']; ?>
  </div>
</div>

<div class="row cols-3">
  <div class="col col-left">
    <?php print $content['left']; ?>
  </div>
  <div class="col col-middle">
    <?php print $content['middle']; ?>
  </div>
  <div class="col col-right">
    <?php print $content['right']; ?>
  </div>
</div>

<div class="row">
  <div class="col col-bottom"><?php print $content['bottom']; ?></div>
</div>

<?php print $wrapper_close; ?>
RobLoach’s picture

.layout-col-left doesn't quite make sense because if you're on a smaller screen, the columns would be pushed one on top of another (effectively top/bottom). Instead, it is better to think in terms of the row index in the columns.

<?php
/**
 * @file
 * Template for a 2 column layout.
 *
 * This template provides a two column display layout, with each column equal in
 * width.
 *
 * Variables:
 * - $content: An array of content, each item in the array is keyed to one
 *   region of the layout. This layout supports the following sections:
 *   - $content[0]: The content in the first grid.
 *   - $content[1]: The content in the second grid.
 */
?>
<div class="layout-row">
  <div class="layout-col-1">
    <?php print $content[0]; ?>
  </div>

  <div class="layout-col-2">
    <?php print $content[1]; ?>
  </div>
</div>

I have not doven into the depths of the Layout module yet though, so forgive me if I'm talking absolute nonsense.

How about .layout-FOO--col-right?

It's best to not prefix class names within each other as we want to re-use classes as much as possible. If you need to cherry pick, you can do so with .layout-row .layout-col-2 .

we didn't want to piss off the people working so hard in the Twig initiative

In Twig, the above may look like:

<div class="layout-row">
  {% for grid in content %}
    <div class="layout-col-{{ loop.index }}">
      {{ grid }}
    </div>
  {% endfor %}
</div>

We aren't stepping on anyone's feet here :-) . Anything accomplished in a sane way in PHP Template can be accomplished in Twig.

JohnAlbin’s picture

Just to be clear, where do these sample layouts go? (As in which directory in /core.)

webchick’s picture

Oh, sorry. /core/modules/layout/layouts/static/[layoutname]/[layoutname].yml, etc.

Stalski’s picture

Assigned: Unassigned » Stalski

I am working on this. Any feedback on how the tpl.php and css should look like, please advise!
@JohnAlbin: are you working on the html output for these simple layouts (one-col, two-col) ?

Stalski’s picture

Status: Active » Needs review
FileSize
2.97 KB

So the current patch is still a very basic one, but I wanted to get feedback by front-end people asap. So it's still possible front-end developers want to stab my eyes out with a hot poke but at the least the issue has something to talk about.
Imo the best way is to start with a one-col and a two-col, where the one-col might replace some default theming in time (E.g. render a node in node.tpl.php using the most simple $content variable).

Included changes in this patch:
- Removed "inside" and the whole div for that matter.
- Removed css file for the simple one-col layout

I do agree with Rob about the left/right being incorrect, but it's not included (yet). I wanted to check other opinions about that.

Stalski’s picture

FileSize
2.83 KB

Still css for .inside, removed that.

Status: Needs review » Needs work

The last submitted patch, 1814520_12.patch, failed testing.

swentel’s picture

Status: Needs work » Needs review
FileSize
3.7 KB

You'd think adding 2 template files wouldn't fail on tests right :)

mortendk’s picture

I dont get the Drupalistic way of overusing classnames here:

<div class="layout-display layout-two-col clearfix">
  <div class="layout-region layout-col-left">
    <?php print $content['left']; ?>
  </div>

  <div class="layout-region layout-col-right">
    <?php print $content['right']; ?>
  </div>
</div>

Lets clean it up:

<div class="layout-two-col">
	<div class="layout-col-left">
		<?php print $content['left']; ?>
	</div>

	<div class="layout-col-right">
		<?php print $content['right']; ?>
	</div>
</div>

.clearfix:
Must die simple as that we dont wanna carry this techneque around at our baselayout element - the problem is that were carying around clearfix - that remove the ability to float to layouts unless we nest them in more divs (if theres a need for a deeper explenation for this i will provide it)

.layout-display?
So what does this class tells us - that its a display? We already know that by the layout-two-col class. No reason for this kinda hook thinking :)

.layout-region?
yeah its a region but we know that based on the layout-col-left class

dasjo’s picture

.layout-col-left doesn't quite make sense because if you're on a smaller screen, the columns would be pushed one on top of another (effectively top/bottom). Instead, it is better to think in terms of the row index in the columns.

i'd also like to avoid column names like left & right but give them indices that reflect their (mobile-first) content hierarchy.

that's maybe more for semantic css purists but with css preprocessors i think this will sooner or later become a best-practice in frontend development. that for example makes it possible to swap layouts based on the same markup.

say you have

  <div class="layout-two-col">
    <div class="layout-col-first">
       <?php print $content['first']; ?>
    </div>
    <div class="layout-col-second">
       <?php print $content['second']; ?>
    </div>
  </div>

an example based on the Susy grid that allows you to easily switch the column layout.

first = left & second = right:

@media (min-width: 30em) {
  .layout-col-first {
    @include span-columns(12);
  }
  .layout-col-second {
    @include span-columns(12 omega);
  }
}

first = right & second = left:

@media (min-width: 30em) {
  .layout-col-first {
    @include span-columns(12 omega);
  }
  .layout-col-second {
    @include span-columns(12);
  }
}

this should illustrate my opinion that i'd like to avoid layout-based css classes like left, right, grid-x and stick to semantic ones like col-first. the actual layout definition (left, right, ...) lives in the css. using a preprocessor like Sass makes it a lot more maintainable.

i don't want to derail this issue on whether or not to use a css preprocessor. that discussion lives here: #1310698: Add a CSS preprocessor library to core
just wanted to advocate for semantic class naming :)

Gábor Hojtsy’s picture

@mortendk: of course the .layout-region and .layout-display kind of general classes are there to let CSS apply to generally all regions/displays. If we assume we don't need that and/or that any such CSS would need to hunt down and list all possible regions/displays it would ever apply to (which given contrib modules might be a pretty tall order), then they are just cruft. Otherwise, they might have some use. What is your alternative for a contrib module? "Do not mess with my layout?".

seutje’s picture

it makes more sense to keep the layout-region class than to keep the layout-col-first & layout-col-second classes.
so you don't have to do this when styling all layout regions:

.layout-col-first,
.layout-col-second,
.layout-col-third,
.layout-col-fourth,
...
.layout-col-twelve { ... }

instead of just

.layout-region { ... }

I suppose the same thing goes for the wrapper, I would rather not be forced to:

.layout-two-col,
.layout-three-col,
.layout-fourt-col,
...
.layout-twelve-col { ... }

when I really just want to

.layout-display { ... }

But of course, we need a way to distinguish them, and since IE8 is still incapable of doing proper nth-child selectors and (virtually) no browser has already implemented parent selectors, it makes sense to keep both.

It would make it really trivial to say, for instance, every layout gets a white bg, grey border and a bit of padding, and every first column gets a grey right border:

.layout-display {
  background-color: grey;
  border: 1px solid grey;
  padding: 0 15px;
}
.layout-region {
  padding: 15px 0;
}
.layout-col-first {
  border-right: 1px solid grey;
}

(I know I could use .layout-region:first-child but that wouldn't work if I wanted to target the second column, and in IE8 this would require awkwardness in the form of .layout-region:first-child + .layout-region, hence why .layout-col-second would be needed)

I do, however, want to propose changing layout-region to layout-col

Stalski’s picture

1) Extra classes: I would prefer those two classes as they exist now. We (can) use them both, depends on how you want to theme. Basically I use them both, depending on the use case and where the re-use is important.
2) .clearfix: I am in favor in clearfix here but a solution where this won't be needed is necessary to continue. Also there needs to be consensus here . it's hard to tell what *most* front-end people want.
3) Left/right naming of regions: Well, this is fully correct that in responsive layouts this does not make sense. However, another issue is also trying to get region-roles in. Short this means that when changing a layout with the need to move content from one region to another layout, these region roles could help to determine that left and right are "sidebar regions" and thus have a bit of AI on this matter. So this is going to be a hard one. We need consensus about this and make one *best* decision

seutje’s picture

Personally, I try to refrain from using floats nowadays, considering we only support IE8 and up, can't we just use inline-block, like this for instance: http://dabblet.com/gist/3931796

mortendk’s picture

.clearfix is one of the finale bastards of browser hell drupal chosed to use clearfix very heavy "ooh its a box it needs a clearfix" kinda aproach, its a techneque that was forced on us during the evil days of ie7 (which we dont support) Inline-block would be the way to go

What we use as names is for not so much the "semantic" correct value, its more importent that it has a relevanse to its naming if the field

  <div class="layout-col-whateveritscalled">
       <?php print $content['whateveritscalled']; ?>
    </div>

gabor i would prefer a soulution where core does as little as possible, so if a theme needs something, eater a basetheme could take care of business or the themer adds in his prefered classes for whatever css framework thats possible in use for that theme

Stalski’s picture

Correct (although your description is a little different from what I had in mind, like "panels work with floats, thus a .clearfix is helpfull ;) )

So the inlineblock is good? one time, second time, sold.

About classes, I still think we need both. It's no go imo to expect that *most* cases need an override for consistent theming.
Ofcourse as little as possible as you said.

Crell’s picture

The problem of targeting "all layouts" or "just these layouts", and wanting to be able to do both without having to modify templates, is legit. Plus, layouts have to ship "functional" out of the box. They cannot ship in a fashion that requires a themer for them to be useful. That simply will not fly.

Double redundant classes is what we've had to do in the past, but we have two and a half fewer crap browsers to deal with now so that opens up more options.

What about dobule-class CSS rules? Eg:

<div class="layout two-col">
...
</div>
div.layout {
  /* Rules for all layouts */
}
div.layout.two-col {
  /* Rules for just the two-col layout */
}

There may be other side-effects there, and I'm totally flexible on the class names, but I've never really understood why people don't make more use of multi-class CSS rules. I rarely see it in the wild myself. Perhaps there is a good reason that I don't understand, in which case please enlighten me, but it's at least an idea that I haven't seen explored much.

Stalski’s picture

I fully agree that layouts should be usable and functional on first use. I think that's one of the main reasons this issue is for the 2 most basic layouts only.

About the double css classes, we use it a lot actually :) . Especially in cases where you need to do something like .row.status . That is not something you would do often in this case imo.

seutje’s picture

@#23: main reason you don't see them in the wild that often is because IE7 (and lower) created the habit, since it didn't work. It also increases specificity, although that shouldn't be a problem in our case. I'm all for it, but we need to make sure these classes don't conflict with popular 3rd party libraries/plugins/whatnots.

Anonymous’s picture

Just to jump in, and give some feedback and ideas.

#15 +1
#16 +1

#23

The problem of targeting "all layouts" or "just these layouts", and wanting to be able to do both without having to modify templates, is legit.

Well, what about something like this for the more complex layout in #3?

@webchick
Are you just looking for a fixed layout or is a dynamic layout allowed? The example below could solve some of the need for manually making different tpl.php files, as well as give front-end developers some layouts to choose from out of the box.

The code below would allow for multiple layouts with optional top (with multiple columns), middle (with multiple columns), bottom (with multiple columns). Basically what it will do is print 'containers' dynamically based on the panel content. It prints a wrapper div for top, middle, and bottom. Each top, middle, and bottom wrapper can have classes added through the panels admin (which is the case now in panels) or that could be fixed as well if that is the preferred way to go. For each container it prints a generic container class, a preset class, and a class specific for that container based on the id of the panel content container.

One could read/ write the layout from/ to the .yml and tpl.php for the panel. It could have save/ select/ import/ export functionality.

Please don't mind the variable naming, it's a mockup. I settled on panel for the panel, and containers for the inside. The variables could be changed to fit the Drupal Twig variables.

Working from the more complex layout example in #3:

<?php
/**
* @file
* Template for a column panel layout with optional top, middle, and bottom panels.
* This template provides a variable column panel display layout.
*/
?>
<div class="panel-wrapper <?php if (!empty($css_class)) { print $css_class; } ?>">

<?php if ($container_top) : ?>
     
       <div class="panel-top-wrapper">	
	
	<?php foreach($container_top as $container) :
     
	    $build_container  = '<div class="container' . $container->preset . 'top-' . $container->cid .'">';
  	  $build_container .= $container->content; 
   	 $build_container .= '</div>';
        print $build_container;
	
	    endif; ?> 
    
       </div>	

<?php endif; ?>
 

<?php if ($container_middle) : ?>

	<div class="panel-middle-wrapper">
	
		<?php foreach($container_middle as $container) :
      
	    $build_container  = '<div class="container' . $container->preset . 'middle-' . $container->cid .'">';
	    $build_container .= $container->content;
	    $build_container .= '</div>';
        print $build_container;

		endif; ?>

	</div>

<?php endif; ?>

	
<?php if ($container_bottom) : ?>

	<div class="panel-bottom-wrapper">
	
		<?php foreach($container_bottom as $container) :
      
	     $build_container  = '<div class="container' . $container->preset . 'bottom-' . $container->cid .'">';
	     $build_container .= $container->content;
	     $build_container .= '</div>';
         print $build_container;

		endif; ?>

	</div>

<?php endif; ?>

(p.s. The comment section seems to mess up the layout of the code don't know why and can't get it fixed.)

The preset functionality of the containers will allow for standard layouts e.g:
left right for a 2 column layout
left middle right for a 3 column layout

(#18) It may better to do the wrapper's in id's, with this mockup considered that there could be more than one panel layout on one page, that would possibly need some rewriting, because I don't the know the div layout that would come before that. If that has a (unique) id, then that could be used.

For example for multiple image galleries on one page:


<div id="page"> 
/// The first panel layout
<div class="panel-wrapper gallery flower-photos">
</div>
// The second panel layout
<div class="panel-wrapper gallery flower-paintings">
</div>

Can't think of a layout you couldn't do with this if you figure in blocks.

edward_or’s picture

+1 for not just just having a single class name on the outer layout div (like in #23)

There are instances when it would be good to be able to target all layouts (.layout) with some properties. Setting them to display: flex or apply clearfix classes or something like that.

Anonymous’s picture

Let's get some productive activity going on this, and get this wrapped up. We have been moaning and complaining about this a long time, and now that we get the opportunity to get some input we shouldn't let that go to waste.

Here are some fixed layouts for the two examples given, in addition to the earlier dynamic one.

Working from the comments above.

I've opted for the top-wrapper, center-wrapper, bottom-wrapper naming convention instead row-1, row-2, as I felt this described the area a little better, also is already used in themes in Drupal. Also row-1, row-2, etc is something I relate more to tables than to divs. However, it isn't written in stone.

Use col 1, col 2, etc for the columns this to keep account for responsive layouts. Each column has a general column class to allow for styling all the columns the same (for a panel).

Besides a optional custom id, it would be nice to be be able to add a custom class. This in case there are multiple panels on a page and you can't use an id, and you want to apply custom styling to different panels. Should this be done (in part) from the layout admin, or should this be added in the layout itself? For example:

Option 1
All dynamic attributes

<div <?php if (!empty($css_id)) { print "id=\"$css_id\""; } ?>  <?php if (!empty($css_class)) { print "id=\"$css_class\""; } ?>">

Option 2
Dynamic id and class attributes, besides standard layout class attribute

<div <?php if (!empty($css_id)) { print "id=\"$css_id\""; } ?>  class="layout-two-col <?php if (!empty($css_class)) { print $css_class; } ?>">

Option 3
Manually added id and class attributes

<div id="custom_id"  class="custom_class layout-two-col">

Template Proposals

Template proposal for a 2 column layout:

<?php
/**
* @file
* Template for a 2 column layout.
*
* This template provides a two column display layout, with each column equal in
* width.
*
* Variables:
* - $content: An array of content, each item in the array is keyed to one
*   region of the layout. This layout supports the following sections:
*   - $content['left']: Content in the left column.
*   - $content['right']: Content in the right column.
*/
?>
<div <?php if (!empty($css_id)) { print "id=\"$css_id\""; } ?>  class="layout-two-col">
  <div class="column col-1">
    <?php print $content['left']; ?>
  </div>

  <div class="column col-2">
    <?php print $content['right']; ?>
  </div>
</div>

Template proposal for a 3 column panel layout:

<?php
/**
* @file
* Template for a 3 column panel layout.
*
* This template provides a three column 25%-50%-25% panel display layout, with
* additional areas for the top and the bottom.
*
* Variables:
* - $id: An optional CSS id to use for the layout.
* - $content: An array of content, each item in the array is keyed to one
*   panel of the layout. This layout supports the following sections:
*   - $content['top']: Content in the top row.
*   - $content['left']: Content in the left column.
*   - $content['middle']: Content in the middle column.
*   - $content['right']: Content in the right column.
*   - $content['bottom']: Content in the bottom row.
*/
?>
<div <?php if (!empty($css_id)) { print "id=\"$css_id\""; } ?> class="layout-3col-stacked" >
  <?php if ($content['top']): ?>
    <div class="top-wrapper">
      <?php print $content['top']; ?>
    </div>
  <?php endif ?>

  <div class="center-wrapper">
    <div class="column col-1">
      <?php print $content['left']; ?>
    </div>

    <div class="column col-2">
      <?php print $content['middle']; ?>
    </div>

    <div class="column col-3">
      <<?php print $content['right']; ?>
    </div>
  </div>

  <?php if ($content['bottom']): ?>
    <div class="bottom-wrapper">
      <?php print $content['bottom']; ?>
    </div>
  <?php endif ?>
</div>

.YML files can stay the same?

CSS needs to be done, but until a layout is decided upon it would be pretty much a waste of time to write those now, as things can still change.

The files are attached. For those that want to write a patch after review, it would be really helpful. :-)
(I don't have a clue on how to write a patch).

cweagans’s picture

@DesignDolphin, There's a Doc Page for That™: http://drupal.org/patch

The code looks good after a cursory glance, but I don't pretend to be a frontend developer, so I will abstain from further comment.

Stalski’s picture

I will create a patch tonight.

I just can't figure out why we are still talking about a 3 cols if the plan for this issue is the most simple 1col and 2col. Correct me if I am wrong.
Every layout should be a encapsuled piece of functionality and so that's it is ready to use.

Anonymous’s picture

Patched files for #28 attached.

@cweagans,

Thanx :-) Last time I tried using the doc pages got stuck. Gave it another go and managed to figure it out using diffutils and a tutorial, but don't want to go to much off-topic.

Status: Needs review » Needs work

The last submitted patch, three-col-25-50-25-stacked.tpl_.php_.patch, failed testing.

Anonymous’s picture

FileSize
546 bytes

O.k. I don't know why the patch is failing. Followed the instructions, apparently missed something. Maybe better for this topic if someone else with more experience patches. If someone wants to clue me through p.b. I'd appreciate it. :-)

@Stalski,

We posted at the same time.
As far as I know from op there wasn't a definition for which one:

The goal? Make one or two of these

In #3 there was a request for a more complex layout, or did I misunderstand something?

It's good that you mention it though.

In any case, to have all the bases covered for now, here is a proposal for a one column layout.
File for this is attached at the bottom.

<?php
/**
 * @file
 * Template for a 1 column panel layout.
 *
 * This template provides a very simple "one column" panel display layout.
 *
 * Variables:
 * - $id: An optional CSS id to use for the layout.
 * - $content: An array of content, each item in the array is keyed to one
 *   panel of the layout. This layout supports the following sections:
 *   $content['middle']: The only panel in the layout.
 */
?>
<div <?php if (!empty($css_id)) { print "id=\"$css_id\""; } ?> class="layout-one-col">
  <?php print $content['middle']; ?>
</div>

Maybe it is better to discuss somewhere which ones to put in before we continue? This so that we have a set parameter, and don't waste any time writing tpl's. Because I'm getting confused...

EclipseGc’s picture

We should likely spend some effort here just attempting to support a drupal_attributes() attributes object. When this moves to twig that should be super standard anyway, and it should also be very very doable now.

Eclipse

webchick’s picture

Title: Create 2 sample layouts » Create 2 basic sample layouts: 1-col and 2-col

Going to clarify the scope of this issue a little bit, which has drifted since when it was created.

So the reason Stalski is taking this patch on is because he needs some simple layouts to proceed on Field UI refactoring. And I see the discussion in here going into more complex layouts (great!), dynamic layouts (even better!), etc. but I think if we try and tackle all of this in the first patch, it's going to be February by the time we have any layouts that Field UI / page builder / etc. can build from. :)

So I think I'd like to limit the scope of this issue to just getting the basic 1-col and 2-col layouts that were part of the original issue to "non-themer-stabby" levels of markup, and get those committed as soon as we can, so we can unblock other efforts. But the other discussion in this issue is really good, so let's open a follow-up for "Add a standard header / 2 sidebar / footer layout to Layout module," or similar, to hone in on those larger questions and try and cook up a third layout that we can add later when it's ready.

Anonymous’s picture

Title: Create 2 basic sample layouts: 1-col and 2-col » Create 2 sample layouts

#34

Would you mind linking to some documentation on that, or explain in easy to understand language what you mean?

From what I understand from docs you mean something like this?

<?php

$options['attributes']['id']
$options['attributes']['class']

?>

Which would translate to something like {{ attributes }}?

So the one column layout would look something like this then?

<?php
/**
* @file
* Template for a 1 column panel layout.
*
* This template provides a very simple "one column" panel display layout.
*
* Variables:
* - {{ attributes }} the id or class of the wrapper div
* - $content: An array of content, each item in the array is keyed to one
*   panel of the layout. This layout supports the following sections:
*   $content['middle']: The only panel in the layout.
*/
?>
<div {{ attributes }} >
    <?php // Needs to be translated to Twig 
          print $content['middle']; 
     ?>
</div>

As long as the attributes are easy to set I think that is a good idea, and could be a good solution. With emphasis on the easy to set part for people with a low level of coding knowledge. You shouldn't need a PHP degree to set the attributes for a div. Don't want to make it anymore complicated than it needs to be. Also be a good idea to let people know in the top of the file where they can set this then, or include this in the Theming documentation. (Not sure if this is the best place to discuss that in depth?)

It would solve that point, and we could check that off, and move on.

Edit:

#35 +1 Sounds like a good idea.

webchick’s picture

Title: Create 2 sample layouts » Create 2 basic sample layouts: 1-col and 2-col

Oops, reverting cross-post title change.

DesignDolphin, would you be able to create the "Fancy layouts" issue? :)

Anonymous’s picture

Oops, sorry @webchick, we posted at the same time, and it changed the title back by accident.
Changed it back for you.

Edit:
#37
Wouldn't know where to start with a new issue, and I'm also limited in my time unfortunately.

EclipseGc’s picture

I think the twig version would look something like:

<div {{ attributes }} >{{ content.middle }}</div>

So attributes objects are just an improvement over the oldschool attributes array we've had in previous versions of Drupal. You can continue to treat it like an array (don't worry about it, you just can). So any html supported key value pair will just render out of it by doing the {{ attributes }} thing. That would support id, class, rel, whatever.

That would just change the theme hook so that it takes an attributes variable in addition to the content one.

Anonymous’s picture

So attributes objects are just an improvement over the oldschool attributes array we've had in previous versions of Drupal. You can continue to treat it like an array (don't worry about it, you just can). So any html supported key value pair will just render out of it by doing the {{ attributes }} thing. That would support id, class, rel, whatever.

That would just change the theme hook so that it takes an attributes variable in addition to the content one.

o.k., good that you wrote it down like that, because that is the part where you lose me, and other people as well that don't know PHP (that well). If it is documented how to do what you suggest step by step, and 'it just works', then I'm fine with it. Otherwise I foresee some people ripping out the {{ attributes }} part, and just adding hard coded attributes instead. Which some people may do anyway, because they want to style only that section, and don't feel like learning the whole thing behind it, or feel it's too complicated. Using the {{ attributes }} if there is no dynamic part behind it (e.g. gui to fill those values) may just be an unnecessary complication where hard coded attributes would suffice. I may judge that wrong, and other front-end developers may have another opinion though.

Anonymous’s picture

Looking at #39 and #40. You know what, let's focus on the mission at hand. Let's do the HTML the hard coded way first. We can add 'optional_custom_id' and 'optional_custom_class' where the need is to be able to add a custom id or class, and then in a follow up issues translate this to Twig, and how to add those attributes dynamically. We can sign off on these then, and do the CSS for these two templates. Then we have two templates which are ready for dynamizing. :-)

Template proposal for a 1 column layout

<?php
/**
 * @file
 * Template for a 1 column panel layout.
 *
 * This template provides a very simple "one column" panel display layout.
 *
 * Variables:
 * - $id: An optional CSS id to use for the layout.
 * - $content: An array of content, each item in the array is keyed to one
 *   panel of the layout. This layout supports the following sections:
 *   $content['middle']: The only panel in the layout.
 */
?>
<div id="optional_custom_id" class="layout-one-col optional_custom_classes">
  <?php print $content['middle']; ?>
</div>

Template proposal for a 2 column layout

<?php
/**
* @file
* Template for a 2 column layout.
*
* This template provides a two column display layout, with each column equal in
* width.
*
* Variables:
* - $content: An array of content, each item in the array is keyed to one
*   region of the layout. This layout supports the following sections:
*   - $content['left']: Content in the left column.
*   - $content['right']: Content in the right column.
*/
?>
<div id="optional_custom_id" class="layout-two-col optional_custom_classes">
  <div class="column col-1">
    <?php print $content['left']; ?>
  </div>

  <div class="column col-2">
    <?php print $content['right']; ?>
  </div>
</div>
Anonymous’s picture

FileSize
651 bytes
536 bytes

The files for #41.

(forgot to add)

dcmouyard’s picture

I think we should check if the attributes object actually contains attributes before printing out the wrapper. That will cut down on divitis.

effulgentsia’s picture

I think we should check if the attributes object actually contains attributes before printing out the wrapper. That will cut down on divitis.

What that would mean though is that whether the DIV is there or not depends on which modules you have enabled. For example, let's say with a minimal set of modules there's no attributes, but then turn RDF module on, and suddenly there's attributes. Is DIVs appearing or not in this way based on module state better or worse than a DIV always there, sometimes without attributes?

dcmouyard’s picture

What that would mean though is that whether the DIV is there or not depends on which modules you have enabled. For example, let's say with a minimal set of modules there's no attributes, but then turn RDF module on, and suddenly there's attributes. Is DIVs appearing or not in this way based on module state better or worse than a DIV always there, sometimes without attributes?

In my opinion, as long as checking the attributes object does not negatively impact performance, then having wrapper DIVs appear based on what attributes modules & themes have added is better than always outputting that wrapper DIV.

Anonymous’s picture

Lorem Ipsum HTML files and first draft CSS for the 1 and 2 column layout.

Please find attached below Lorem Ipsum HTML files, and a first draft for the CSS for code port, browser design and testing. I've added the original panel CSS as well. I've added them in a ZIP file so that everybody regardless of operating system should be able to have access to it, also I can't attach HTML and CSS files without renaming them to a .txt extension, so this should save people some work. This way everybody will be able to work with the files, which the dynamic stuff can then be added too.

The HTML files are really simple files meant to work on the div's, don't worry about p tags at this point.
The new CSS code is just a first draft, to start porting some stuff such as attribute names. It needs to be checked, and further worked on. This is dependent on how the HTML layout will look, so until that is done don't spend too much time on layouting the CSS. Otherwise you may have to do the work again if the HTML layout changes.

There is some stuff in the old CSS code that may need special attention (which may need the input from someone with more Drupal experience):

In the one column layout CSS:

/* What is this stuff for, and does it need to be renamed? */

#panels-edit-display .panel-pane,
#panels-edit-display .helperclass {
  margin: .5em;
}

/*
Why is there panel-2col in the 1 col CSS ? 
What is this stuff for, and does it need to be renamed? */

.panel-2col .panel-separator {
  margin: 0 0 1em 0;
}

In the two column layout CSS:

/* What is this stuff for, and does it need to be renamed? */

#panels-edit-display .panel-pane,
#panels-edit-display .helperclass {
  margin: .5em;
}

/* What is this stuff for, and does it need to be renamed? */

.panel-2col .panel-separator {
  margin: 0 0 1em 0;
}

For the two column layout which way should we do the CSS for the columns?:

Option 1:

.layout-two-col .column { 
  float: left; 
  width: 49%;
  margin: 0 .5em 1em 0; 
}

Option 2:

.layout-two-col .col-1, .layout-two-col .col-2 { 
  float: left; 
  width: 49%;
  margin: 0 .5em 1em 0; 
}

Option 3:

.layout-two-col .col-1 { 
  float: left; 
  width: 49%;
  margin: 0 .5em 1em 0; 
}

.layout-two-col .col-2 { 
  float: left; 
  width: 49%;
  margin: 0 .5em 1em 0; 
}

Do we want the margin there (or use padding instead)? Are these the margin sizes we should use?

Last, but not least. There is this in the old two column CSS, one for each column:

.panel-2col .panel-col-first { 
  float: left; 
  width: 50%; 
}

* html .panel-2col .panel-col-first {
  width: 49.9%;
}

Which I'm not sure why it is there. To tell you the truth I've never seen it done like this, and I'm not sure both are needed. If I may ask, what is the reason for adding this? Cross-browser issues?

#43

+1
I agree that div's should not be showing if they are empty.

seutje’s picture

iirc, * html is a CSS hack for IE6 and below, so I'm pretty sure we can do without that.

the way panels does its layouts is have 2 outer wrappers (for 2col) on 50% width and both have an inner wrapper with margin
the panel-separator thingies are just silly and I've never understood why it was done that way

having a width relative to the wrapper width but have margins relative to the font-size kind of spells out disaster for me, seems a lot more interesting to use padding and box-sizing instead

Stalski’s picture

Status: Needs work » Needs review
FileSize
4.41 KB

Attached the patch with:

  • Floats replaced by inline-blocks (as seutje indicated)
  • Left, right have been replaced by one and two (most people voted that way)
  • Added two col integration for smaller devices (taken from panopoly)
  • Added attributes integration (but the same as with layouts itself, nothing yet to actually use it)

Also two classes since they both can and will be useful.

dcmouyard’s picture

For the one column layout, we don't need any wrapping divs unless a theme or module adds an ID or class to the outer wrapper; just output the content.

For the responsiveness of the two column layout, shouldn't we use the breakpoint module to make it configurable for where it switches from one column to two?

effulgentsia’s picture

shouldn't we use the breakpoint module to make it configurable for where it switches from one column to two?

Let's please defer that to a follow up. Our existing themes still hard-code their breakpoints in the CSS file, and figuring out the right way to generate CSS from user-configured breakpoints is a meaty enough discussion to warrant its own issue.

Stalski’s picture

For the one column layout, we don't need any wrapping divs unless a theme or module adds an ID or class to the outer wrapper; just output the content.

The reason why I did not use the optional div is for consistency. In our opinion consistency is more important. See following reasoning:
- If you don't need a wrapper for the one col, why should we "decide" we DO need one for the 2 col layout.
- If you want to style consistently you would need to look up and inspect every time. Also if you do need a wrapper you would need to override the template or define your own layout. (the wrapper div only showing up when a class is defined is no good imo, the assumption is something lots of people will miss).

So, something like a border around all layouts make sure we need the wrapper with the layout class.
Common styling on the regions says we need that region wrappers with their classes.

Besides, don't forget if you really want to strip out the outer div or do some logic (if there are attributes ...) you can still define your own layout or even better, just override the tpl in your theme. And in some cases you'll want to override all core layouts ... so be it. That's what it's there for.

Anonymous’s picture

#47,

iirc, * html is a CSS hack for IE6 and below, so I'm pretty sure we can do without that.

From what I understand Drupal 8 won't support IE6 (or IE7), but this needs confirmation. If IE6 is the reason it is being used, than I agree that it can be scrapped if IE6 is no longer supported with Drupal.

Reviewing the patch in #48:

  1. If using block instead of float is 'clearfix' still needed?
  2. Should clearfix, like margin and padding, be something that is left up to the individual theme. Providing a clear slate with two columns. It would remove (some of the) the necessity to do CSS overrides, adding clean CSS instead. (In the end though if everything is cleaned up, like it is now, then I could live with clearfix, if it provides an overall solution for a problem, and makes life easier.)
  3. What's the reasoning for using a - negative margin in the two-col.css in layout-two-col .layout-region?
  4. What is the reasoning behind using 'vertical-align: top' in the two-col.css layout-two-col .layout-region?
  5. With the whitespace issue which the patch also suffers from, and float being generally accepted, would the use of floats be preferred in this case?
  6. For example:

    .layout-two-col .layout-region   {
        float:left
        width: 50%;
    }
    

    With a standard padding of 20px:

    .layout-two-col .layout-region {
        float:left;
        width: 47.917%;
        padding: 20px;
    }
    

    (Please note: examples above need complete cross-browser testing for this use case before use).

  7. I haven't tested or used this broadly. Another way to go may be to use max-width and pixels. Which in Firefox in any case gets rid of the need for a special style for mobile (would need cross browser testing), is lean code, makes for easier calculation of the padding and margin in px, gets away from using percentages (which can be tricky). There may be other issues with this, though, but as we don't have to account for IE6 (max-width was introduced in IE7) this may be a solution... Throwing it into the mix so we have all bases covered on this, but not sure what to do with it.
  8. For example:

    .layout-two-col {
        max-width: 600px;
    }
    
    .layout-two-col .layout-region {
        float:left;
        max-width: 260px;
        padding: 20px;
    }
    
  9. As we're using 'one-col' and 'two-col' naming convention in all the other parts of the layout. Instead of naming the divs 'layout-col-first' and 'layout-col-second' naming the divs 'layout-col-one' and 'layout-col-two', may be more consistent. (While first and second has a case for being easier to read, on the next level, and may avoid some confusion.)
  10. There was no one-col.css included as far as I can see. Does this mean there won't be one?

That's all I could think off, but please do doublecheck as I may have missed something accidentally.

edward_or’s picture

iirc, * html is a CSS hack for IE6 and below, so I'm pretty sure we can do without that.

That is right. * html is so the style gets applied to IE6 and bellow only. See http://paulirish.com/2009/browser-specific-css-hacks/

dcmouyard’s picture

Besides, don't forget if you really want to strip out the outer div or do some logic (if there are attributes ...) you can still define your own layout or even better, just override the tpl in your theme. And in some cases you'll want to override all core layouts ... so be it. That's what it's there for.

If we check the attributes object before outputting wrapper divs, then someone doesn't need to override the template in their theme to get rid of divitis, they can just alter the attributes object.

For responsive layouts we should be styling the mobile layout first, then use min-width media queries to adjust the layout as the screen gets wider. And those media queries should be using em instead of px.

If using block instead of float is 'clearfix' still needed?

I believe we're using inline-block, and clearfix is only needed if we're floating stuff inside.

What's the reasoning for using a - negative margin in the two-col.css in layout-two-col .layout-region? With the whitespace issue which the patch also suffers from, and float being generally accepted, would the use of floats be preferred in this case?

The negative margin fixes the white-space issue. I recommend using inline-block instead of floats whenever possible since we're not coddling Internet Explorer anymore.

Another way to go may be to use max-width and pixels.

The problem with using max-width on column widths is that we want those columns to be 100% wide until it switches to two columns.

Stalski’s picture

FileSize
4.4 KB

Removed redundant clearfix, we don't need that at all

explanations for @DesignDolphin:
- negative margin are needed since the two boxes of 50% width are too wide to fit in 100% width. That's how it works with inline-blocks (see code of seutje in #20)
- vertical align: See http://www.impressivewebs.com/css-vertical-align/

There was no one-col.css included as far as I can see.

You did not mention why you specifically want one, so I don't understand why it should be changed. I did not see any use for it ...

I also see no extra consistency in using one/two. As you said first , second is more readable so now it's consistent AND readable.

Anonymous’s picture

Reviewing #55

- negative margin are needed since the two boxes of 50% width are too wide to fit in 100% width. That's how it works with inline-blocks (see code of seutje in #20)
- vertical align: See http://www.impressivewebs.com/css-vertical-align/

O.k., using the code from the patch at least in Firefox this layout using inline:block gives problems for me when testing. Please see attached screenshots.

With a sidebar on the left, the inline:block div moves over the sidebar div. The layout-regions show below each other and not next to each other. With no sidebar, the content moves off of the screen on the left and creates a gap on the right, while the layout-regions are shown next to each other. Can anyone duplicate this result, or am I overlooking something/ patched something incorrect?

HTML Code used for sidebar:

<div id="sidebar">
   ...
</div>

<div class="layout-display layout-two-col">
   
    <div class="layout-region layout-col-first">
	...			
    </div>
    
    <div class="layout-region layout-col-second">
	...
    </div>

</div>

CSS code used for sidebar:

#sidebar { 
    width:200px;
    float:left;
    background: #ccc
}

.layout-two-col {
    width:100%;
}

.layout-two-col .layout-region {
     vertical-align: top;
     margin-left: -.25em;
     display: inline-block;
     width: 50%;
     background: yellow
}
You did not mention why you specifically want one, so I don't understand why it should be changed.

It was there in the original file. Just to make sure we are not missing any steps during the process: the container div in one-col needs to be set to 100%, doesn't it though? Won't otherwise the change exist that the div doesn't fill to the div around it?

Anonymous’s picture

FileSize
24.6 KB

Please disregard inline-block-100%.png in previous post.
See inline-block-full-width.png instead atttached to this post.

(Renaming of attached image inline-block-100%.png to inline-block-full-width.png, as
Drupal has problems reading the file.)

Stalski’s picture

@DesignDolphin: maybe you can remove the irrelevant comments then. It gives a lot clutter and even me doesn't understand it anymore. Also please note that at the end we all need a solution together. I still don't know what I should do regarding your remarks.

Anonymous’s picture

@Stalski

I don't waste time writing irrelevant comments... ;-) (well in my perception anyway ;p)

You're not the only one getting confused....

I agree with finding a solution together. :-)

Which part don't you understand?

Short and sweet summary: the inline:block code is giving layout problems in Firefox. Needs further cross-browser testing to see if problem occurs in other browsers. Propose to use float instead, unless inline:block issues can be resolved.

In Dutch/ Belgium speak:
De inline:block code veroorzaakt problemen met de layout (in Firefox). Dit ga nie werken zo.

seutje’s picture

The negative margin is needed because when using inline-block, the spaces in the markup matter (as they would with a <a> within a <p>

possible solutions include:

  1. get rid of whitespace in the markup
  2. use negative margins, but I guess they'd have to be relative as you're trying to match the width of a space character
  3. set font-size to 0 on the wrapper and reset it on the columns
  4. don't use inline-block and use floats instead, which would need a clearfix on the wrapper

see http://css-tricks.com/fighting-the-space-between-inline-block-elements/

I've been using this in production for sites where we don't support IE7, and I usually go with the 3rd solution (font-size: 0 on the wrapper), but that's because I have full control over everything, not sure if it's viable for core to go with this solution.

gausarts’s picture

Regarding CSS for those columns, have you thought of using CSS table-related values: table, table-row, and table-cell? You can read more about it here:
http://www.digital-web.com/articles/everything_you_know_about_CSS_Is_wrong/

The good thing about CSS table is no matter how many columns, they will just fit into the container.
This will save lots of codes. Rather than defining different width for different columns, you can simply ignore all widths, and the column will grow and shrink to the container. As a bonus, no clearfix, no issue with whitespaces, and most of all equal height columns for free.

Seeing the HTML from https://drupal.org/files/1814520_48.patch, I think this will do, not tested though:

.layout-display {
  display: table;
  width: 100%;
  border-collapse:separate;
  border-spacing: 0; /*Add some spacing if .layout-region wants margin or has background color*/
  table-layout: fixed;
}

.layout-region {
  display: table-cell;
  vertical-align:top;
  padding: 0 1.25em;
}

You don't care how many columns are defined, those CSS will just work, even when only one.

Anonymous’s picture

#61

Interesting. Definitely worth considering. The example is using pixels. Do you have a working example using percentages for the two-col layout? It would help with testing. The method you propose has some clear advantages.

Some point of concerns with the proposed solution:

1. As mentioned in the article:

Of course, we should also take care not to use display: table; on a bunch of div elements when what we really have is tabular data!

2. When different parts of the layout are using CSS tables can they conflict with each other? For example can a CSS table be placed in a CSS table-cell? That would be good information to have when considering this.

3. 'Anonymous Table Elements'. Need to find out if these are rendered empty in source code, or not shown at all (but interpreted by browser). Also if we are getting a lot of invisible code, and whether that balances out.

I read your comment when I was going to post the code below. I'm going to look at the table thing because it is interesting and looks promising, in the meantime posting this as well, as it may work.

This is another option using position: absolute and position: relative that may work. It is proving to be quite flexible in Firefox so far e.g. no issues with padding, adding a sidebar, resizes on browser within what I've tested. Needs (cross-browser) testing.

.layout-two-col {
	position:relative;
	width: 100%
}

.layout-two-col .layout-region { 
	position:absolute;	
	width: 50%
}

.layout-two-col .layout-col-first {
 	left: 0
}

.layout-two-col .layout-col-second {
	left: 50%
}

Good to see so much brainstorming going with this. It's great to see such involvement!

Stalski’s picture

@seutje, @gausarts : thx for the review and pointers. Definitely worth considering.

Anonymous’s picture

Some additional things to consider when naming the divs regions 'first' and 'second' or 'one' and 'two'. Think '1' and '2' could be a better way to go here. Getting into higher numbers could add to the length of the name. Also not everybody's English might be good enough, and it will mean extra translating. 1,2,3, 24, etc is short, sweet, and clear.

For the two col:

for the two-col CSS we have 4 options for the layout-region div displaying next to each other:

1. Float
2. Inline block
3. CSS table
4. Position absolute and relative

One thing we haven't looked at yet is the height of the divs. If not set properly browsers can respond differently to this leading to different ways of displaying the layout. Do we want the height of the layout-regions to be the same as the container, or based on the height of the content within the layout regions?

For the HTML for the two-col from what I can tell, aside from some minor naming issues, we're all pretty much agreed upon. The naming issue shouldn't hold back the rest of the development of this though.

For the one-col:

A layout-region div within the container is superflous for some, while others feel it's needed. Next we have to decide on how we want the width and height of the content set? e.g. 100% width/ height to the div around it or fill to content.

We should decide which way to go on this, assign some roles, and start testing. Normal use cases that would be encountered within a Drupal install, what it should do out of the box, and what is up to the front-end developer should be handy (if not critical), and will help to stay within scope. The clearer the scope and the lower the threshold the more designers, that aren't fluent with Drupal, will be able to help (quickly) e.g. cross-browser testing. For example Seutje is using Dabblet, something like this or setting up a couple of HTML pages, could help for everybody to have access to the layout, and test it on different platforms and browsers without all having to set up dev boxes and patching untill we have a finalised layout. That could save a lot of time.

seutje’s picture

I really don't think we want to open the position:absolute can of worms and I guess the inline-block is really hard to get it working in a generic way without making too many assumptions. I also don't think we should enforce 100% height as this is only a requirement in some cases (and even with box-sizing, IE8 has problems with height + padding, it calculates the position of bottom: 0; all wrong)

I think the table-cell approach could work, but would mean that if any1 animates that with jQuery, it'll end up as display:block; unless you set it back to table-cell in the animation callback.

That being said, maybe it's best to just stick with floats and live with that clearfix on the wrapper. After all, these are sample layouts and will probably be swapped out by most ppl.

seutje’s picture

FileSize
4.37 KB

using floats (with clearfix): http://dabblet.com/gist/3999750

seutje’s picture

FileSize
4.41 KB

example using table-cell (implies equal heights): http://dabblet.com/gist/3999862

When trying to create an example of the problem when animating with jQuery, I noticed the latest version of jQuery doesn't set it to display block anymore, but actually notices they are display: table(-cell), and respects that! -> http://jsfiddle.net/beM6u/

so I guess I have no objections with using display: table-cell.

seutje’s picture

FileSize
4.43 KB

Ignore previous patch, forgot the breakpoint stuff

gausarts’s picture

@seutje: Whichever is the best.
Just to follow mobile first, perhaps we do the reverse on the CSS order:

/*Mobile CSS first. You can even disregard mobile CSS if this line 
will be just "display:block" and "width:100% or width:auto", block level 
elements always do that.*/

@media only screen and (min-width: 59em) {
   /*All desktop stuffs goes here*/
}
seutje’s picture

FileSize
4.32 KB
4.42 KB

added mobile-first patches, one for table-cell, one for floats

table-cell: http://dabblet.com/gist/4001302
floats: http://dabblet.com/gist/4001287

also, while playing around with this, I noticed we need a vertical-align:top; on the columns, because otherwise, if the first element of a column has a top margin, the first element in the other column will be on the same height, which might be undesirable.
illustration of the issue: http://dabblet.com/gist/4001314

so considering all this, I think it's best to just stick with floats and live with the clearfix.

seutje’s picture

Issue tags: +D8MI

also, I went with 59em (as suggested in #69) which translates to about 944px on a 16px default font-size.

not sure if it's desirable to only swap on resolution that big, perhaps we want to go with 30em, which would translate to about 480px

tagging this for the mobile peeps

gausarts’s picture

59em is based on 13px default base font in mind which translate to 768px. And this must be invalid assumption to think people always uses 13px, so please ignore as you see fit.

On the other hand, I have no data if browser default 16px is common today in real world, but since core never seems to define any base font size, it maybe reasonable to rely on browser default as you suggested.

Anonymous’s picture

Hmmm, working on the mobile CSS something became apparent:

Namely, what is the overhead of adding one or more seperate @media per CSS file when you have say 10 different layout--*.tpl.php files. This from a maintenance, performance, and code bloat point of view.

With that I mean imagine having to change the pixel size of one or more viewport for every layout, block, module CSS file one at a time for a theme This could add up to having to do the same change for say 50 times. Not wanting to go to far offtopic, but a single responsive.css or a responsive.css per viewport size, for the layout module, drupal install, or theme may be a better way to go.

Multiple stylesheets can be combined with PHP code, but having to change a single variable across multiple files could prove a time inefficient process. If font-size is part of determining the size, as well as the number of different viewport sizes, and content that may not look right depending on what it is. I'm not sure doing it this way is the way forward. Also not sure if it is part of the scope for this issue? Maybe do mobile/ responsive in a follow-up (in a broader perspective)? For now we could consider to document in the notes which parts should be responsive, and work on the mobile/ responsive part to the degree possible.

seutje’s picture

yup, smells out of scope to me

Stalski’s picture

@DesignDolphin: this is indeed offtopic.
Can you please try to be more constructive in this issue. The goal is to have working code for a 1-col and 2-col layout which are basically very easy. It seems like this issue is derailing again. E.G. answering reviews with off-topic questions, posting big blobs which bring a lot of clutter to this issue, suggesting solution without actually testing or checking them yourself. Thx in advance

webchick’s picture

This is a huge blocker for the remainder of the layout and Field UI initiative. How close are we to something that's committable as a base to work from? (knowing that we can always make further improvements later on in follow-up issues)

Fabianx’s picture

Status: Needs review » Needs work

Sorry, I wanted to mark this RTBC and I say we go with floats for now (same state as now; with Twig we can re-visit to use inline-float, tables, etc. or even independent of that).

But I think this needs a corresponding -rtl.css file.

So, todo here (IMHO) correct me if I am wrong:

* Use the float approach with clearfix (we have that now, state of the art, can revisit and find out how to work around table, inline-block things)
* Add RTL layout.

Then RTBC.

seutje’s picture

Status: Needs work » Needs review
FileSize
4.75 KB

whoops, always forget about RTL stuff, my apologies!

seutje’s picture

Not sure if I need to also declare it in the YML or if it gets picked up automagically.

seutje’s picture

FileSize
4.78 KB

added the rtl css to the YML

Fabianx’s picture

Status: Needs review » Reviewed & tested by the community

Assuming this still passes the testbot this is RTBC. Looks good now.

aspilicious’s picture

rtl is going to be picked up automagicly when enabling the language module if I'm not mistaken. (its a css alter hook that does the "magic")

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Beautiful!! Thanks for all the hard work on this folks!!

Committed and pushed to 8.x.

aspilicious’s picture

+++ b/core/modules/layout/layouts/static/twocol/two-col.ymlundefined
@@ -0,0 +1,9 @@
+  - two-col-rtl.css

I was basicly saying we don't need this line in here. Cause now it always will load both even if we haven't enabled language module. Not sure with the layouts module...

ry5n’s picture

I agree with RTBC for the HTML and CSS. I did want to make a couple of notes for possible follow-ups:

1. The .layout-display class may be able to be simplified to just .layout.
2. The 59em breakpoint should be looked at, since media queries in ems always use the browser's default font-size, regardless of the font-size set on <html> or <body>. Based on comments above, the intention here may be to use 59ems @13px.

EDIT: clarify that I reviewed the patch for HTML and CSS only.

Anonymous’s picture

@Stalski

I disagree with you. I find your comment way of the mark. I have spent a lot of effort getting this patch to where it needs to be. I have tested many things in this topic. I have stayed on topic in this entire issue, worked on getting this done, as well as getting focus for this issue. That I don't always agree with what you're proposing is a different story.

Accuse me of not being constructive in this issue. Are you on drugs or something? Seriously, go take a couple of weeks off or something.

Thanx for making my last issue with Drupal a sucky experience. The code you wrote sucked. Others and I improved it. Deal with it.

For example you're the one that added the mobile code in the patch. I noticed a problem with it and mentioned it. Now, your giving me comments about me doing wrong. That's rich. I warned you not to add the inline:block, but you added it anyway (insulting me in your comments while doing so btw), and having to face the fact that you were wrong. Like I said, DEAL WITH IT. Don't go insulting your fellow colleagues.

I find your comment non constructive, way off the mark, your behavior is totally out of line, as well as I think you owe me an apology.

If you have any further comments you wish to make I suggest you contact me through my contact form.
Where your off the wall comments should have been made in the first place.

seutje’s picture

Status: Fixed » Needs review
FileSize
443 bytes

@82: I figured as much q.q

next time, please mark it back to "needs work"

removing the -rtl css from the YML

sorry for dragging this along so far :x

aspilicious’s picture

Status: Needs review » Reviewed & tested by the community
webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and that follow-up to 8.x, too. I'll push it sometime tonight. Thanks!

webchick’s picture

Also, unpublished inflammatory comment. Can everyone in this issue please refresh yourself with http://drupal.org/dcoc.

Anonymous’s picture

#90

My comment was not intended to be inflammatory. My apologies if it came across this way.
I was defending myself against libel and slander.

Please unpublish Stalski's comment at #75 then as well.
I distance myself from the comment in #75, and do not recognize myself in this comment.

Also consider this as filing a formal complaint. It is unheard of in this community that such comments are allowed. In the least it is poor judgement.

Feel free to remove this comment after this matter is resolved. Otherwise I will see this as slander. I'm sick of this nonsense. Over 4 years of dedicated volunteer service with Drupal, and this is how you get treated.

I followed the rules with this issue.

You bust your butt, and this is the thanks you get. Thanks, but no thanks.

webchick’s picture

Ditto.

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Updated issue summary.