fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2012-02-14 05:41 pm

[dw-free] Cleanup tables on site-styled /icons

[commit: http://hg.dwscoalition.org/dw-free/rev/f24d2e4438a9]

http://bugs.dwscoalition.org/show_bug.cgi?id=4312

Use CSS instead of tables to align and space out /icons.

Patch by [personal profile] momijizukamori.

Files modified:
  • bin/upgrading/s2layers/siteviews/layout.s2
  • htdocs/stc/allpics.css
--------------------------------------------------------------------------------
diff -r f18a58c7d31f -r f24d2e4438a9 bin/upgrading/s2layers/siteviews/layout.s2
--- a/bin/upgrading/s2layers/siteviews/layout.s2	Tue Feb 14 22:15:12 2012 +0800
+++ b/bin/upgrading/s2layers/siteviews/layout.s2	Wed Feb 15 01:40:32 2012 +0800
@@ -83,10 +83,12 @@
 set text_icons_inactive = "[Inactive]";
 
 function IconsPage::print_title() {
+    # Do not actually *print* anything here, or in overridden instances, just call set_content with windowtitle or title as appropriate. 
     $*SITEVIEWS->set_content("title",$this->view_title());
 }
 
 function IconsPage::print_default_stylesheet() {
+    # Do not actually *print* any stylesheets here, but you can $*SITEVIEWS->need_res(...); here to pull in anything.
     $*SITEVIEWS->need_res( "stc/allpics.css" );
 }
 
@@ -120,68 +122,33 @@
             }
             if ( (++$sort_ct) < size $.sort_keyseq) { print $*text_default_separator; }
         }
-        """</p><table class='allpics'>""";
-        foreach var Icon i ($.icons) {
+        
+        """<div class="icon-container">"""; 
+                foreach var Icon i ($.icons) {
             $piccount++;
 
             if ($piccount % 2 == 1) {
-                """<tr>""";
+                """<div class="icon-row">""";
             }
 
             $i->print();
 
             if ($piccount % 2 == 1) {
-                """<td class='blank'></td>""";
+                
             } else {
-                """</tr>\n""";
+                """</div>""";
             }
         }
         if ($piccount) {
             if ($piccount % 2 == 1) {
             }
-            """</table>""";
+            
         } else {
         }
+        """</div>""";
 
         $.pages->print({ "anchor" => "" });
+        """<div class="clear-floats"></div>""";
     }
 }
 
-function Icon::print() {
-    """<td class='pic'>""";
-    
-    """<a href="$.link_url">"""; $.image->print(); """</a>""";
-
-    """</td><td class='desc'>""";
-
-    if ( $.default ) {
-        print safe """<u>$*text_icons_default</u><br/>""";
-    }
-
-    if ( not $.active ) {
-        print safe """<em>$*text_icons_inactive</em><br/>""";
-    }
-
-    if ( size $.keywords ) {
-        var int count = 0;
-        print safe """<strong>$*text_icons_keywords</strong> """;
-        foreach var string kw ( $.keywords ) {
-            $count++;
-            print safe $kw;
-            if ( $count < size $.keywords ) {
-                print safe $*text_icons_keyword_sep;
-            }
-        }
-        """<br/>""";
-    }
-
-    if ( $.comment ) {
-        print safe """<strong>$*text_icons_comment</strong> $.comment<br/>""";
-    }
-
-    if ( $.description ) {
-        print safe """<strong>$*text_icons_description</strong> $.description<br/>""";
-    }
-
-    """</td>""";
-}
diff -r f18a58c7d31f -r f24d2e4438a9 htdocs/stc/allpics.css
--- a/htdocs/stc/allpics.css	Tue Feb 14 22:15:12 2012 +0800
+++ b/htdocs/stc/allpics.css	Wed Feb 15 01:40:32 2012 +0800
@@ -1,18 +1,59 @@
 /* allpics styling */
 
-table.allpics {
+#content {
+    overflow: visible !important;
+    }
+
+.icon-container {
     margin-left: 50px;
+    min-width: 350px;
+    z-index:10;
 }
 
-.allpics td {
+.icon-image {
+    float: left;
+    width: 100px;
+    height: 100px;
+    line-height: 100px;
+    text-align: center;
+    padding: 0.2em 0.5em;
+    }
+
+.icon-image img {
+    
+    }
+
+.icon-info {
+    padding: 0.2em 0.5em;
+    overflow:auto;
     vertical-align: bottom;
-}
+    word-wrap: break-word;
+    display: table-cell;
+    width:100%;
+    }
 
-.allpics .userpic-img {
-    margin-right: 1em;
-    margin-top: 15px;
-}
+.icon {
+    width:50%;
+    float: left;
+    vertical-align: bottom;
+    min-width: 350px;
+    display:table;
+    }
 
-.allpics blank {
-    width: 50px;
-}
+.label, .comment-text, .description-text {
+    font-weight: bold;
+    }
+
+.default {
+    text-decoration: underline;
+    font-weight:normal;
+    }
+
+.keywords li, .keywords ul {
+    display:inline;
+    margin: 0;
+    }
+
+.icon-row {
+    clear:both;
+    }
--------------------------------------------------------------------------------
ninetydegrees: Art: self-portrait (Default)

Display Issue

[personal profile] ninetydegrees 2012-02-21 11:42 am (UTC)(link)
With icons which are less than 100px high, keywords and such can go below the icon. If you only have keywords, it's printed between icons and don't seem to correspond to anything. Pretty confusing.


Edit: simple solution is to switch to 'vertical-align: top' and add more padding between elements but this means not keeping the same alignment as on the current page.

Also this worked for me (basically this is what I used on custom pages) but I haven't tested it in any other browser than the current version of FF:

.icon-image {
float: left;
clear: left;
margin-bottom: 1.5em;
margin-right: 1em;
min-width: 100px;
}

.icon-info {
margin-bottom: 1.5em;
margin-left: 100px;
}

Also, the page won't adapt to smaller resolutions as the icons from second column won't go below the icons from first one (don't know if that was the case before as well but maybe it's something to think about).
Edited 2012-02-22 09:52 (UTC)
ninetydegrees: Art: self-portrait (Default)

Re: Display Issue

[personal profile] ninetydegrees 2012-02-22 09:56 am (UTC)(link)
Hm! It should be doing so; it was specifically coded to do that.

If I open the Edit CSS panel with the Web Developer tool it does so maybe it's a priority/important issue.
ninetydegrees: Art: self-portrait (Default)

Re: Display Issue

[personal profile] ninetydegrees 2012-02-22 11:06 am (UTC)(link)
we put the icon at center bottom

You mean the text? 'middle' does work for me.
ninetydegrees: Art: self-portrait (Default)

Re: Display Issue

[personal profile] ninetydegrees 2012-02-22 11:13 am (UTC)(link)
It makes the keywords go above the icon in some cases. If I switch to a very big font size like 22px it doesn't solve the issue at all.
ninetydegrees: Art: self-portrait (Default)

Re: Display Issue

[personal profile] ninetydegrees 2012-02-22 11:26 am (UTC)(link)
Sure!

Here's before and here's after with keywords above the zebra icon. I also find it pretty hard to separate the info from the snake icon from the info of the icon which is below it.
ninetydegrees: Art: self-portrait (Default)

Re: Display Issue

[personal profile] ninetydegrees 2012-02-22 12:20 pm (UTC)(link)
It's worse. Make everything go up even more.
denise: Image: Me, facing away from camera, on top of the Castel Sant'Angelo in Rome (Default)

Re: Display Issue

[staff profile] denise 2012-02-22 11:39 am (UTC)(link)
Yeah, I think we might need to give it more padding. Or start zebra-striping on site skinned icon pages, and use CSS classes so layout designers can zebra-stripe if they want, actually.
ninetydegrees: Art: self-portrait (Default)

Re: Display Issue

[personal profile] ninetydegrees 2012-02-22 05:32 pm (UTC)(link)
Doesn't really change things or make them better but it makes more sense to me to use table-cell for .icon-image as well and it gets much better if you set the img alignment to bottom. What about this:

.icon-image {
display: table-cell;
line-height: 100px;
min-width: 100px;
padding: 0 .5em;
text-align: center;
}

.icon-image img {
vertical-align: bottom;
}

.icon-info {
display: table-cell;
padding: 0 .5em;
overflow: auto;
vertical-align: bottom;
width: 100%;
word-wrap: break-word;
}

or even:

.icon-image {
display: table-cell;
height: 100px;
min-width: 100px;
padding: .5em;
text-align: center;
vertical-align: bottom;
}

.icon-image img {
vertical-align: bottom;
}

.icon-info {
display: table-cell;
padding: .5em;
overflow: auto;
vertical-align: bottom;
width: 100%;
word-wrap: break-word;
}
ninetydegrees: Art: self-portrait (mobilize)

Re: Display Issue

[personal profile] ninetydegrees 2012-02-22 06:36 pm (UTC)(link)
Glad I could help! Coincidentally, this is pretty much how my style is coded. *g*