diff --git a/src/cssgrids/build.json b/src/cssgrids/build.json index 862d3188c13..0e119e90cc7 100644 --- a/src/cssgrids/build.json +++ b/src/cssgrids/build.json @@ -16,6 +16,13 @@ "cssfiles": [ "cssgrids-base.css" ] + }, + "cssgrids-responsive": { + "cssfiles": [ + "cssgrids-base.css", + "cssgrids-units.css", + "cssgrids-responsive-base.css" + ] } } } diff --git a/src/cssgrids/css/cssgrids-responsive-base.css b/src/cssgrids/css/cssgrids-responsive-base.css new file mode 100644 index 00000000000..2258e1382a8 --- /dev/null +++ b/src/cssgrids/css/cssgrids-responsive-base.css @@ -0,0 +1,44 @@ +.yui3-g-r { + letter-spacing: -0.31em; + *letter-spacing: normal; + word-spacing: -0.43em; +} +.yui3-g-r img { + max-width: 100%; +} + +@media (min-width:980px) { + .yui3-visible-phone { + display: none; + } + .yui3-visible-tablet { + display: none; + } + .yui3-hidden-desktop { + display: none; + } +} +@media (max-width:480px) { + .yui3-g-r > [class ^= "yui3-u"] { + width: 100%; + } +} +@media (max-width:767px) { + .yui3-g-r > [class ^= "yui3-u"] { + width: 100%; + } + .yui3-hidden-phone { + display: none; + } + .yui3-visible-desktop { + display: none; + } +} +@media (min-width:768px) and (max-width:979px) { + .yui3-hidden-tablet { + display: none; + } + .yui3-visible-desktop { + display: none; + } +} diff --git a/src/cssgrids/docs/assets/cssgrids-magazine-tests.js b/src/cssgrids/docs/assets/cssgrids-magazine-tests.js new file mode 100644 index 00000000000..4d40638131c --- /dev/null +++ b/src/cssgrids/docs/assets/cssgrids-magazine-tests.js @@ -0,0 +1,16 @@ +YUI.add('cssgrids-magazine-tests', function(Y) { + + var suite = new Y.Test.Suite('cssgrids-magazine example test suite'), + Assert = Y.Assert; + + suite.add(new Y.Test.Case({ + name: 'Responsive tests', + 'images have max-widths defined': function() { + var headlineImg = Y.one('.left-bar .article img'); + Assert.isNotUndefined(headlineImg.getComputedStyle('maxWidth'), 'maxWidth undefined on images'); + } + })); + + Y.Test.Runner.add(suite); + +}, '', { requires: [ 'node', 'node-event-simulate' ] }); diff --git a/src/cssgrids/docs/component.json b/src/cssgrids/docs/component.json index e2481d61fa4..71cc67dd175 100644 --- a/src/cssgrids/docs/component.json +++ b/src/cssgrids/docs/component.json @@ -50,6 +50,17 @@ "modules" : ["cssgrids"], "tags" : ["cssgrids"], + "hideTableOfContents": true + }, + + { + "newWindow" : "true", + "name" : "cssgrids-magazine", + "displayName": "Responsive Newspaper Layout", + "description": "A responsive layout that looks like a newspaper", + "modules" : ["cssgrids"], + "tags" : ["cssgrids"], + "hideTableOfContents": true } @@ -78,6 +89,11 @@ "name" : "cssgrids-align", "displayName": "CSS Grids Alignment Example", "layout" : "cssgrids-align-example" + }, + "cssgrids-magazine-example": { + "name" : "cssgrids-magazine", + "displayName": "CSS Grids Responsive Magazine Example", + "layout" : "cssgrids-magazine-example" } } } diff --git a/src/cssgrids/docs/cssgrids-magazine-example.mustache b/src/cssgrids/docs/cssgrids-magazine-example.mustache new file mode 100644 index 00000000000..15e96b05880 --- /dev/null +++ b/src/cssgrids/docs/cssgrids-magazine-example.mustache @@ -0,0 +1,2 @@ +{{>cssgrids-magazine-source}} +{{>test-runner}} \ No newline at end of file diff --git a/src/cssgrids/docs/cssgrids-magazine.mustache b/src/cssgrids/docs/cssgrids-magazine.mustache new file mode 100644 index 00000000000..a1f1f7d9608 --- /dev/null +++ b/src/cssgrids/docs/cssgrids-magazine.mustache @@ -0,0 +1,10 @@ +
+

The HTML for this example uses YUI3 Responsive Grids syntax to look great on different screen sizes (resize this page or view it on a smartphone). On larger screens, there are three columns. However, if viewed on a screen that is smaller than 767px, the columns stack vertically. The right-most column, which shows a stack of content on larger widths, changes to show a grid on smaller widths.

+
+ +
+ + View Example in New Window + +
+ diff --git a/src/cssgrids/docs/index.mustache b/src/cssgrids/docs/index.mustache index 6c358548045..9e0e6cf25b7 100644 --- a/src/cssgrids/docs/index.mustache +++ b/src/cssgrids/docs/index.mustache @@ -14,8 +14,13 @@ ``` ``` +

If you want responsive behavior, pull down Responsive Grids instead.

-

Using YUI CSS Grids

+ + + + +

Using YUI CSS Grids

Unit Sizes

All of the sizing for YUI Grids is done using "units". Units can be subdivided up to 1/24 of the available width. The following table gives the various unit classes that can be applied.

@@ -214,3 +219,123 @@ body { ``` + +``` + + + + + +
+ +
+ +
+
+ +``` + + +

Responsive Grids

+ +

To pull down Responsive Grids, include this link element on your page:

+``` + +``` + +

YUI Responsive Grids builds on top of the existing YUI Grids implementation. It adds a single new class name called `.yui3-g-r`. You can use this instead of using `.yui3-g` as you normally do. All elements with a class name of `.yui3-u-*-*` will automatically become responsive if they are direct descendents of a `.yui3-g-r`. Images will shrink to fit the viewport, and units will collapse to 100% width when the viewport is 767px or below.

+ +

For example, consider the two HTML snippets below. The first gist shows how regular YUI grids are written. These grids are unresponsive. They’ll always be one-thirds irrespective of the width of the screen. The second gist replaces the `yui3-g` with `yui3-g-r`, thereby making the one-third columns collapse to full width on lower screen widths.

+ +``` +
+
...
+
...
+
...
+
+ +``` + +``` +
+
...
+
...
+
...
+
+``` + +

If you want some HTML elements to remain in a grid even on smaller screens, wrap them in the standard `.yui3-g`

+ + +

Media Queries

+ +

Responsive Grids listens to the following media queries. All `yui3-u-*` elements inside a `yui3-g-r` become 100% width at 767px or below.

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Type of DisplayMedia Query Widths
Default Displays980px and up
Large Tablets768px to 979px
Smaller Tablets and Large Phones767px and below
Phones480px and below
+ +

Responsive Grids also comes with the following helper classes to show or hide content at different screen widths. Remember that to optimize performance and page load time, you should ideally determine what to show and hide on the server, instead of on the client.

+ + + + + + + + + + + + + + + + + + + + + + +
Helper Class NameDescription
`yui3-hidden-phone`Content marked with this class will be hidden below 768px
`yui3-hidden-tablet`Content marked with this class will be hidden between 768px and 979px
`yui3-hidden-desktop`Content marked with this class will be hidden above 980px
+ diff --git a/src/cssgrids/docs/partials/cssgrids-magazine-source.mustache b/src/cssgrids/docs/partials/cssgrids-magazine-source.mustache new file mode 100644 index 00000000000..8c6b37d33e4 --- /dev/null +++ b/src/cssgrids/docs/partials/cssgrids-magazine-source.mustache @@ -0,0 +1,184 @@ + + + + + + + + + + + + +
+
+
+ +
+ +

The unstyled look of hipster food magazines

+

The latest trendy food and lifestyle magazines are driven by a desire to exist outside the mainstream food world and all that goes with it.

+
+ +
+
+

A free market will help fix health care

+ +
+

What Medicare needs is not more top-down control, but the flexibility and competition of a consumer-driven free market.

+
+
+
+ + +
+
+

Boston's last great unsolved mystery

+ +
+

In 1990, Boston’s Isabella Stewart Gardner Museum was robbed of 13 works of art. In this special section, delve into the Globe’s re-examination of the case.

+
+
+
+ +
+
+
+
+

Latest News

+
+

Health chief cites 'serious lapses' at state drug lab

+

The health secretary said lab management failed to alert the state after discovering a “serious breach of protocol” by a chemist.

+
+
+

Patrick addresses controversies on drug lab, hiring

+

Governor Patrick said a former highway safety chief with a bad driving record made his administration look “ridiculous.”

+
+
+

Powerball jackpot up to $550m

+

The fast-growing jackpot had been $450 million as recently as Tuesday morning.

+
+
+
+
+
+

Globe Exclusives

+
+ +

Scot Lehigh

+

End of the Menino era?

+
+
+ +

Suffolk shifts core of campus downtown

+
+
+ +

How to donate to Globe Santa

+
+
+
+
+ + + \ No newline at end of file diff --git a/src/cssgrids/meta/cssgrids.json b/src/cssgrids/meta/cssgrids.json index 230dd15d346..34b24881f03 100644 --- a/src/cssgrids/meta/cssgrids.json +++ b/src/cssgrids/meta/cssgrids.json @@ -19,6 +19,19 @@ "type": "css" }, + "cssgrids-responsive": { + "requires": [ + "cssgrids", + "cssgrids-responsive-base" + ], + + "optional": [ + "cssreset", + "cssfonts" + ], + "type": "css" + }, + "cssgrids": { "optional": [ "cssreset", diff --git a/src/cssgrids/tests/manual/responsive.html b/src/cssgrids/tests/manual/responsive.html new file mode 100644 index 00000000000..59d9630465e --- /dev/null +++ b/src/cssgrids/tests/manual/responsive.html @@ -0,0 +1,175 @@ + + + + + + + + +
+ +

YUI3 Responsive Grids

+

An example of making your YUI3 Grids behave responsively.

+ +
+ +
+

How does it work?

+
+
+

YUI3 Responsive Grids builds on top of the existing YUI3 Grids implementation. It adds a single new class name called .yui3-g-r. You can use this instead of using .yui3-g as you normally do. All elements with a class name of .yui3-u-*-* will automatically become responsive if they are direct descendents of a .yui3-g-r.

+ +

The HTML

+

The first gist shows how regular YUI3 grids are written. These grids are unresponsive. They'll always be one-thirds irrespective of the width of the screen. The second gist replaces the yui3-g with yui3-g-r, thereby making the one-third columns collapse to full width on lower screen widths.

+ +
+
+ + +

Features.

+
+
+
    +
  • Adds configurable media queries for different screen widths (Desktops, Landscape Tablets, Portrait Tablets, Phones)
  • +
  • Collapses elements to 100% if smaller than a certain width (767px by default)
  • +
  • Adjusts images to fit on smaller screens
  • +
  • Works with as many columns as you want (or as few)
  • +
+
+ +
+ +
+

Example.

+
+
+

Fast

+

YUI's lightweight core and modular architecture make it scalable, fast, and robust. Built by frontend engineers at Yahoo!, YUI powers the most popular websites in the world.

+
+
+ +
+
+

Complete

+

YUI's intuitive and well-documented API takes you from basic DOM handling to building performant and maintainable applications on desktop browsers, mobile devices, and servers.

+
+
+
+
+

Industrial Strength

+

A thriving community, a carefully architected infrastructure, and a comprehensive suite of tools help you code like a pro, from simple web pages to complex web applications.

+
+
+
+
+

Free and Open

+

YUI is free for all uses and is developed in the open on GitHub. Core team members can always be found in the forums and the #yui IRC channel on Freenode. Pull requests welcome!

+
+
+ +
+ test image +
+ +
+
+

Two-Fifth Column

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur fermentum dui turpis. Duis nulla dolor, suscipit in venenatis vitae, auctor eu nibh. Proin lobortis arcu nec tellus vehicula vitae pellentesque nisi molestie. Aenean felis ligula, hendrerit id dictum sed, ornare nec leo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Donec non lectus et quam porttitor dignissim vitae ac odio. Aenean mattis dui porta lacus egestas ultricies. Mauris vel dolor libero, sit amet rhoncus nibh.

+
+
+ +
+
+

Three-Fifth Column

+

Quisque ac magna eget est porta varius ut eget quam. Curabitur tincidunt gravida nisl, vitae luctus velit vulputate vel. Aliquam sed sodales orci. Proin varius placerat magna tristique tincidunt. Morbi non dignissim felis. Proin bibendum libero nec felis eleifend porttitor. Morbi auctor venenatis justo, molestie luctus mi pulvinar nec. Pellentesque vitae ornare lacus. Nulla hendrerit tempor auctor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis luctus facilisis cursus. Integer in lacinia dui. Phasellus ullamcorper, sem at congue pretium, velit sapien ornare mi, eu eleifend risus sapien ac eros.

+ +

Fusce accumsan, sem vitae tempus tempor, nulla lectus interdum felis, eget molestie urna mauris vel elit. Curabitur vel ipsum nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nam viverra, augue et sollicitudin dignissim, lectus tellus imperdiet lectus, a tempor ipsum mauris vitae augue. Nullam vel nulla a purus cursus consequat. Nulla orci elit, malesuada nec egestas non, ornare quis nibh. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.

+
+
+
+
+

Grids on mobile

+
+
+

Thirds

+

This cell will be a grid even on mobile devices.

+
+
+
+
+

Thirds

+

This cell will be a grid even on mobile devices.

+
+
+
+
+

Thirds

+

This cell will be a grid even on mobile devices.

+
+
+
+
+
+
+

Thirds

+

This cell will be a grid even on mobile devices.

+
+
+
+
+

Thirds

+

This cell will be a grid even on mobile devices.

+
+
+
+
+

Thirds

+

This cell will be a grid even on mobile devices.

+
+
+
+
+
+
+

Thirds

+

This cell will be a grid even on mobile devices.

+
+
+
+
+

Thirds

+

This cell will be a grid even on mobile devices.

+
+
+
+
+

Thirds

+

This cell will be a grid even on mobile devices.

+
+
+
+ + +
+

Helper Classes

+
+
+

No Phones Allowed

+

Should be hidden on phones

+
+
+
+
+

No Tablets Allowed

+

Should be hidden on tablets

+
+
+
+
+

No big screens allowed.

+

Should be hidden on desktops/laptops

+
+
+
+ +