@carbon/grid 10.1.1 → 10.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/LICENSE +2 -2
- package/README.md +24 -26
- package/package.json +10 -5
- package/scss/_inlined/12.scss +41 -0
- package/scss/_inlined/_mixins.scss +335 -0
- package/scss/_inlined/_prefix.scss +12 -0
- package/scss/_mixins.scss +1 -1
- package/scss/grid.scss +1 -1
- package/scss/index.scss +10 -0
- package/scss/vendor/@carbon/import-once/import-once.scss +27 -0
- package/scss/vendor/@carbon/import-once/index.scss +8 -0
- package/scss/vendor/@carbon/layout/_breakpoint.scss +237 -0
- package/scss/vendor/@carbon/layout/_convert.scss +30 -0
- package/scss/vendor/@carbon/layout/_key-height.scss +97 -0
- package/scss/vendor/@carbon/layout/_mini-unit.scss +23 -0
- package/scss/vendor/@carbon/layout/_spacing.scss +328 -0
- package/scss/vendor/@carbon/layout/_utilities.scss +41 -0
- package/scss/vendor/@carbon/layout/index.scss +8 -0
- package/scss/vendor/@carbon/layout/layout.scss +12 -0
- package/css/grid.css +0 -1053
- package/css/grid.min.css +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,29 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# 10.3.0 (2019-06-05)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# 10.3.0-rc.2 (2019-06-03)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# 10.3.0-rc.1 (2019-05-29)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* **grid:** add 1:2 aspect ratio class ([#2858](https://github.com/IBM/carbon-elements/tree/master/packages/grid/issues/2858)) ([43c9446](https://github.com/IBM/carbon-elements/tree/master/packages/grid/commit/43c9446))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# 10.2.0-bridge (2019-05-13)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
6
29
|
## [10.1.1](https://github.com/IBM/carbon-elements/tree/master/packages/grid/compare/v10.1.0...v10.1.1) (2019-04-13)
|
|
7
30
|
|
|
8
31
|
**Note:** Version bump only for package @carbon/grid
|
package/LICENSE
CHANGED
|
@@ -178,7 +178,7 @@
|
|
|
178
178
|
APPENDIX: How to apply the Apache License to your work.
|
|
179
179
|
|
|
180
180
|
To apply the Apache License to your work, attach the following
|
|
181
|
-
boilerplate notice, with the fields enclosed by brackets "
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
182
182
|
replaced with your own identifying information. (Don't include
|
|
183
183
|
the brackets!) The text should be enclosed in the appropriate
|
|
184
184
|
comment syntax for the file format. We also recommend that a
|
|
@@ -186,7 +186,7 @@
|
|
|
186
186
|
same "printed page" as the copyright notice for easier
|
|
187
187
|
identification within third-party archives.
|
|
188
188
|
|
|
189
|
-
Copyright
|
|
189
|
+
Copyright 2015 IBM Corp.
|
|
190
190
|
|
|
191
191
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
192
|
you may not use this file except in compliance with the License.
|
package/README.md
CHANGED
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
## Getting started
|
|
6
6
|
|
|
7
|
-
To install `@carbon/grid` in your project, you will need to run the
|
|
8
|
-
|
|
7
|
+
To install `@carbon/grid` in your project, you will need to run the following
|
|
8
|
+
command using [npm](https://www.npmjs.com/):
|
|
9
9
|
|
|
10
10
|
```bash
|
|
11
11
|
npm install -S @carbon/grid
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
If you prefer [Yarn](https://yarnpkg.com/en/), use the following
|
|
15
|
-
|
|
14
|
+
If you prefer [Yarn](https://yarnpkg.com/en/), use the following command
|
|
15
|
+
instead:
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
18
|
yarn add @carbon/grid
|
|
@@ -20,17 +20,17 @@ yarn add @carbon/grid
|
|
|
20
20
|
|
|
21
21
|
## Usage
|
|
22
22
|
|
|
23
|
-
`@carbon/grid` has three primitive class types to use in order to
|
|
24
|
-
|
|
23
|
+
`@carbon/grid` has three primitive class types to use in order to structure your
|
|
24
|
+
application. They include:
|
|
25
25
|
|
|
26
|
-
- `bx--grid`, defines the overall grid context and sets some useful
|
|
27
|
-
|
|
26
|
+
- `bx--grid`, defines the overall grid context and sets some useful attributes
|
|
27
|
+
like width and margin
|
|
28
28
|
- `bx--row`, defines a row of items in a grid
|
|
29
29
|
- `bx--col`, used to define individual columns
|
|
30
30
|
|
|
31
|
-
You can use a combination of these classes to build a layout. For
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
You can use a combination of these classes to build a layout. For example, if we
|
|
32
|
+
wanted a 4 column layout for a small breakpoint we could use the following
|
|
33
|
+
markup:
|
|
34
34
|
|
|
35
35
|
```html
|
|
36
36
|
<div class="bx--grid">
|
|
@@ -43,14 +43,14 @@ could use the following markup:
|
|
|
43
43
|
</div>
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
-
While this layout can work for some grid usage scenarios, we probably
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
While this layout can work for some grid usage scenarios, we probably will want
|
|
47
|
+
more control over how many columns our layout will span at each given
|
|
48
|
+
breakpoint.
|
|
49
49
|
|
|
50
|
-
By default, `@carbon/grid` uses the breakpoints defined in `@carbon/layout`.
|
|
51
|
-
and `max`. You can use each
|
|
52
|
-
specify the number of columns to span at a
|
|
53
|
-
example, we could rewrite the above example to be:
|
|
50
|
+
By default, `@carbon/grid` uses the breakpoints defined in `@carbon/layout`.
|
|
51
|
+
There are five breakpoints: `sm`, `md`, `lg`, `xlg`, and `max`. You can use each
|
|
52
|
+
one in combination with a column to specify the number of columns to span at a
|
|
53
|
+
given breakpoint. For example, we could rewrite the above example to be:
|
|
54
54
|
|
|
55
55
|
```html
|
|
56
56
|
<div class="bx--grid">
|
|
@@ -63,10 +63,9 @@ example, we could rewrite the above example to be:
|
|
|
63
63
|
</div>
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
-
The `.bx--col-sm-1` class names tells us that this `<div>` should only
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
overall width.
|
|
66
|
+
The `.bx--col-sm-1` class names tells us that this `<div>` should only span one
|
|
67
|
+
column at our `sm` breakpoint. By default, as we scale beyond the breakpoint the
|
|
68
|
+
layout will still take up a percentage of the overall width.
|
|
70
69
|
|
|
71
70
|
## 📖 API Documentation
|
|
72
71
|
|
|
@@ -76,10 +75,9 @@ If you're looking for `@carbon/grid` API documentation, check out:
|
|
|
76
75
|
|
|
77
76
|
## 🙌 Contributing
|
|
78
77
|
|
|
79
|
-
We're always looking for contributors to help us fix bugs, build new
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
! 👀
|
|
78
|
+
We're always looking for contributors to help us fix bugs, build new features,
|
|
79
|
+
or help us improve the project documentation. If you're interested, definitely
|
|
80
|
+
check out our [Contributing Guide](/.github/CONTRIBUTING.md) ! 👀
|
|
83
81
|
|
|
84
82
|
## 📝 License
|
|
85
83
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbon/grid",
|
|
3
3
|
"description": "Grid for digital and software products using the Carbon Design System",
|
|
4
|
-
"version": "10.
|
|
4
|
+
"version": "10.3.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": "https://github.com/IBM/carbon-elements/tree/master/packages/grid",
|
|
7
7
|
"bugs": "https://github.com/IBM/carbon-elements/issues",
|
|
@@ -21,11 +21,16 @@
|
|
|
21
21
|
"access": "public"
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
|
-
"build": "bundler sassdoc 'scss'"
|
|
24
|
+
"build": "yarn clean && bundler sassdoc 'scss/*.scss' && bundler inline && bundler check 'scss/*.scss'",
|
|
25
|
+
"clean": "rimraf scss/_inlined scss/vendor"
|
|
25
26
|
},
|
|
26
27
|
"dependencies": {
|
|
27
|
-
"@carbon/import-once": "10.
|
|
28
|
-
"@carbon/layout": "10.
|
|
28
|
+
"@carbon/import-once": "10.2.0",
|
|
29
|
+
"@carbon/layout": "10.2.0"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@carbon/bundler": "10.2.0",
|
|
33
|
+
"rimraf": "^2.6.3"
|
|
29
34
|
},
|
|
30
35
|
"eyeglass": {
|
|
31
36
|
"exports": false,
|
|
@@ -33,5 +38,5 @@
|
|
|
33
38
|
"sassDir": "scss",
|
|
34
39
|
"needs": "^1.3.0"
|
|
35
40
|
},
|
|
36
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "e1ff2abd982e22a1d53eeb4c95b1caa00d802595"
|
|
37
42
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright IBM Corp. 2018, 2018
|
|
3
|
+
//
|
|
4
|
+
// This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
// LICENSE file in the root directory of this source tree.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
@import 'mixins';
|
|
9
|
+
|
|
10
|
+
/// Overrides `$carbon--grid-breakpoints` to use a 12 column grid instead of the default 16
|
|
11
|
+
/// @type Map
|
|
12
|
+
/// @access public
|
|
13
|
+
/// @group @carbon/grid
|
|
14
|
+
$carbon--12-column-grid: map-merge(
|
|
15
|
+
$carbon--grid-breakpoints,
|
|
16
|
+
(
|
|
17
|
+
lg:
|
|
18
|
+
map-merge(
|
|
19
|
+
map-get($carbon--grid-breakpoints, lg),
|
|
20
|
+
(
|
|
21
|
+
columns: 12,
|
|
22
|
+
)
|
|
23
|
+
),
|
|
24
|
+
xlg:
|
|
25
|
+
map-merge(
|
|
26
|
+
map-get($carbon--grid-breakpoints, xlg),
|
|
27
|
+
(
|
|
28
|
+
columns: 12,
|
|
29
|
+
)
|
|
30
|
+
),
|
|
31
|
+
max:
|
|
32
|
+
map-merge(
|
|
33
|
+
map-get($carbon--grid-breakpoints, max),
|
|
34
|
+
(
|
|
35
|
+
columns: 12,
|
|
36
|
+
)
|
|
37
|
+
),
|
|
38
|
+
)
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
@include carbon--grid($breakpoints: $carbon--12-column-grid);
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright IBM Corp. 2018, 2018
|
|
3
|
+
//
|
|
4
|
+
// This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
// LICENSE file in the root directory of this source tree.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
// Helpers for defining columns, rows, and containers are heavily inspired by,
|
|
9
|
+
// and often derived from, bootstrap:
|
|
10
|
+
// https://github.com/twbs/bootstrap/blob/v4-dev/scss/mixins/_grid.scss
|
|
11
|
+
|
|
12
|
+
@import '../vendor/@carbon/layout/breakpoint';
|
|
13
|
+
@import 'prefix';
|
|
14
|
+
|
|
15
|
+
// -----------------------------------------------------------------------------
|
|
16
|
+
// Columns
|
|
17
|
+
// -----------------------------------------------------------------------------
|
|
18
|
+
|
|
19
|
+
/// Used to initialize the default properties for a column class, most notably
|
|
20
|
+
/// for setting width and default gutters when a column's breakpoint has not been
|
|
21
|
+
/// hit yet.
|
|
22
|
+
/// @param {Number} $gutter [$carbon--grid-gutter] - The gutter for the grid system
|
|
23
|
+
/// @param {Number} $collapsed-gutter [$carbon--grid-gutter--condensed] - The condensed mode gutter
|
|
24
|
+
/// @access private
|
|
25
|
+
/// @group @carbon/grid
|
|
26
|
+
@mixin carbon--make-col-ready(
|
|
27
|
+
$gutter: $carbon--grid-gutter,
|
|
28
|
+
$condensed-gutter: $carbon--grid-gutter--condensed
|
|
29
|
+
) {
|
|
30
|
+
// Prevent columns from becoming too narrow when at smaller grid tiers by
|
|
31
|
+
// always setting `width: 100%;`. This works because we use `flex` values
|
|
32
|
+
// later on to override this initial width.
|
|
33
|
+
width: 100%;
|
|
34
|
+
padding-right: ($gutter / 2);
|
|
35
|
+
padding-left: ($gutter / 2);
|
|
36
|
+
|
|
37
|
+
// For our condensed use-case, our gutters collapse to 2px solid, 1px on each
|
|
38
|
+
// side.
|
|
39
|
+
.#{$prefix}--row--condensed &,
|
|
40
|
+
.#{$prefix}--grid--condensed & {
|
|
41
|
+
padding-right: ($condensed-gutter / 2);
|
|
42
|
+
padding-left: ($condensed-gutter / 2);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/// Define the width of the column for a given span and column count.
|
|
47
|
+
/// @param {Number} $span - The number of columns covered
|
|
48
|
+
/// @param {Number} $columns - The total number of columns available
|
|
49
|
+
/// @access private
|
|
50
|
+
/// @group @carbon/grid
|
|
51
|
+
@mixin carbon--make-col($span, $columns) {
|
|
52
|
+
flex: 0 0 percentage($span / $columns);
|
|
53
|
+
// Add a `max-width` to ensure content within each column does not blow out
|
|
54
|
+
// the width of the column. Applies to IE10+ and Firefox. Chrome and Safari
|
|
55
|
+
// do not appear to require this.
|
|
56
|
+
max-width: percentage($span / $columns);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/// Create a column offset for a given span and column count.
|
|
60
|
+
/// @param {Number} $span - The number of columns the offset should cover
|
|
61
|
+
/// @param {Number} $columns - The total number of columns available
|
|
62
|
+
/// @access private
|
|
63
|
+
/// @group @carbon/grid
|
|
64
|
+
@mixin carbon--make-col-offset($span, $columns) {
|
|
65
|
+
$offset: $span / $columns;
|
|
66
|
+
@if $offset == 0 {
|
|
67
|
+
margin-left: 0;
|
|
68
|
+
} @else {
|
|
69
|
+
margin-left: percentage($offset);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/// Output the CSS required for all the columns in a given grid system.
|
|
74
|
+
/// @param {Map} $breakpoints [$carbon--grid-breakpoints] - The breakpoints in the grid system
|
|
75
|
+
/// @param {Number} $gutter [$carbon--grid-gutter] - The gutter for the grid system
|
|
76
|
+
/// @access private
|
|
77
|
+
/// @group @carbon/grid
|
|
78
|
+
@mixin carbon--make-grid-columns(
|
|
79
|
+
$breakpoints: $carbon--grid-breakpoints,
|
|
80
|
+
$gutter: $carbon--grid-gutter
|
|
81
|
+
) {
|
|
82
|
+
.#{$prefix}--col {
|
|
83
|
+
@include carbon--make-col-ready();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@each $breakpoint in map-keys($breakpoints) {
|
|
87
|
+
$infix: carbon--breakpoint-infix($breakpoint);
|
|
88
|
+
$columns: map-get(map-get($breakpoints, $breakpoint), columns);
|
|
89
|
+
|
|
90
|
+
// Allow columns to stretch full width below their breakpoints
|
|
91
|
+
@for $i from 1 through $columns {
|
|
92
|
+
.#{$prefix}--col#{$infix}-#{$i} {
|
|
93
|
+
@include carbon--make-col-ready();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.#{$prefix}--col#{$infix},
|
|
98
|
+
.#{$prefix}--col#{$infix}--auto {
|
|
99
|
+
@include carbon--make-col-ready();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
@include carbon--breakpoint($breakpoint, $breakpoints) {
|
|
103
|
+
// Provide basic `.col-{bp}` classes for equal-width flexbox columns
|
|
104
|
+
.#{$prefix}--col,
|
|
105
|
+
.#{$prefix}--col#{$infix} {
|
|
106
|
+
flex-basis: 0;
|
|
107
|
+
flex-grow: 1;
|
|
108
|
+
max-width: 100%;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.#{$prefix}--col--auto,
|
|
112
|
+
.#{$prefix}--col#{$infix}--auto {
|
|
113
|
+
flex: 1 0 0%;
|
|
114
|
+
width: auto;
|
|
115
|
+
// Reset earlier grid tiers
|
|
116
|
+
max-width: 100%;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
@for $i from 1 through $columns {
|
|
120
|
+
.#{$prefix}--col#{$infix}-#{$i} {
|
|
121
|
+
@include carbon--make-col($i, $columns);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
@for $i from 0 through ($columns - 1) {
|
|
126
|
+
@if not($infix == '') {
|
|
127
|
+
.#{$prefix}--offset#{$infix}-#{$i} {
|
|
128
|
+
@include carbon--make-col-offset($i, $columns);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// -----------------------------------------------------------------------------
|
|
137
|
+
// Rows
|
|
138
|
+
// -----------------------------------------------------------------------------
|
|
139
|
+
|
|
140
|
+
/// Define the properties for a selector assigned to a row in the grid system.
|
|
141
|
+
/// @param {Number} $gutter [$carbon--grid-gutter] - The gutter in the grid system
|
|
142
|
+
/// @access private
|
|
143
|
+
/// @group @carbon/grid
|
|
144
|
+
@mixin carbon--make-row($gutter: $carbon--grid-gutter) {
|
|
145
|
+
display: flex;
|
|
146
|
+
flex-wrap: wrap;
|
|
147
|
+
margin-right: -1 * $gutter / 2;
|
|
148
|
+
margin-left: -1 * $gutter / 2;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// -----------------------------------------------------------------------------
|
|
152
|
+
// No gutter
|
|
153
|
+
// -----------------------------------------------------------------------------
|
|
154
|
+
|
|
155
|
+
/// Add `no-gutter` and `no-gutter--{left,right}` classes to the output CSS. These
|
|
156
|
+
/// classes are useful for dropping the gutter in fluid situations.
|
|
157
|
+
/// @access private
|
|
158
|
+
/// @group @carbon/grid
|
|
159
|
+
@mixin carbon--no-gutter {
|
|
160
|
+
.#{$prefix}--no-gutter,
|
|
161
|
+
.#{$prefix}--row.#{$prefix}--no-gutter [class*='#{$prefix}--col'] {
|
|
162
|
+
padding-left: 0;
|
|
163
|
+
padding-right: 0;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.#{$prefix}--no-gutter--left,
|
|
167
|
+
.#{$prefix}--row.#{$prefix}--no-gutter--left [class*='#{$prefix}--col'] {
|
|
168
|
+
padding-left: 0;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.#{$prefix}--no-gutter--right,
|
|
172
|
+
.#{$prefix}--row.#{$prefix}--no-gutter--right [class*='#{$prefix}--col'] {
|
|
173
|
+
padding-right: 0;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// -----------------------------------------------------------------------------
|
|
178
|
+
// Hang
|
|
179
|
+
// -----------------------------------------------------------------------------
|
|
180
|
+
|
|
181
|
+
/// Add `hang--left` and `hang--right` classes for a given gutter. These classes are
|
|
182
|
+
/// used alongside `no-gutter--left` and `no-gutter--right` to "hang" type.
|
|
183
|
+
/// @param {Number} $gutter [$carbon--grid-gutter] - The gutter in the grid system
|
|
184
|
+
/// @access private
|
|
185
|
+
/// @group @carbon/grid
|
|
186
|
+
@mixin carbon--hang($gutter: $carbon--grid-gutter) {
|
|
187
|
+
.#{$prefix}--hang--left {
|
|
188
|
+
padding-left: ($gutter / 2);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.#{$prefix}--hang--right {
|
|
192
|
+
padding-right: ($gutter / 2);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// -----------------------------------------------------------------------------
|
|
197
|
+
// Aspect ratio
|
|
198
|
+
// -----------------------------------------------------------------------------
|
|
199
|
+
|
|
200
|
+
/// The aspect ratios that are used to generate corresponding aspect ratio
|
|
201
|
+
/// classes in code
|
|
202
|
+
/// @type List
|
|
203
|
+
/// @access public
|
|
204
|
+
/// @group @carbon/grid
|
|
205
|
+
$carbon--aspect-ratios: ((16, 9), (2, 1), (4, 3), (1, 1), (1, 2));
|
|
206
|
+
|
|
207
|
+
/// Output the CSS classes for generating aspect ratio classes
|
|
208
|
+
/// @param {List} $aspect-ratios [$carbon--aspect-ratios] - A list of aspect ratios to generate
|
|
209
|
+
/// @access private
|
|
210
|
+
/// @group @carbon/grid
|
|
211
|
+
@mixin carbon--aspect-ratio($aspect-ratios: $carbon--aspect-ratios) {
|
|
212
|
+
.#{$prefix}--aspect-ratio {
|
|
213
|
+
height: 0;
|
|
214
|
+
position: relative;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.#{$prefix}--aspect-ratio--object {
|
|
218
|
+
position: absolute;
|
|
219
|
+
top: 0;
|
|
220
|
+
right: 0;
|
|
221
|
+
bottom: 0;
|
|
222
|
+
left: 0;
|
|
223
|
+
width: 100%;
|
|
224
|
+
height: 100%;
|
|
225
|
+
z-index: 100;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
@each $ratio in $aspect-ratios {
|
|
229
|
+
$width: nth($ratio, 1);
|
|
230
|
+
$height: nth($ratio, 2);
|
|
231
|
+
|
|
232
|
+
.#{$prefix}--aspect-ratio--#{$width}x#{$height} {
|
|
233
|
+
padding-bottom: percentage($height / $width);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// -----------------------------------------------------------------------------
|
|
239
|
+
// Grid
|
|
240
|
+
// -----------------------------------------------------------------------------
|
|
241
|
+
|
|
242
|
+
/// Create the container for a grid. Will cause full-bleed for the grid unless
|
|
243
|
+
/// max-width properties are added with `make-container-max-widths`
|
|
244
|
+
/// @param {Map} $breakpoints [$carbon--grid-breakpoints] - A map of breakpoints where the key is the name
|
|
245
|
+
/// @access private
|
|
246
|
+
/// @group @carbon/grid
|
|
247
|
+
@mixin carbon--make-container($breakpoints: $carbon--grid-breakpoints) {
|
|
248
|
+
margin-right: auto;
|
|
249
|
+
margin-left: auto;
|
|
250
|
+
|
|
251
|
+
@include carbon--set-largest-breakpoint();
|
|
252
|
+
|
|
253
|
+
@each $name, $value in $breakpoints {
|
|
254
|
+
$prev-breakpoint: map-get($breakpoints, carbon--breakpoint-prev($name));
|
|
255
|
+
$margin: map-get($value, margin);
|
|
256
|
+
|
|
257
|
+
@if $prev-breakpoint {
|
|
258
|
+
$prev-margin: map-get($prev-breakpoint, margin);
|
|
259
|
+
@if $prev-margin != $margin {
|
|
260
|
+
@include carbon--breakpoint($name) {
|
|
261
|
+
padding-left: #{($carbon--grid-gutter / 2) + $margin};
|
|
262
|
+
padding-right: #{($carbon--grid-gutter / 2) + $margin};
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
} @else {
|
|
266
|
+
@include carbon--breakpoint($name) {
|
|
267
|
+
padding-left: #{($carbon--grid-gutter / 2) + $margin};
|
|
268
|
+
padding-right: #{($carbon--grid-gutter / 2) + $margin};
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/// Get the last breakpoint width and set max-width to its value
|
|
275
|
+
/// @param {Map} $breakpoints [$carbon--grid-breakpoints] - A map of breakpoints where the key is the name
|
|
276
|
+
/// @access private
|
|
277
|
+
/// @group @carbon/grid
|
|
278
|
+
@mixin carbon--set-largest-breakpoint($breakpoints: $carbon--grid-breakpoints) {
|
|
279
|
+
$largest-breakpoint: last-map-item($breakpoints);
|
|
280
|
+
|
|
281
|
+
max-width: map-get($largest-breakpoint, 'width');
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/// Add in the max-widths for each breakpoint to the container
|
|
285
|
+
/// @param {Map} $breakpoints [$carbon--grid-breakpoints] - A map of breakpoints where the key is the name
|
|
286
|
+
/// @access private
|
|
287
|
+
/// @group @carbon/grid
|
|
288
|
+
@mixin carbon--make-container-max-widths(
|
|
289
|
+
$breakpoints: $carbon--grid-breakpoints
|
|
290
|
+
) {
|
|
291
|
+
@each $name, $value in $breakpoints {
|
|
292
|
+
@include carbon--breakpoint($name) {
|
|
293
|
+
max-width: map-get($value, width);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/// Generate the CSS for a grid for the given breakpoints and gutters
|
|
299
|
+
/// @param {Map} $breakpoints [$carbon--grid-breakpoints] - The default breakpoints
|
|
300
|
+
/// @param {Number} $grid-gutter [$carbon--grid-gutter] - The default gutters
|
|
301
|
+
/// @param {Number} $condensed-gutter [$carbon--grid-gutter--condensed] - The condensed mode gutter
|
|
302
|
+
/// @access public
|
|
303
|
+
/// @group @carbon/grid
|
|
304
|
+
@mixin carbon--grid(
|
|
305
|
+
$breakpoints: $carbon--grid-breakpoints,
|
|
306
|
+
$grid-gutter: $carbon--grid-gutter,
|
|
307
|
+
$condensed-gutter: $carbon--grid-gutter--condensed
|
|
308
|
+
) {
|
|
309
|
+
.#{$prefix}--grid {
|
|
310
|
+
@include carbon--make-container($breakpoints);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
@include carbon--largest-breakpoint($breakpoints) {
|
|
314
|
+
.#{$prefix}--grid--full-width {
|
|
315
|
+
max-width: 100%;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
.#{$prefix}--row {
|
|
320
|
+
@include carbon--make-row();
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
.#{$prefix}--grid--condensed .#{$prefix}--row:not(:last-of-type) {
|
|
324
|
+
margin-bottom: $condensed-gutter;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
.#{$prefix}--row--condensed + .#{$prefix}--row--condensed {
|
|
328
|
+
margin-top: $condensed-gutter;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
@include carbon--make-grid-columns($breakpoints, $grid-gutter);
|
|
332
|
+
@include carbon--no-gutter();
|
|
333
|
+
@include carbon--hang($grid-gutter);
|
|
334
|
+
@include carbon--aspect-ratio();
|
|
335
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright IBM Corp. 2018, 2018
|
|
3
|
+
//
|
|
4
|
+
// This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
// LICENSE file in the root directory of this source tree.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
/// Namespace prefix
|
|
9
|
+
/// @type String
|
|
10
|
+
/// @access public
|
|
11
|
+
/// @group @carbon/grid
|
|
12
|
+
$prefix: 'bx' !default;
|
package/scss/_mixins.scss
CHANGED
|
@@ -202,7 +202,7 @@
|
|
|
202
202
|
/// @type List
|
|
203
203
|
/// @access public
|
|
204
204
|
/// @group @carbon/grid
|
|
205
|
-
$carbon--aspect-ratios: ((16, 9), (2, 1), (4, 3), (1, 1));
|
|
205
|
+
$carbon--aspect-ratios: ((16, 9), (2, 1), (4, 3), (1, 1), (1, 2));
|
|
206
206
|
|
|
207
207
|
/// Output the CSS classes for generating aspect ratio classes
|
|
208
208
|
/// @param {List} $aspect-ratios [$carbon--aspect-ratios] - A list of aspect ratios to generate
|
package/scss/grid.scss
CHANGED
package/scss/index.scss
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright IBM Corp. 2018, 2018
|
|
3
|
+
//
|
|
4
|
+
// This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
// LICENSE file in the root directory of this source tree.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
/// Used by `exports` mixin to track which modules have been imported
|
|
9
|
+
/// @type Map
|
|
10
|
+
/// @access public
|
|
11
|
+
/// @group @carbon/import-once
|
|
12
|
+
$imported-modules: () !default;
|
|
13
|
+
|
|
14
|
+
/// Module export mixin that helps making sure a module is imported once and only once
|
|
15
|
+
/// @access public
|
|
16
|
+
/// @param {String} $name - Name of exported module
|
|
17
|
+
/// @param {Bool} $warn [false] - Warn when a module has been already imported
|
|
18
|
+
/// @content Declaration blocks to be imported
|
|
19
|
+
/// @group @carbon/import-once
|
|
20
|
+
@mixin exports($name, $warn: false) {
|
|
21
|
+
@if (index($imported-modules, $name) == null) {
|
|
22
|
+
$imported-modules: append($imported-modules, $name) !global;
|
|
23
|
+
@content;
|
|
24
|
+
} @else if $warn == true {
|
|
25
|
+
@warn 'Module `#{$name}` has already been imported.';
|
|
26
|
+
}
|
|
27
|
+
}
|