Front end of the Slack clone application.

grid.js 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. import { Directive } from '@angular/core';
  2. /**
  3. * @name Grid
  4. * @module ionic
  5. * @description
  6. *
  7. * The grid is a powerful mobile-first flexbox system for building custom layouts.
  8. * It is heavily influenced by [Bootstrap's grid system](http://v4-alpha.getbootstrap.com/layout/grid/).
  9. *
  10. * The grid is composed of three units — a grid, row(s) and column(s). Columns will expand to fill their
  11. * row, and will resize to fit additional columns. It is based on a 12 column layout with different
  12. * breakpoints based on the screen size. The number of columns and breakpoints can be fully customized
  13. * using Sass.
  14. *
  15. * - [How it works](#how-it-works)
  16. * - [Grid size](#grid-size)
  17. * - [Grid attributes](#grid-attributes)
  18. * - [Default breakpoints](#default-breakpoints)
  19. * - [Auto-layout columns](#auto-layout-columns)
  20. * - [Equal-width](#equal-width)
  21. * - [Setting one column width](#setting-one-column-width)
  22. * - [Variable-width](#variable-width)
  23. * - [Responsive attributes](#responsive-attributes)
  24. * - [All breakpoints](#all-breakpoints)
  25. * - [Stacked to horizontal](#stacked-to-horizontal)
  26. * - [Reordering](#reordering)
  27. * - [Offsetting columns](#offsetting-columns)
  28. * - [Push and pull](#push-and-pull)
  29. * - [Alignment](#alignment)
  30. * - [Vertical Alignment](#vertical-alignment)
  31. * - [Horizontal Alignment](#horizontal-alignment)
  32. * - [Customizing the grid](#customizing-the-grid)
  33. * - [Number of columns and padding](#number-of-columns-and-padding)
  34. * - [Grid tiers](#grid-tiers)
  35. *
  36. *
  37. * ## How it works
  38. *
  39. * The grid is a mobile-first system made up of any number of rows and columns.
  40. * It is built with flexbox making it extremely responsive. The components that
  41. * make up the grid can be written as an element (e.g., `<ion-grid>`) or added as
  42. * an attribute to any element (e.g., `<div ion-row>`).
  43. *
  44. * Here's how it works:
  45. *
  46. * - Grids act as a container for all rows and columns. Grids take up the full width of their container,
  47. * but adding the `fixed` attribute will specify the width per screen size, see [grid size](#grid-size) below.
  48. * - Rows are horizontal groups of columns that line the columns up properly.
  49. * - Content should be placed within columns, and only columns may be immediate children of rows.
  50. * - Grid columns without a specified width will automatically have equal widths.
  51. * For example, four instances of `col-sm` will each automatically be 25% wide for small breakpoints.
  52. * - Column attributes indicate the number of columns to use out of the default 12 per row.
  53. * So, `col-4` can be added in order to have three equal-width columns.
  54. * - Column widths are set as a percentage, so they’re always fluid and sized relative to their parent element.
  55. * - Columns have padding between individual columns, however, the padding can be removed from the grid and
  56. * columns by adding `no-padding` on the grid.
  57. * - There are five grid tiers by default, one for each responsive breakpoint: all breakpoints (extra small),
  58. * small, medium, large, and extra large.
  59. * - Grid tiers are based on minimum widths, meaning they apply to their tier and all those larger than it
  60. * (e.g., `col-sm-4` applies to small, medium, large, and extra large devices).
  61. * - Grids can easily be customized via Sass variables. See [customizing the grid](#customizing-the-grid).
  62. *
  63. * There are some [known bugs with flexbox](https://github.com/philipwalton/flexbugs) that
  64. * should be checked prior to creating issues with Ionic.
  65. *
  66. * ## Grid size
  67. *
  68. * By default, the grid will take up 100% width. To set a maximum width based on the screen
  69. * size add the `fixed` attribute. The maximum width of the grid for each breakpoint is defined
  70. * in the `$grid-max-widths` Sass variable. For more information, see
  71. * [customizing the grid](#customizing-the-grid).
  72. *
  73. * | Name | Value | Description |
  74. * |----------|----------|-----------------------------------------------------|
  75. * | xs | auto | Don't set the grid width for xs screens |
  76. * | sm | 540px | Set grid width to 540px when (min-width: 576px) |
  77. * | md | 720px | Set grid width to 720px when (min-width: 768px) |
  78. * | lg | 960px | Set grid width to 960px when (min-width: 992px) |
  79. * | xl | 1140px | Set grid width to 1140px when (min-width: 1200px) |
  80. *
  81. *
  82. * ## Grid attributes
  83. *
  84. * The grid takes up full width and has padding added to it based on the screen size. There are two
  85. * attributes that can be used to adjust this behavior.
  86. *
  87. * | Property | Description |
  88. * |-----------------|-------------------------------------------------------------------------------------------------------------------|
  89. * | no-padding | Removes padding from the grid and immediate children columns. |
  90. * | fixed | Set a max width based on the screen size. |
  91. *
  92. *
  93. * ## Default breakpoints
  94. *
  95. * The default breakpoints are defined by the `$grid-breakpoints` Sass variable. It can be
  96. * customized to use different values for the breakpoint, rename and add/remove breakpoints.
  97. * For more information, see [customizing the grid](#customizing-the-grid).
  98. *
  99. * | Name | Value | Width Prefix | Offset Prefix | Push Prefix | Pull Prefix | Description |
  100. * |----------|----------|--------------|---------------|--------------|-------------|---------------------------------------------------|
  101. * | xs | 0 | `col-` | `offset-` | `push-` | `pull-` | Set columns when (min-width: 0) |
  102. * | sm | 576px | `col-sm-` | `offset-sm-` | `push-sm-` | `pull-sm-` | Set columns when (min-width: 576px) |
  103. * | md | 768px | `col-md-` | `offset-md-` | `push-md-` | `pull-md-` | Set columns when (min-width: 768px) |
  104. * | lg | 992px | `col-lg-` | `offset-lg-` | `push-lg-` | `pull-lg-` | Set columns when (min-width: 992px) |
  105. * | xl | 1200px | `col-xl-` | `offset-xl-` | `push-xl-` | `pull-xl-` | Set columns when (min-width: 1200px) |
  106. *
  107. * _Note: the first breakpoint must have the value set to 0 and all breakpoint values must be in
  108. * ascending order._
  109. *
  110. * ## Auto-layout columns
  111. *
  112. * ### Equal-width
  113. *
  114. * By default, columns will take up equal width inside of a row for all devices and screen sizes.
  115. *
  116. * ```
  117. * <ion-grid>
  118. * <ion-row>
  119. * <ion-col>
  120. * 1 of 2
  121. * </ion-col>
  122. * <ion-col>
  123. * 2 of 2
  124. * </ion-col>
  125. * </ion-row>
  126. * <ion-row>
  127. * <ion-col>
  128. * 1 of 3
  129. * </ion-col>
  130. * <ion-col>
  131. * 2 of 3
  132. * </ion-col>
  133. * <ion-col>
  134. * 3 of 3
  135. * </ion-col>
  136. * </ion-row>
  137. * </ion-grid>
  138. * ```
  139. *
  140. * ### Setting one column width
  141. *
  142. * Set the width of one column and the others will automatically resize around it.
  143. * This can be done using our predefined grid attributes. In the example below,
  144. * the other columns will resize no matter the width of the center column.
  145. *
  146. * ```
  147. * <ion-grid>
  148. * <ion-row>
  149. * <ion-col>
  150. * 1 of 3
  151. * </ion-col>
  152. * <ion-col col-8>
  153. * 2 of 3 (wider)
  154. * </ion-col>
  155. * <ion-col>
  156. * 3 of 3
  157. * </ion-col>
  158. * </ion-row>
  159. * <ion-row>
  160. * <ion-col>
  161. * 1 of 3
  162. * </ion-col>
  163. * <ion-col col-6>
  164. * 2 of 3 (wider)
  165. * </ion-col>
  166. * <ion-col>
  167. * 3 of 3
  168. * </ion-col>
  169. * </ion-row>
  170. * </ion-grid>
  171. * ```
  172. *
  173. * ### Variable-width
  174. *
  175. * Using the `col-{breakpoint}-auto` attributes, the column can size itself based on the
  176. * natural width of its content. This is extremely useful for setting a column width
  177. * using pixels. The columns next to the variable-width column will resize to fill the row.
  178. *
  179. * ```
  180. * <ion-grid>
  181. * <ion-row>
  182. * <ion-col>
  183. * 1 of 3
  184. * </ion-col>
  185. * <ion-col col-auto>
  186. * Variable width content
  187. * </ion-col>
  188. * <ion-col>
  189. * 3 of 3
  190. * </ion-col>
  191. * </ion-row>
  192. * <ion-row>
  193. * <ion-col>
  194. * 1 of 4
  195. * </ion-col>
  196. * <ion-col>
  197. * 2 of 4
  198. * </ion-col>
  199. * <ion-col col-auto>
  200. * <ion-input placeholder="Variable width input"></ion-input>
  201. * </ion-col>
  202. * <ion-col>
  203. * 4 of 4
  204. * </ion-col>
  205. * </ion-row>
  206. * </ion-grid>
  207. * ```
  208. *
  209. *
  210. * ## Responsive attributes
  211. *
  212. * ### All breakpoints
  213. *
  214. * To customize a column's width for all devices and screens, add the `col-*`
  215. * attribute. These attributes tell the column to take up `*` columns out
  216. * of the available columns.
  217. *
  218. * ```
  219. * <ion-grid>
  220. * <ion-row>
  221. * <ion-col col-4>
  222. * 1 of 4
  223. * </ion-col>
  224. * <ion-col col-2>
  225. * 2 of 4
  226. * </ion-col>
  227. * <ion-col col-2>
  228. * 3 of 4
  229. * </ion-col>
  230. * <ion-col col-4>
  231. * 4 of 4
  232. * </ion-col>
  233. * </ion-row>
  234. * </ion-grid>
  235. * ```
  236. *
  237. * ### Stacked to horizontal
  238. *
  239. * Use a combination of width and breakpoint attributes to create a grid that starts out stacked
  240. * on extra small screens before becoming horizontal on small screens.
  241. *
  242. * ```
  243. * <ion-grid>
  244. * <ion-row>
  245. * <ion-col col-12 col-sm>
  246. * 1 of 4
  247. * </ion-col>
  248. * <ion-col col-12 col-sm>
  249. * 2 of 4
  250. * </ion-col>
  251. * <ion-col col-12 col-sm>
  252. * 3 of 4
  253. * </ion-col>
  254. * <ion-col col-12 col-sm>
  255. * 4 of 4
  256. * </ion-col>
  257. * </ion-row>
  258. * </ion-grid>
  259. * ```
  260. *
  261. *
  262. * ## Reordering
  263. *
  264. * ### Offsetting columns
  265. *
  266. * Move columns to the right by adding the `offset-*` attributes. These attributes
  267. * increase the margin start of the column by `*` columns. For example, in the following
  268. * grid the last column will be offset by 3 columns and take up 3 columns:
  269. *
  270. * ```
  271. * <ion-grid>
  272. * <ion-row>
  273. * <ion-col col-3>
  274. * 1 of 2
  275. * </ion-col>
  276. * <ion-col col-3 offset-3>
  277. * 2 of 2
  278. * </ion-col>
  279. * </ion-row>
  280. * </ion-grid>
  281. * ```
  282. *
  283. * Offsets can also be added based on screen breakpoints. Here's an example of a
  284. * grid where the last column will be offset by 3 columns for `md` screens and up:
  285. *
  286. * ```
  287. * <ion-grid>
  288. * <ion-row>
  289. * <ion-col col-md-3>
  290. * 1 of 3
  291. * </ion-col>
  292. * <ion-col col-md-3>
  293. * 2 of 3
  294. * </ion-col>
  295. * <ion-col col-md-3 offset-md-3>
  296. * 3 of 3
  297. * </ion-col>
  298. * </ion-row>
  299. * </ion-grid>
  300. * ```
  301. *
  302. * ### Push and pull
  303. *
  304. * Reorder the columns by adding the `push-*` and `pull-*` attributes. These attributes
  305. * adjust the `left` and `right` of the columns by `*` columns making it easy to reorder
  306. * columns. For example, in the following grid the column with the `1st col` description
  307. * will actually be the last column and the `2nd col` will be the first column.
  308. *
  309. * ```
  310. * <ion-grid>
  311. * <ion-row>
  312. * <ion-col col-9 push-3>
  313. * 1 of 2
  314. * </ion-col>
  315. * <ion-col col-3 pull-9>
  316. * 2 of 2
  317. * </ion-col>
  318. * </ion-row>
  319. * </ion-grid>
  320. * ```
  321. *
  322. * Push and pull can also be added based on screen breakpoints. In the following example,
  323. * the column with the `3rd` column description will actually be the first column for
  324. * `md` screens and up:
  325. *
  326. * ```
  327. * <ion-grid>
  328. * <ion-row>
  329. * <ion-col col-md-6 push-md-3>
  330. * 1 of 3
  331. * </ion-col>
  332. * <ion-col col-md-3 push-md-3>
  333. * 2 of 3
  334. * </ion-col>
  335. * <ion-col col-md-3 pull-md-9>
  336. * 3 of 3
  337. * </ion-col>
  338. * </ion-row>
  339. * </ion-grid>
  340. * ```
  341. *
  342. *
  343. * ## Alignment
  344. *
  345. * ### Vertical alignment
  346. *
  347. * All columns can be vertically aligned inside of a row by adding different
  348. * attributes to the row. For a list of available attributes, see
  349. * [row attributes](../Row#row-attributes).
  350. *
  351. * ```
  352. * <ion-grid>
  353. * <ion-row align-items-start>
  354. * <ion-col>
  355. * 1 of 4
  356. * </ion-col>
  357. * <ion-col>
  358. * 2 of 4
  359. * </ion-col>
  360. * <ion-col>
  361. * 3 of 4
  362. * </ion-col>
  363. * <ion-col>
  364. * 4 of 4 <br>#<br>#<br>#
  365. * </ion-col>
  366. * </ion-row>
  367. *
  368. * <ion-row align-items-center>
  369. * <ion-col>
  370. * 1 of 4
  371. * </ion-col>
  372. * <ion-col>
  373. * 2 of 4
  374. * </ion-col>
  375. * <ion-col>
  376. * 3 of 4
  377. * </ion-col>
  378. * <ion-col>
  379. * 4 of 4 <br>#<br>#<br>#
  380. * </ion-col>
  381. * </ion-row>
  382. *
  383. * <ion-row align-items-end>
  384. * <ion-col>
  385. * 1 of 4
  386. * </ion-col>
  387. * <ion-col>
  388. * 2 of 4
  389. * </ion-col>
  390. * <ion-col>
  391. * 3 of 4
  392. * </ion-col>
  393. * <ion-col>
  394. * 4 of 4 <br>#<br>#<br>#
  395. * </ion-col>
  396. * </ion-row>
  397. * </ion-grid>
  398. * ```
  399. *
  400. * Columns can also align themselves differently than other columns by
  401. * adding the alignment attribute directly to the column. For a list of available
  402. * attributes, see [column attributes](../Col#column-attributes).
  403. *
  404. * ```
  405. * <ion-grid>
  406. * <ion-row>
  407. * <ion-col align-self-start>
  408. * <div>
  409. * 1 of 4
  410. * </div>
  411. * </ion-col>
  412. * <ion-col align-self-center>
  413. * <div>
  414. * 2 of 4
  415. * </div>
  416. * </ion-col>
  417. * <ion-col align-self-end>
  418. * <div>
  419. * 3 of 4
  420. * </div>
  421. * </ion-col>
  422. * <ion-col>
  423. * <div>
  424. * 4 of 4 <br>#<br>#<br>#
  425. * </div>
  426. * </ion-col>
  427. * </ion-row>
  428. * </ion-grid>
  429. * ```
  430. *
  431. * ### Horizontal alignment
  432. *
  433. * All columns can be horizontally aligned inside of a row by adding different
  434. * attributes to the row. For a list of available attributes, see
  435. * [row attributes](../Row#row-attributes).
  436. *
  437. * ```
  438. * <ion-grid>
  439. * <ion-row justify-content-start>
  440. * <ion-col col-3>
  441. * 1 of 2
  442. * </ion-col>
  443. * <ion-col col-3>
  444. * 2 of 2
  445. * </ion-col>
  446. * </ion-row>
  447. *
  448. * <ion-row justify-content-center>
  449. * <ion-col col-3>
  450. * 1 of 2
  451. * </ion-col>
  452. * <ion-col col-3>
  453. * 2 of 2
  454. * </ion-col>
  455. * </ion-row>
  456. *
  457. * <ion-row justify-content-end>
  458. * <ion-col col-3>
  459. * 1 of 2
  460. * </ion-col>
  461. * <ion-col col-3>
  462. * 2 of 2
  463. * </ion-col>
  464. * </ion-row>
  465. *
  466. * <ion-row justify-content-around>
  467. * <ion-col col-3>
  468. * 1 of 2
  469. * </ion-col>
  470. * <ion-col col-3>
  471. * 2 of 2
  472. * </ion-col>
  473. * </ion-row>
  474. *
  475. * <ion-row justify-content-between>
  476. * <ion-col col-3>
  477. * 1 of 2
  478. * </ion-col>
  479. * <ion-col col-3>
  480. * 2 of 2
  481. * </ion-col>
  482. * </ion-row>
  483. * </ion-grid>
  484. * ```
  485. *
  486. *
  487. * ## Customizing the grid
  488. *
  489. * Using our built-in grid Sass variables and maps, it’s possible to completely customize
  490. * the predefined grid attributes. Change the number of breakpoints, the media query values,
  491. * the number of columns, and more.
  492. *
  493. * ### Number of columns and padding
  494. *
  495. * The number of grid columns and their padding can be modified via Sass variables.
  496. * `$grid-columns` is used to generate the widths (in percent) of each individual column.
  497. * `$grid-padding-width` is used for the padding on the grid, while `$grid-padding-widths`
  498. * allows breakpoint-specific widths that are divided evenly across `padding-left` and
  499. * `padding-right` as well as `padding-top` and `padding-bottom` of the grid and columns.
  500. *
  501. * ```
  502. * $grid-columns: 12 !default;
  503. *
  504. * $grid-padding-width: 10px !default;
  505. *
  506. * $grid-padding-widths: (
  507. * xs: $grid-padding-width,
  508. * sm: $grid-padding-width,
  509. * md: $grid-padding-width,
  510. * lg: $grid-padding-width,
  511. * xl: $grid-padding-width
  512. * ) !default;
  513. * ```
  514. *
  515. * ### Grid tiers
  516. *
  517. * To customize the breakpoints and their values, override the values of
  518. * `$grid-breakpoints` and `$grid-max-widths`. For example, to only use
  519. * 3 breakpoints, the following could be written:
  520. *
  521. * ```
  522. * $grid-breakpoints: (
  523. * sm: 0,
  524. * md: 768px,
  525. * lg: 1024px
  526. * );
  527. *
  528. * $grid-max-widths: (
  529. * sm: 420px,
  530. * md: 720px,
  531. * lg: 960px
  532. * );
  533. * ```
  534. *
  535. */
  536. export class Grid {
  537. }
  538. Grid.decorators = [
  539. { type: Directive, args: [{
  540. selector: 'ion-grid, [ion-grid]',
  541. host: {
  542. 'class': 'grid'
  543. }
  544. },] },
  545. ];
  546. /** @nocollapse */
  547. Grid.ctorParameters = () => [];
  548. //# sourceMappingURL=grid.js.map