mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 19:21:34 +08:00
feat(grid): Adam Vintage Grid
This commit is contained in:
174
ionic/components/grid/grid.scss
Normal file
174
ionic/components/grid/grid.scss
Normal file
@ -0,0 +1,174 @@
|
||||
/**
|
||||
* Grid
|
||||
* --------------------------------------------------
|
||||
* Using flexbox for the grid, inspired by Philip Walton:
|
||||
* http://philipwalton.github.io/solved-by-flexbox/demos/grids/
|
||||
* By default each .col within a .row will evenly take up
|
||||
* available width, and the height of each .col with take
|
||||
* up the height of the tallest .col in the same .row.
|
||||
*/
|
||||
|
||||
$grid-padding-width: 10px !default;
|
||||
$grid-responsive-sm-break: 567px !default; // smaller than landscape phone
|
||||
$grid-responsive-md-break: 767px !default; // smaller than portrait tablet
|
||||
$grid-responsive-lg-break: 1023px !default; // smaller than landscape tablet
|
||||
|
||||
@mixin responsive-grid-break($selector, $max-width) {
|
||||
@media (max-width: $max-width) {
|
||||
#{$selector} {
|
||||
flex-direction: column;
|
||||
|
||||
.col, .col-10, .col-20, .col-25, .col-33, .col-34, .col-50, .col-66, .col-67, .col-75, .col-80, .col-90 {
|
||||
flex: 1;
|
||||
margin-bottom: ($grid-padding-width * 3) / 2;
|
||||
margin-left: 0;
|
||||
max-width: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ion-row {
|
||||
display: flex;
|
||||
padding: ($grid-padding-width / 2);
|
||||
width: 100%;
|
||||
&[wrap] {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
&[flush] {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
> .col {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
&[top] {
|
||||
align-items: flex-start;
|
||||
}
|
||||
&[bottom] {
|
||||
align-items: flex-end;
|
||||
}
|
||||
|
||||
&[center] {
|
||||
align-items: center;
|
||||
}
|
||||
&[stretch] {
|
||||
align-items: stretch;
|
||||
}
|
||||
&[baseline] {
|
||||
align-items: baseline;
|
||||
}
|
||||
}
|
||||
|
||||
ion-row + ion-row {
|
||||
margin-top: ($grid-padding-width / 2) * -1;
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
ion-col {
|
||||
flex: 1;
|
||||
display: block;
|
||||
padding: ($grid-padding-width / 2);
|
||||
width: 100%;
|
||||
|
||||
&[top] {
|
||||
align-self: flex-start;
|
||||
}
|
||||
&[bottom] {
|
||||
align-self: flex-end;
|
||||
}
|
||||
&[center] {
|
||||
align-self: center;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Vertically Align Columns */
|
||||
/* .row-* vertically aligns every .col in the .row */
|
||||
|
||||
/* .col-* vertically aligns an individual .col */
|
||||
|
||||
/* Column Offsets */
|
||||
.col-offset-10 {
|
||||
margin-left: 10%;
|
||||
}
|
||||
.col-offset-20 {
|
||||
margin-left: 20%;
|
||||
}
|
||||
.col-offset-25 {
|
||||
margin-left: 25%;
|
||||
}
|
||||
.col-offset-33, .col-offset-34 {
|
||||
margin-left: 33.3333%;
|
||||
}
|
||||
.col-offset-50 {
|
||||
margin-left: 50%;
|
||||
}
|
||||
.col-offset-66, .col-offset-67 {
|
||||
margin-left: 66.6666%;
|
||||
}
|
||||
.col-offset-75 {
|
||||
margin-left: 75%;
|
||||
}
|
||||
.col-offset-80 {
|
||||
margin-left: 80%;
|
||||
}
|
||||
.col-offset-90 {
|
||||
margin-left: 90%;
|
||||
}
|
||||
|
||||
|
||||
/* Explicit Column Percent Sizes */
|
||||
/* By default each grid column will evenly distribute */
|
||||
/* across the grid. However, you can specify individual */
|
||||
/* columns to take up a certain size of the available area */
|
||||
.col-10 {
|
||||
flex: 0, 0, 10%;
|
||||
max-width: 10%;
|
||||
}
|
||||
.col-20 {
|
||||
flex: 0, 0, 20%;
|
||||
max-width: 20%;
|
||||
}
|
||||
.col-25 {
|
||||
flex: 0, 0, 25%;
|
||||
max-width: 25%;
|
||||
}
|
||||
.col-33, .col-34 {
|
||||
flex: 0, 0, 33.3333%;
|
||||
max-width: 33.3333%;
|
||||
}
|
||||
.col-50 {
|
||||
flex: 0, 0, 50%;
|
||||
max-width: 50%;
|
||||
}
|
||||
.col-66, .col-67 {
|
||||
flex: 0, 0, 66.6666%;
|
||||
max-width: 66.6666%;
|
||||
}
|
||||
.col-75 {
|
||||
flex: 0, 0, 75%;
|
||||
max-width: 75%;
|
||||
}
|
||||
.col-80 {
|
||||
flex: 0, 0, 80%;
|
||||
max-width: 80%;
|
||||
}
|
||||
.col-90 {
|
||||
flex: 0, 0, 90%;
|
||||
max-width: 90%;
|
||||
}
|
||||
|
||||
|
||||
/* Responsive Grid Classes */
|
||||
/* Adding a class of responsive-X to a row */
|
||||
/* will trigger the flex-direction to */
|
||||
/* change to column and add some margin */
|
||||
/* to any columns in the row for clearity */
|
||||
|
||||
@include responsive-grid-break('.responsive-sm', $grid-responsive-sm-break);
|
||||
@include responsive-grid-break('.responsive-md', $grid-responsive-md-break);
|
||||
@include responsive-grid-break('.responsive-lg', $grid-responsive-lg-break);
|
9
ionic/components/grid/test/basic/index.ts
Normal file
9
ionic/components/grid/test/basic/index.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import {App, NavController, IonicView} from 'ionic/ionic';
|
||||
|
||||
@App({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
class IonicApp {
|
||||
constructor() {
|
||||
}
|
||||
}
|
11
ionic/components/grid/test/basic/main.html
Normal file
11
ionic/components/grid/test/basic/main.html
Normal file
@ -0,0 +1,11 @@
|
||||
<ion-row>
|
||||
<ion-col class="col-33">
|
||||
Hello
|
||||
</ion-col>
|
||||
<ion-col class="col-33">
|
||||
Hello
|
||||
</ion-col>
|
||||
<ion-col class="col-33">
|
||||
Hello
|
||||
</ion-col>
|
||||
</ion-row>
|
@ -29,6 +29,7 @@
|
||||
"components/item/item",
|
||||
"components/form/form",
|
||||
"components/form/label",
|
||||
"components/grid/grid",
|
||||
"components/text-input/text-input",
|
||||
"components/list/list",
|
||||
"components/card/card",
|
||||
|
Reference in New Issue
Block a user