Giter Club home page Giter Club logo

iron-grid's Introduction

#Demo Plunker

<iron-grid>
    <div class="xs12 s9 m6 l3 xl3"></div>
    <div class="xs12 s9 m6 l3 xl3"></div>
    <div class="xs12 s9 m6 l3 xl3"></div>
    <div class="xs12 s9 m6 l3 xl3"></div>
</iron-grid>

Iron Container

iron-container is not strictly part of iron-grid but is important in laying out content. It allows you to center your page content. iron-container's default is set to ~90% of the window width. It helps you center and contain your page content. We use the container to contain our body content.

Styling

The following custom proporties are available for styling:

Custom property Description Default
--iron-container-width Width of the Container 90%
--iron-grid-element-style Permit to override grid style element null

Iron Grid

iron-grid helps you layout polymer elements in an ordered, easy fashion. We are using a standard 12 column fluid responsive grid system. iron-grid is now designed to be used in each element you want to be responsive, not only the complete page. So if you want differents behaviors following screen size for each element, you can. Now each compoment can manage its own responsiveness.

iron-grid Is created using flexboxes.

Please note that all the examples pictured below have the class 'example' on them. The class is included in the component. This class gives each grid column a 1px white border so that you can see the seperation.

12 Columns

Our standard grid has 12 columns. No matter the size of the browser, each of these columns will always have an equal width.

1

To get a feel of how the grid is used in HTML. Take a look at this code below which will produce a similar result as the one above.

<iron-grid>
    <div class="s1">1</div>
    <div class="s1">2</div>
    <div class="s1">3</div>
    <div class="s1">4</div>
    <div class="s1">5</div>
    <div class="s1">6</div>
    <div class="s1">7</div>
    <div class="s1">8</div>
    <div class="s1">9</div>
    <div class="s1">10</div>
    <div class="s1">11</div>
    <div class="s1">12</div>
</iron-grid>

Offsets

To offset, simply add offset-s2 to the class where s signifies the screen class-prefix (s = small, m = medium, l = large) and the number after is the number of columns you want to offset by.

2

<iron-grid>
    <div class="s12">
        <span>This div is 12-columns wide on all screen sizes</span>
    </div>
    <div class="s6 offset-s6">
        <span>6-columns (offset-by-6)</span>
    </div>
</iron-grid>

Orders

You can change the normal element's order of appearance on the screen. To do this, simply add order-s1 to the class where s signifies the screen class-prefix (s = small, m = medium, l = large) and the number is the appearance order (from 1 to 12). The default element order is 6, so the page will load in order of number (ie. order-s1 order-s2 order-s3 etc.), and if there are multiple element's with the same order number, then in consecutive order, as shown below.

3

<iron-grid>
    <div class="s1">1</div>
    <div class="s1">2</div> // Without the order tag, the `div` will default to order-s6.
    <div class="s1">3</div>
    <div class="s1">4</div>
    <div class="s1">5</div>
    <div class="s1">6</div>
    <div class="s1">7</div>
    <div class="s1">8</div>
    <div class="s1">9</div>
    <div class="s1">10</div>
    <div class="s1">11</div>
    <div class="s1 order-s1">12</div>
</iron-grid>

Hiding elements

You can create hidden elements by using s0, m0, or l0.

<iron-grid>
    <div class="s0 m12">
        <span>This div is hidden on small screen sizes and 12-columns wide on medium and large screen sizes.</span>
    </div>
</iron-grid>

Creating Responsive Layouts

Above we showed you how to layout elements using our grid system. Now we'll show you how to design your layouts so that they look great on all screen sizes.

Mobile Devices <= 480px Mobile Devices <= 960px Tablet Devices <= 1280px Desktop Devices <= 1600px Desktop Devices > 1600px
Class Prefix .xs .s .m .l .xl
Number of Columns 12 12 12 12 12

Adding Responsiveness

In the previous examples, we only defined the size for small screens using s12. This is fine if we want a fixed layout since the rules propogate upwards. By just saying s12, we are essentially saying s12 m12 l12. But by explicitly defining the size we can make our website more responsive.

4

<iron-grid>
    <div class="s12">
        <span>I am always full-width (s12)</span>
    </div>
    <div class="s12 m6">
        <span>I am full-width on mobile (s12 m6)</span>
    </div>
</iron-grid>

Custom screen size format

For each usage of iron-grid you can change the default screen sizes of screen format management (xs, s, m, l, xl) Each iron-grid instance will have its own screen size. Because of this, each seprate component can have it's own breakpoint.

<iron-grid xs-max-width="400" s-max-width="600" m-max-width="900" l-max-width="1150"> 
    <div class="s12">
        <span>I am always full-width (s12)</span>
    </div>
    <div class="s12 m6">
        <span>I am full-width on mobile (s12 m6)</span>
    </div>
</iron-grid>

Note that xl is not set because it is the size above 'l' max width.

Logging

You can log an iron-grid during you development adding log on iron-grid tag.

<iron-grid log> 
    <div class="s12">
        <span>I am always full-width (s12)</span>
    </div>
    <div class="s12 m6">
        <span>I am full-width on mobile (s12 m6)</span>
    </div>
</iron-grid>

Open your dev console and you will see during zomm/dezoom :

width : 375 screenFormat = s

It is recomended to only apply logging on iron-grid one at a time. If not, you will be disturb because each iron-grid can manage its screen formats. Because of the ability for an element to have it's own breakpoints, the console may become cluttered and confusing with multiple logs.

iron-grid's People

Contributors

chadkillingsworth avatar davidmarquis avatar gemron avatar hiroprotagonist avatar maxiplay avatar ozwaldorf avatar smo-key avatar studiospindle avatar vinerz avatar willsquire avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

iron-grid's Issues

Responsive layout does not work

Hi there,

upgraded to the latest version from 1.4.2. It doesn't seem to work for us. The layouting is not happening during browser resize (which it did before). The Demo is also not working, maybe let us start there.

style breaks inside dom-repeat

Hi, the grid works fine when elements with the css classes i.e ["xs", "s", "m", "l", "xl"] are direct children of the element <iron-grid>, but breaks when using an element between.

Working code:

<div class="grid-container layout center"> <iron-grid> <div class="xs6 s6 m4 l4 layout center-justified"> <paper-button class="grid-button layout vertical"> <iron-icon icon="custom:clock-w"></iron-icon> <br/> <div>Time</div> </paper-button> </div> <div class="xs6 s6 m4 l4 layout center-justified"> <paper-button class="grid-button layout vertical"> <iron-icon icon="custom:ruler-w"></iron-icon> <br/> <div>Length</div> </paper-button> </div> ... </iron-grid>

Breaking code

<div class="grid-container layout center"> <iron-grid> <template is="dom-repeat" items="{{unitData}}"> <div class="xs6 s6 m4 l4 layout center-justified"> <paper-button class="grid-button layout vertical"> <iron-icon icon="[[item.icon]]-w"></iron-icon> <br/> <div>[[item.name]]</div> </paper-button> </div> </template> </iron-grid> </div>

CSS

paper-button.grid-button {
        width: 70%;
        background-color: var(--google-red-500);
        color: white !important;
        margin: 10px;
        text-transform: capitalize;
}
.grid-container {
        padding-top: 3vh;
}

screenshot 6

Hiding a column

Would it be possible to implement something to hide columns?

I was thinking about maybe the classes s0 m0 l0?

That way I could hide certain columns on mobile:

<!-- Will not be shown on mobile -->
<div class="s0 m6">
Only for medium and large devices!
</div>

Thank you for this awesome element!

Provide demo

There is a good documentation but no live link demo. It could be interesting to add it.

Result in Safari different than Chrome

Okay, only a couple weeks in on Polymer - so I could be way off base... I'm trying to build a responsive web site that works in iOS - hence Safari.

Case 1 - Wide: Show two columns side-by-side
Case 2 - Narrow: Drop the first column, only show the second full width.

For case 1 it's pretty easy to use in my case m3 and m9, e.g.,

<iron-grid>
    <div class="m3">foo</div>
    <div class="m9">bar</div>
</iron-grid>

For case 2 the 'obvious' thing to me is throw in an s0, or...

<iron-grid>
    <div class="s0 m3">foo</div>
    <div class="m9">bar</div>
</iron-grid>

This works well on Chrome. Two columns wide, drops/hides first column on small.

foo     bar

on 's' it is...

bar

On Safari it screws up. For the wide case it shows the first column, 'foo', but then goes to the next line to show 'bar'. i.e., output for 'm' is:

foo
bar

It works correctly on 's' then, i.e.,

bar

Hint/idea -- It turns out that if I make the second column into an 's8' it will fit on one row. In other words, somehow the 's0' could be taking up just enough space to screw up the math for the 12 columns.

Microsoft Edge
Not to confuse the above point - Edge works for 's' and 'm/l/xl', but when I get to 'xs' in the above case it reverts back to using the rules for 'm'. i.e., I thought the rule was for xs was to use the next larger size specified, i.e., it should behave like 's', not 'm'???

Or am I lost?

Thanks again - this seems like a great tool!!!

Polymer & Webcomponents conflict

When imported in project where already included polymer and my own webcomponents dependencies its totally break everything. After remove the first two (import) line from iron-grid.html its working like charm, but its too difficult remove these lines at every build. Do you have any idea how to solve this?

Wrong initial grid render

Please, mind the code bellow. Every time I refresh the page, in whatever column class it happens to be, the grid always shows the largest column class. For example, after a refresh, if the browser window is 470px wide, so the .xs class in utilized, instead of getting 1 card to be shown full-screen, I get 4 cards. I think it defaults to the largest class. I have to resize the window manually for the correct grid rule to apply.

Am I missing something in the correct use of iron-grid or is it a bug?

PS. Windows user here.

<iron-grid>
  <template is="dom-repeat" items="{{productsList}}" on-dom-change="_repeatRender">
    <div class="xs12 s6 m3 l3">
      <paper-card elevation="1" id="{{item.id}}" image="{{item.header}}" heading="{{item.name}}">
        <div class="card-content">
          Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aut earum, quisquam in temporibus dolor facilis provident similique officiis velit blanditiis!
        </div>
        <div class="card-actions">
          <paper-button on-tap="_openCard">Open</paper-button>
        </div>
      </paper-card>
    </div>
  </template>
</iron-grid>

Is not Compatible with Polymer2.0

Hi!! I need use your component with polymer 2. I can do a PR with the changes in the code (content = slot) for the compatiblity of the component.

Is a interesting PR by the road map of the component?

add important to some CSS classes: offset-s0

I'm not sure why, but the offset-s0 was being ignored and overwritten by the medium one.
I changed it to offset-s0-important but that forced me to write down the offset for all the sizes instead of just medium.
<div class="xs12 s12 offset-xs0 offset-s0-important m6 offset-m3 offset-l3 offset-xl3">
It feels wrong to add so many classes. I expected it to work without the large and xl versions.

Missing dependency on iron-media-query

I think you're missing a dependency in bower.json to iron-media-query. I assume you want a dependency on PolymerElements/iron-media-query. If not, please mention it in the README.md

Hidding elements does not work

Hidding an element for a screen format does not work with the current version 3.0.0.

F.e. in the demo change

...
            <div class="s12 example blue">
                <p>s12</p>
            </div>
....

to

...
            <div class="s0 m12 example blue">
                <p>s12</p>
            </div>
...

The blue element is always hidden, also for medium size and larger.

Inner components

Hi,

Could you advise to me how to put inner paper-input to full cell with

Some polymer update broke the element

Hello! Some Polymer recent update broke the element. The column gets the right size, but they get all wrapped.
Even the demo is broken right now, as the screenshot shows:

image

Is this working?

Looks like this component is broken, because I can't get it to work correctly.

If I use s6 m4 as a class, only the last class get applied, so the div occupies 4/12 of the width, but resizing the viewport never toggles the s6 class correctly, it always stays 4/12 of it.

Nested grid does not work anymore

Try this,

The s8 container break

<div class="s8">
        <div class="s12 example blue">
            <p>s12</p>
        </div>
        <div class="s12 m3 l2 example red">
            <p>s12 m3 l2</p>
        </div>
        <div class="s12 m6 l8 example red">
            <p>s12 m6 l8</p>
        </div>
        <div class="s12 m3 l2 example red">
            <p>s12 m3 l2</p>
        </div>
  </div>

I will make a pull request very soon. Just need to add "display :flex" on sizing classes

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.