@penskemediacorp/larva-css 1.5.0-alpha.0 → 1.5.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/LICENSE +21 -0
- package/README.md +193 -37
- package/__tests__/fixtures/expected.js +29 -0
- package/__tests__/lib/generators.test.js +11 -0
- package/browser-test-setup.js +26 -0
- package/build/css/algorithms.common.async.css +4 -0
- package/build/css/algorithms.common.inline.css +21 -0
- package/build/css/generic.common.inline.css +4 -0
- package/build/css/js.common.async.css +3 -0
- package/build/css/js.common.inline.css +6 -0
- package/build/css/utilities.common.async.css +8 -0
- package/build/css/utilities.common.inline.css +27 -0
- package/gulpfile.js +123 -0
- package/lib/generators.js +93 -0
- package/package.json +14 -15
- package/src/01-generic/elements.common.inline.scss +37 -1
- package/src/01-generic/forms.common.inline.scss +10 -0
- package/src/01-generic/side-skins.common.inline.scss +10 -0
- package/src/01-generic/typography.common.inline.scss +24 -13
- package/src/02-algorithms/README.md +65 -0
- package/src/02-algorithms/a-buy-now/a-buy-now.common.inline.scss +112 -0
- package/src/02-algorithms/a-carousel-grid/a-carousel-grid.common.inline.scss +66 -0
- package/src/02-algorithms/a-children-border/a-children-border.common.inline.scss +43 -0
- package/src/02-algorithms/a-children-link-color/a-children-link-color.common.inline.scss +15 -0
- package/src/02-algorithms/a-children-link-decoration/a-children-link-decoration.common.inline.scss +13 -0
- package/src/02-algorithms/a-counter/a-counter.common.inline.scss +26 -0
- package/src/02-algorithms/a-crop/README.md +17 -13
- package/src/02-algorithms/a-crop/a-crop.common.inline.scss +97 -12
- package/src/02-algorithms/a-crop/a-crop.html +2 -2
- package/src/02-algorithms/a-floated/a-floated.common.inline.scss +32 -0
- package/src/02-algorithms/a-font/a-font.common.inline.scss +3 -0
- package/src/02-algorithms/a-glue/a-glue.common.inline.scss +63 -6
- package/src/02-algorithms/a-glue/a-glue.html +3 -3
- package/src/02-algorithms/a-grid/README.md +141 -14
- package/src/02-algorithms/a-grid/a-grid.common.inline.scss +58 -6
- package/src/02-algorithms/a-grid/a-grid.html +4 -4
- package/src/02-algorithms/a-hidden/a-hidden.common.inline.scss +43 -0
- package/src/02-algorithms/a-hover-dropup/a-hover-dropup.common.async.scss +9 -8
- package/src/02-algorithms/a-hover-dropup/a-hover-dropup.html +3 -3
- package/src/02-algorithms/a-hover-effect/a-hover-effect.common.async.scss +25 -0
- package/src/02-algorithms/a-hover-effect/a-hover-effect.html +16 -0
- package/src/02-algorithms/a-icon/a-icon.common.async.scss +36 -0
- package/src/02-algorithms/a-icon/a-icon.common.inline.scss +56 -70
- package/src/02-algorithms/a-screen-reader-only/a-screen-reader-only.common.inline.scss +30 -0
- package/src/02-algorithms/a-scrollable-grid/a-scrollable-grid.common.inline.scss +52 -0
- package/src/02-algorithms/a-show-on-hover/a-show-on-hover.common.inline.scss +16 -0
- package/src/02-algorithms/a-space-children/a-space-children.common.inline.scss +88 -17
- package/src/02-algorithms/a-truncate-ellipsis/a-truncate-ellipsis.common.async.scss +71 -0
- package/src/02-algorithms/a-unstyle-button/a-unstyle-button.common.inline.scss +2 -3
- package/src/02-algorithms/a-unstyle-link/a-unstyle-link.common.inline.scss +7 -0
- package/src/02-algorithms/a-unstyle-list/a-unstyle-list.common.inline.scss +1 -1
- package/src/02-algorithms/a-wrapper/a-wrapper.common.inline.scss +14 -2
- package/src/03-utilities/u-background-color.common.async.scss +15 -0
- package/src/03-utilities/u-background-color.common.inline.scss +37 -0
- package/src/03-utilities/u-border-color.common.async.scss +38 -6
- package/src/03-utilities/u-border-radius.common.async.scss +27 -0
- package/src/03-utilities/u-border.common.inline.scss +216 -3
- package/src/03-utilities/u-box-alignment.common.inline.scss +64 -4
- package/src/03-utilities/u-box-shadow.common.async.scss +37 -3
- package/src/03-utilities/u-color.common.async.scss +20 -15
- package/src/03-utilities/u-color.common.inline.scss +39 -0
- package/src/03-utilities/u-cursor.common.async.scss +1 -1
- package/src/03-utilities/u-display.common.inline.scss +86 -3
- package/src/03-utilities/u-filter.common.async.scss +5 -0
- package/src/03-utilities/u-flex.common.inline.scss +128 -9
- package/src/03-utilities/u-font-family.common.inline.scss +41 -16
- package/src/03-utilities/u-font-size.common.inline.scss +58 -5
- package/src/03-utilities/u-font-style.common.inline.scss +9 -0
- package/src/03-utilities/u-font-weight.common.inline.scss +50 -12
- package/src/03-utilities/u-height.common.inline.scss +41 -5
- package/src/03-utilities/u-letter-spacing.common.inline.scss +11 -0
- package/src/03-utilities/u-line-height.common.inline.scss +49 -13
- package/src/03-utilities/u-list-style.common.async.scss +3 -0
- package/src/03-utilities/u-margin.common.inline.scss +186 -46
- package/src/03-utilities/u-max-width.common.inline.scss +25 -0
- package/src/03-utilities/u-opacity.common.inline.scss +3 -0
- package/src/03-utilities/u-order.common.inline.scss +23 -2
- package/src/03-utilities/u-overflow.common.inline.scss +15 -0
- package/src/03-utilities/u-padding.common.inline.scss +157 -52
- package/src/03-utilities/u-position.common.inline.scss +3 -0
- package/src/03-utilities/u-text-align.common.inline.scss +32 -3
- package/src/03-utilities/u-text-decoration.common.inline.scss +11 -0
- package/src/03-utilities/u-text-transform.common.inline.scss +14 -2
- package/src/03-utilities/u-transform.common.inline.scss +5 -0
- package/src/03-utilities/u-vertical-align.common.inline.scss +7 -0
- package/src/03-utilities/u-whitespace.common.inline.scss +1 -1
- package/src/03-utilities/u-width.common.inline.scss +191 -7
- package/src/04-js/README.md +5 -0
- package/src/04-js/js-Collapsible.common.inline.scss +15 -0
- package/src/04-js/js-ExpandableSearch.common.async.scss +33 -0
- package/src/04-js/js-Flickity.common.async.scss +91 -0
- package/src/04-js/js-Header.common.inline.scss +73 -0
- package/src/04-js/js-MegaMenu.common.inline.scss +50 -0
- package/src/04-js/js-MobileHeightToggle.common.inline.scss +7 -5
- package/src/04-js/js-PopOver.common.async.scss +13 -0
- package/src/04-js/js-Tooltip.common.inline.scss +17 -0
- package/src/04-js/js-VideoShowcase.common.inline.scss +33 -0
- package/src/04-js/partials/expandable-search.scss +202 -0
- package/src/04-js/partials/flickity.scss +149 -0
- package/src/_generated/_a-font.scss +1027 -0
- package/src/larva-ui/prism.scss +127 -0
- package/src/setup.scss +7 -0
- package/stylelint.config.js +45 -0
- package/src/01-generic/config.common.inline.scss +0 -20
- package/src/02-algorithms/a-glue/index.js +0 -1
- package/src/02-algorithms/a-icon/a-icon.html +0 -20
- package/src/02-algorithms/a-unstyle-link/a-unstyle-link.common.async.scss +0 -5
- package/src/03-utilities/u-background.common.async.scss +0 -14
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
|
|
2
|
+
# CSS Algorithms
|
|
3
|
+
|
|
4
|
+
## Anatomy
|
|
5
|
+
|
|
6
|
+
Each algorithm should contain the following files:
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
|-- a-name
|
|
10
|
+
|-- a-name.{chunkName}.{async|inline}.{scss|css}
|
|
11
|
+
|-- a-name.html
|
|
12
|
+
|-- a-name.browser-test.js
|
|
13
|
+
|-- README.md
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
The HTML file should contain the minimum HTML required to reflect the functionality.
|
|
17
|
+
|
|
18
|
+
### CSS-only wherever possible!
|
|
19
|
+
|
|
20
|
+
If you algorithm does not use any Sass, there is no need to pre-process it through Sass, so you can work directly in a CSS file. Although this might be unusual since we need to use tokens for a lot of styling, we should try to use CSS-only wherever possible! When developing relative layouts with CSS Grid, this is certainly a possibility.
|
|
21
|
+
|
|
22
|
+
### Naming the Algorithm
|
|
23
|
+
|
|
24
|
+
The name of the algorithm should be presentational in nature, and indicative of the CSS programming, _not_ oriented around the name of a UI element. Algorithms follow the development practice of small, well-named functions.
|
|
25
|
+
|
|
26
|
+
For example, `a-card-title` is a very poor algorithm name because it does not tell a fellow developer _what_ the CSS algorithm is doing. Essentially, any CSS could be in something called `a-card-title`. Some better names might be:
|
|
27
|
+
|
|
28
|
+
* `a-minmax-font-size` for an algorithm that controls the min and max in the font-size property.
|
|
29
|
+
* `a-vertically-centered-border-behind` for an algorithm that adds a vertically centered border behind an element.
|
|
30
|
+
* `a-fade-in-on-hover-before` for an algorithm that fades in the `::before` pseudo-element when its hover state is triggered.
|
|
31
|
+
|
|
32
|
+
### Naming the (S)CSS File
|
|
33
|
+
|
|
34
|
+
The algorithm's CSS file should be named according to the chunk it will be included in when used in an actual product. Example, full file names (note that these may have originated as SCSS files):
|
|
35
|
+
|
|
36
|
+
* `a-minmax-font-size.common.inline.css`
|
|
37
|
+
* `a-offset-dots-behind.single.async.css`
|
|
38
|
+
* `a-gradient-after.common.async.css`
|
|
39
|
+
* `a-archive-grid.archive.inline.css`
|
|
40
|
+
|
|
41
|
+
Note that the algorihtm name should be the _base_ name of the algorithm. These files may contain classes with responsive suffixes, elements, and modifiers, but it only necessary to include the base name in the file. Read on for further description of these naming parameters.
|
|
42
|
+
|
|
43
|
+
#### `chunkName`
|
|
44
|
+
|
|
45
|
+
The name of the chunk where this algorithm should be included. Most algorithms will be `common`, but there will certainly be cases when algorithms are written for specifc projects that may have their own chunk naming convention. When naming chunks in a WordPress theme, they should map directly 1 to 1 with the queried template where the CSS is equeued or inlined.
|
|
46
|
+
|
|
47
|
+
#### `async` or `inline`
|
|
48
|
+
|
|
49
|
+
These terms refer to whether or not the algorithm should be included in inlined, or "critical CSS", or in a file loaded asynchronously.
|
|
50
|
+
|
|
51
|
+
`inline` should be used for CSS that is applied to elements that are both "above the fold" and contain properties that come into play at the layout phase in rendering. In other words, they are crucial for the first paint of the page. Examples are any properties part of the box model, positioning, layout APIs like Grid and Flexbox, font sizing, and more.
|
|
52
|
+
|
|
53
|
+
`async` should be used for CSS that is not critical to the first paint i.e. to making the page content readable, and that apply during the paint and composite phases of rendering. These are properties like color, background, transition, and box-shadow.
|
|
54
|
+
|
|
55
|
+
## Usage
|
|
56
|
+
|
|
57
|
+
Refer to the README for each algorithm for usage instructions.
|
|
58
|
+
|
|
59
|
+
## Development
|
|
60
|
+
|
|
61
|
+
Algorithms should be developed and build within a single SCSS file that outputs CSS to a file in the same directory with the same name. There is a watch command registered using the node-sass CLI that can be run from the packages/css-algorithms with the command `npm run sass`.
|
|
62
|
+
|
|
63
|
+
## Testing
|
|
64
|
+
|
|
65
|
+
CSS algorithms should have tests where possible. These tests are written in client side JavaScript and can be included in both the example HTML file in each pattern for unit testing, or included in any environment using the algorithm for integration tests.
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
@import 'setup';
|
|
2
|
+
|
|
3
|
+
.lrv-a-buy-now {
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
align-items: center;
|
|
7
|
+
position: relative;
|
|
8
|
+
|
|
9
|
+
@include pmc-breakpoint( tablet ) {
|
|
10
|
+
display: block;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.lrv-a-buy-now__image {
|
|
15
|
+
position: relative;
|
|
16
|
+
z-index: 1;
|
|
17
|
+
width: 100%;
|
|
18
|
+
background-color: $color-white;
|
|
19
|
+
max-width: pmc-rem(300);
|
|
20
|
+
|
|
21
|
+
@include pmc-breakpoint( tablet ) {
|
|
22
|
+
width: pmc-rem(190); // 160 + 30
|
|
23
|
+
left: 0;
|
|
24
|
+
padding: 0 pmc-rem(30) 0 0;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@include pmc-breakpoint( desktop ) {
|
|
28
|
+
width: pmc-rem(245); // 185 + 30 + 30
|
|
29
|
+
left: pmc-rem(94);
|
|
30
|
+
padding: 0 pmc-rem(30);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.lrv-a-buy-now__button {
|
|
35
|
+
margin-top: pmc-rem(16);
|
|
36
|
+
|
|
37
|
+
@include pmc-breakpoint( tablet ) {
|
|
38
|
+
margin-top: 0;
|
|
39
|
+
position: absolute;
|
|
40
|
+
top: 50%;
|
|
41
|
+
left: pmc-rem(190);
|
|
42
|
+
transform: translateY(-50%);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@include pmc-breakpoint( desktop ) {
|
|
46
|
+
left: pmc-rem(339);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.lrv-a-buy-now__hr {
|
|
51
|
+
display: none;
|
|
52
|
+
margin: 0;
|
|
53
|
+
padding: 0;
|
|
54
|
+
border-top: pmc-rem(0.5) solid #000;
|
|
55
|
+
position: relative;
|
|
56
|
+
|
|
57
|
+
@include pmc-breakpoint( tablet ) {
|
|
58
|
+
display: block;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.lrv-a-buy-now__hr--top {
|
|
63
|
+
top: 0;
|
|
64
|
+
|
|
65
|
+
@include pmc-breakpoint( tablet ) {
|
|
66
|
+
top: pmc-rem(37);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@include pmc-breakpoint( desktop ) {
|
|
70
|
+
top: pmc-rem(50);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.lrv-a-buy-now__hr--bottom {
|
|
75
|
+
bottom: 0;
|
|
76
|
+
|
|
77
|
+
@include pmc-breakpoint( tablet ) {
|
|
78
|
+
bottom: pmc-rem(37);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@include pmc-breakpoint( desktop ) {
|
|
82
|
+
bottom: pmc-rem(50);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Optional span.
|
|
87
|
+
.lrv-a-buy-now__span {
|
|
88
|
+
display: none;
|
|
89
|
+
position: absolute;
|
|
90
|
+
right: 0;
|
|
91
|
+
|
|
92
|
+
@include pmc-breakpoint( tablet ) {
|
|
93
|
+
display: block;
|
|
94
|
+
bottom: pmc-rem(16);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@include pmc-breakpoint( desktop ) {
|
|
98
|
+
bottom: pmc-rem(29);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Used when image is not present.
|
|
103
|
+
.lrv-a-buy-now__p {
|
|
104
|
+
display: flex;
|
|
105
|
+
flex-direction: column;
|
|
106
|
+
align-items: center;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.lrv-a-buy-now__p .lrv-a-buy-now__button {
|
|
110
|
+
position: inherit;
|
|
111
|
+
transform: none;
|
|
112
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
@import 'setup';
|
|
2
|
+
|
|
3
|
+
.lrv-a-carousel-grid {
|
|
4
|
+
--grid-overlay: initial;
|
|
5
|
+
|
|
6
|
+
display: grid;
|
|
7
|
+
grid-template-columns: 1fr;
|
|
8
|
+
|
|
9
|
+
@include pmc-breakpoint( tablet ) {
|
|
10
|
+
grid-gap: var(--spacing-050);
|
|
11
|
+
grid-template-columns: 2fr 1fr;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.lrv-a-carousel-grid__overlay {
|
|
16
|
+
--grid-overlay: grid;
|
|
17
|
+
|
|
18
|
+
@include pmc-breakpoint( tablet ) {
|
|
19
|
+
grid-template-columns: 1fr;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.lrv-a-carousel-grid__overlay--primary {
|
|
24
|
+
|
|
25
|
+
@include pmc-breakpoint( desktop ) {
|
|
26
|
+
display: var(--grid-overlay);
|
|
27
|
+
grid-template-columns: 1fr 1.5rem 2fr;
|
|
28
|
+
align-items: center;
|
|
29
|
+
grid-auto-flow: column;
|
|
30
|
+
height: 100%;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.lrv-a-carousel-grid__overlay--primary-img {
|
|
35
|
+
|
|
36
|
+
@include pmc-breakpoint( desktop ) {
|
|
37
|
+
grid-column: 2/4;
|
|
38
|
+
grid-row: 1;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.lrv-a-carousel-grid__overlay--primary-content {
|
|
43
|
+
|
|
44
|
+
@include pmc-breakpoint( desktop ) {
|
|
45
|
+
grid-column: 1/3;
|
|
46
|
+
grid-row: 1;
|
|
47
|
+
padding: 1.875rem;
|
|
48
|
+
z-index: 1;
|
|
49
|
+
background-color: #fff;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.lrv-a-carousel-grid__overlay--secondary {
|
|
54
|
+
|
|
55
|
+
@include pmc-breakpoint( desktop ) {
|
|
56
|
+
display: var(--grid-overlay);
|
|
57
|
+
grid-template-columns: repeat(3,1fr);
|
|
58
|
+
grid-gap: var(--spacing-125);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.lrv-a-carousel-grid__overlay--secondary-card {
|
|
63
|
+
display: var(--grid-overlay);
|
|
64
|
+
grid-template-columns: 6.25rem 1fr;
|
|
65
|
+
grid-gap: var(--spacing-1);
|
|
66
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
@import 'setup';
|
|
2
|
+
|
|
3
|
+
:root {
|
|
4
|
+
--a-children-border-color: #{ map-get( $TOKENS-MAP, color-black ) };
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.lrv-a-children-border--grey {
|
|
8
|
+
--a-children-border-color: #{ map-get( $TOKENS-MAP, border-color-grey ) };
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.lrv-a-children-border--grey-light {
|
|
12
|
+
--a-children-border-color: #{ map-get( $TOKENS-MAP, border-color-grey-light ) };
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// stylelint-disable selector-max-compound-selectors
|
|
16
|
+
.lrv-a-children-border-vertical {
|
|
17
|
+
& > * + * {
|
|
18
|
+
border-top: var(--a-children-border-width, 1px) solid var(--a-children-border-color, '');
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.lrv-a-children-border-vertical\@mobile-max {
|
|
23
|
+
@include pmc-breakpoint(mobile-max) {
|
|
24
|
+
& > * + * {
|
|
25
|
+
border-top: var(--a-children-border-width, 1px) solid var(--a-children-border-color, '');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.lrv-a-children-border-horizontal {
|
|
31
|
+
& > * + * {
|
|
32
|
+
border-left: var(--a-children-border-width, 1px) solid var(--a-children-border-color, '');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.lrv-a-children-border-horizontal\@desktop {
|
|
37
|
+
@include pmc-breakpoint(desktop) {
|
|
38
|
+
& > * + * {
|
|
39
|
+
border-left: var(--a-children-border-width, 1px) solid var(--a-children-border-color, '');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
// stylelint-enable selector-max-compound-selectors
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
@import 'setup';
|
|
2
|
+
|
|
3
|
+
.lrv-a-children-link-color-black {
|
|
4
|
+
& > a {
|
|
5
|
+
color: map-get( $TOKENS-MAP, color-black );
|
|
6
|
+
color: var( --color-black );
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.lrv-a-children-link-color-brand-primary\:hover {
|
|
11
|
+
& > a:hover {
|
|
12
|
+
color: map-get( $TOKENS-MAP, color-brand-primary );
|
|
13
|
+
color: var( --color-brand-primary );
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
.lrv-a-counter {
|
|
2
|
+
counter-reset: a-counter;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.lrv-a-counter-increment {
|
|
6
|
+
counter-increment: a-counter;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.lrv-a-counter-before::before {
|
|
10
|
+
content: counter( a-counter );
|
|
11
|
+
display: var( --a-counter__display, inline-block);
|
|
12
|
+
padding: var( --a-counter__padding, initial );
|
|
13
|
+
background-color: var( --a-counter__background-color, initial );
|
|
14
|
+
color: var( --a-counter__color, inherit );
|
|
15
|
+
border-top-right-radius: var( --a-counter__border-top-right-radius, inherit );
|
|
16
|
+
font-family: var( --a-counter__font-family, inherit );
|
|
17
|
+
font-size: var( --a-counter__font-size, inherit ); // stylelint-disable-line property-blacklist
|
|
18
|
+
line-height: var( --a-counter__line-height, 0.7 );
|
|
19
|
+
font-weight: var( --a-counter__font-weight, inherit ); // stylelint-disable-line property-blacklist
|
|
20
|
+
z-index: 1;
|
|
21
|
+
position: var( --a-counter__position, initial );
|
|
22
|
+
left: var( --a-counter__left, auto );
|
|
23
|
+
top: var( --a-counter__top, auto );
|
|
24
|
+
right: var( --a-counter__right, auto );
|
|
25
|
+
bottom: var( --a-counter__bottom, auto );
|
|
26
|
+
}
|
|
@@ -1,31 +1,35 @@
|
|
|
1
|
-
#
|
|
1
|
+
# a-crop
|
|
2
2
|
|
|
3
3
|
The cropping algorithm applies an aspect ratio to a element containing an image, and will crop the contained image to the aspect ratio. It uses background-size: cover, padding, and absolute positioning to do this.
|
|
4
4
|
|
|
5
|
-
The classes output by the generator are `.
|
|
5
|
+
The classes output by the generator are `.a-crop-WIDTHxHEIGHT`, so a 16x9 cropped image would use the class `.a-crop-16x9`.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Available Classes
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
.pmc-a-crop-2x3
|
|
13
|
-
.pmc-a-crop-4x3
|
|
14
|
-
.pmc-a-crop-16x9
|
|
15
|
-
.pmc-a-crop-3x4
|
|
16
|
-
```
|
|
9
|
+
Reference the Sass list in a-crop.common.inline.scss to see a list of a-crop classes provided by Larva CSS.
|
|
10
|
+
|
|
11
|
+
## Algorithm Source
|
|
17
12
|
|
|
18
13
|
The source for the cropping algorithm is:
|
|
14
|
+
|
|
19
15
|
```
|
|
20
|
-
.
|
|
16
|
+
.lrv-a-crop-16x9 {
|
|
21
17
|
position: relative;
|
|
22
18
|
padding-bottom: calc( ( 9 / 16 ) * 100%);
|
|
23
19
|
}
|
|
24
20
|
|
|
25
|
-
.
|
|
21
|
+
.lrv-a-crop-16x9 img {
|
|
26
22
|
position: absolute;
|
|
27
23
|
width: 100%;
|
|
28
24
|
height: 100%;
|
|
29
25
|
object-fit: cover;
|
|
30
26
|
}
|
|
31
27
|
```
|
|
28
|
+
|
|
29
|
+
## Extendable?
|
|
30
|
+
|
|
31
|
+
**Do no extend `a-crop`**. Create a separate algorithm, or use utilities for properties like the following:
|
|
32
|
+
|
|
33
|
+
* object-fit - change the scaling behavior of the image e.g. `u-object-fit-contain`.
|
|
34
|
+
* object-position - change the alignment of a cropped image, e.g. align it to the top rather than center.
|
|
35
|
+
* background-color – update the background color that may appear while an image is loading.
|
|
@@ -1,12 +1,97 @@
|
|
|
1
|
-
@import '
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
)
|
|
12
|
-
)
|
|
1
|
+
@import 'setup';
|
|
2
|
+
|
|
3
|
+
$aspect-ratios: (
|
|
4
|
+
'1x1': (1, 1),
|
|
5
|
+
'2x1': (2, 1),
|
|
6
|
+
'2x3': (2, 3),
|
|
7
|
+
'3x2': (3, 2),
|
|
8
|
+
'4x3': (4, 3),
|
|
9
|
+
'16x9': (16, 9),
|
|
10
|
+
'5x1': (5, 1),
|
|
11
|
+
'5x2': (5, 2),
|
|
12
|
+
'3x4': (3, 4)
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
@include a-crop( $aspect-ratios, $NAMESPACE: 'lrv-' );
|
|
16
|
+
|
|
17
|
+
.lrv-a-crop-contain img { // Required for a-crop
|
|
18
|
+
object-fit: contain;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.lrv-a-crop-1x1\@mobile-max {
|
|
22
|
+
@include pmc-breakpoint( mobile-max ) {
|
|
23
|
+
|
|
24
|
+
position: relative;
|
|
25
|
+
padding-bottom: 100%;
|
|
26
|
+
|
|
27
|
+
img {
|
|
28
|
+
position: absolute;
|
|
29
|
+
width: 100%;
|
|
30
|
+
height: 100%;
|
|
31
|
+
object-fit: cover;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.lrv-a-crop-1x1\@tablet {
|
|
38
|
+
@include pmc-breakpoint( tablet ) {
|
|
39
|
+
|
|
40
|
+
position: relative;
|
|
41
|
+
padding-bottom: 100%;
|
|
42
|
+
|
|
43
|
+
img {
|
|
44
|
+
position: absolute;
|
|
45
|
+
width: 100%;
|
|
46
|
+
height: 100%;
|
|
47
|
+
object-fit: cover;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.lrv-a-crop-1x1\@desktop-xl-max {
|
|
54
|
+
@include pmc-breakpoint( desktop-xl-max ) {
|
|
55
|
+
|
|
56
|
+
position: relative;
|
|
57
|
+
padding-bottom: 100%;
|
|
58
|
+
|
|
59
|
+
img {
|
|
60
|
+
position: absolute;
|
|
61
|
+
width: 100%;
|
|
62
|
+
height: 100%;
|
|
63
|
+
object-fit: cover;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.lrv-a-crop-3x2\@desktop-xl {
|
|
69
|
+
@include pmc-breakpoint( desktop-xl ) {
|
|
70
|
+
|
|
71
|
+
position: relative;
|
|
72
|
+
padding-bottom: calc( ( 2 / 3 ) * 100% );
|
|
73
|
+
|
|
74
|
+
img {
|
|
75
|
+
position: absolute;
|
|
76
|
+
width: 100%;
|
|
77
|
+
height: 100%;
|
|
78
|
+
object-fit: cover;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
.lrv-a-crop-3x2\@mobile-max {
|
|
85
|
+
@include pmc-breakpoint( mobile-max ) {
|
|
86
|
+
|
|
87
|
+
position: relative;
|
|
88
|
+
padding-bottom: calc( ( 2 / 3 ) * 100% );
|
|
89
|
+
|
|
90
|
+
img {
|
|
91
|
+
position: absolute;
|
|
92
|
+
width: 100%;
|
|
93
|
+
height: 100%;
|
|
94
|
+
object-fit: cover;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
|
11
11
|
|
|
12
|
-
<div class="
|
|
12
|
+
<div class="lrv-a-crop-16x9" style="width: 600px;">
|
|
13
13
|
<img src="https://pmcdeadline2.files.wordpress.com/2019/07/jonathan-majors.jpg" alt="">
|
|
14
14
|
</div>
|
|
15
15
|
<hr>
|
|
16
|
-
<div class="
|
|
16
|
+
<div class="lrv-a-crop-3x4" style="width: 400px;">
|
|
17
17
|
<img src="https://pmcdeadline2.files.wordpress.com/2019/07/jonathan-majors.jpg" alt="">
|
|
18
18
|
</div>
|
|
19
19
|
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
@import '@penskemediacorp/larva-scss/dist/tools';
|
|
2
|
+
|
|
3
|
+
.lrv-a-floated-parent::before,
|
|
4
|
+
.lrv-a-floated-parent::after {
|
|
5
|
+
content: '';
|
|
6
|
+
display: table;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.lrv-a-floated-parent::after {
|
|
10
|
+
clear: both;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.lrv-a-floated-parent {
|
|
14
|
+
zoom: 1;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.lrv-a-floated-left {
|
|
18
|
+
float: left;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.lrv-a-floated-left\@tablet {
|
|
22
|
+
|
|
23
|
+
@include pmc-breakpoint( tablet ) {
|
|
24
|
+
float: left;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.lrv-a-floated-right\@tablet {
|
|
29
|
+
@include pmc-breakpoint(tablet) {
|
|
30
|
+
float: right;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
left: var( --a-glue-left, initial );
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
.
|
|
13
|
+
.lrv-a-glue-parent {
|
|
14
14
|
position: relative;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
.
|
|
17
|
+
.lrv-a-glue {
|
|
18
18
|
// Fallback is top left for everything.
|
|
19
19
|
top: 0;
|
|
20
20
|
left: 0;
|
|
@@ -22,18 +22,75 @@
|
|
|
22
22
|
@include _a-glue-base;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
@include pmc-breakpoint( mobile-max ) {
|
|
26
|
+
.lrv-a-glue\@mobile-max {
|
|
27
|
+
top: 0;
|
|
28
|
+
left: 0;
|
|
29
|
+
|
|
30
|
+
@include _a-glue-base;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.lrv-a-glue\@tablet {
|
|
35
|
+
@include pmc-breakpoint( tablet ) {
|
|
36
|
+
// TODO: incorporate these fallback values into mixin
|
|
37
|
+
top: 0;
|
|
38
|
+
left: 0;
|
|
39
|
+
|
|
40
|
+
@include _a-glue-base;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.lrv-a-glue--l-0 {
|
|
26
45
|
--a-glue-left: 0;
|
|
27
46
|
}
|
|
28
47
|
|
|
29
|
-
.
|
|
48
|
+
.lrv-a-glue--r-0 {
|
|
30
49
|
--a-glue-right: 0;
|
|
31
50
|
}
|
|
32
51
|
|
|
33
|
-
.
|
|
52
|
+
.lrv-a-glue--t-0 {
|
|
34
53
|
--a-glue-top: 0;
|
|
35
54
|
}
|
|
36
55
|
|
|
37
|
-
.
|
|
56
|
+
.lrv-a-glue--b-0 {
|
|
38
57
|
--a-glue-bottom: 0;
|
|
39
58
|
}
|
|
59
|
+
|
|
60
|
+
.lrv-a-glue--t-50p {
|
|
61
|
+
--a-glue-top: 50%;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.lrv-a-glue--t-100p {
|
|
65
|
+
--a-glue-top: 100%;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.lrv-a-glue--l-50p {
|
|
69
|
+
--a-glue-left: 50%;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.lrv-a-glue--r-50p {
|
|
73
|
+
--a-glue-right: 50%;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.lrv-a-glue--b-n1 {
|
|
77
|
+
--a-glue-bottom: -1rem;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.lrv-a-glue-parent\@mobile-max {
|
|
81
|
+
@include pmc-breakpoint( mobile-max ) {
|
|
82
|
+
position: relative;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.lrv-a-glue-parent\@tablet {
|
|
87
|
+
@include pmc-breakpoint( tablet ) {
|
|
88
|
+
position: relative;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.lrv-a-glue--b-unset\@mobile-max {
|
|
93
|
+
@include pmc-breakpoint( mobile-max ) {
|
|
94
|
+
bottom: unset;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
|
7
7
|
<title>Document</title>
|
|
8
|
-
<link rel="stylesheet" href="
|
|
8
|
+
<link rel="stylesheet" href="../../../build/css/algorithms.common.inline.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
|
11
|
-
<div class="a-glue-parent" style="display: inline-block;">
|
|
11
|
+
<div class="lrv-a-glue-parent" style="display: inline-block;">
|
|
12
12
|
<img src="http://placehold.it/300x300" alt="">
|
|
13
|
-
<p class="a-glue a-glue--t-0 a-glue--r-0">Glued Element</p>
|
|
13
|
+
<p class="lrv-a-glue lrv-a-glue--t-0 lrv-a-glue--r-0">Glued Element</p>
|
|
14
14
|
</div>
|
|
15
15
|
</body>
|
|
16
16
|
</html>
|