vanilla-framework 4.26.0 → 4.26.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vanilla-framework",
3
- "version": "4.26.0",
3
+ "version": "4.26.1",
4
4
  "author": {
5
5
  "email": "webteam@canonical.com",
6
6
  "name": "Canonical Webteam"
@@ -7,8 +7,6 @@
7
7
  align-self: center;
8
8
  background-size: map-get($icon-sizes, small);
9
9
  flex: 0 0 auto;
10
- // Space chip away from the content preceding it in the chip body
11
- margin-left: $sph--x-small;
12
10
  @media (min-width: $breakpoint-x-large) {
13
11
  background-size: math.div(map-get($icon-sizes, small), $font-size-ratio--largescreen); //ensure no rounding happens as it positions the icon off center
14
12
  }
@@ -58,6 +56,8 @@
58
56
  @include vf-icon-close-themed;
59
57
 
60
58
  border-radius: 50%;
59
+ // Space away from the content preceding it in the chip body
60
+ margin-left: $sph--x-small;
61
61
  }
62
62
 
63
63
  & > [class*='p-icon--'] {
@@ -25,25 +25,47 @@
25
25
  Image element within an image container.
26
26
  */
27
27
 
28
- @use 'sass:color';
28
+ @use 'sass:math';
29
29
  @import 'settings';
30
30
 
31
- // Mapping of aspect ratio class names to their `aspect-ratio` values (width / height).
31
+ // Mapping of aspect ratio class names to their values
32
32
  $aspect-ratios: (
33
- '16-9': calc(16 / 9),
34
- '3-2': calc(3 / 2),
35
- '2-3': calc(2 / 3),
33
+ '16-9': math.div(16, 9),
34
+ '3-2': math.div(3, 2),
35
+ '2-3': math.div(2, 3),
36
36
  'cinematic': 2.4,
37
37
  'square': 1,
38
38
  );
39
39
 
40
+ @mixin apply-aspect-ratio-styles($padding-value) {
41
+ &::before {
42
+ content: '';
43
+ display: block;
44
+ padding-bottom: $padding-value;
45
+ }
46
+
47
+ .p-image-container__image {
48
+ bottom: 0;
49
+ left: 0;
50
+ margin: auto;
51
+ max-height: 100%;
52
+ max-width: 100%;
53
+ object-fit: contain;
54
+ position: absolute;
55
+ right: 0;
56
+ top: 0;
57
+ }
58
+ }
59
+
40
60
  @mixin aspect-ratio-classes {
41
61
  @each $aspect-ratio, $aspect-ratio-value in $aspect-ratios {
62
+ $padding-percentage: math.div(1, $aspect-ratio-value) * 100%;
42
63
  .p-image-container--#{$aspect-ratio} {
43
- aspect-ratio: $aspect-ratio-value;
64
+ @include apply-aspect-ratio-styles($padding-percentage);
44
65
  }
45
66
  }
46
67
 
68
+ // Responsive aspect ratios
47
69
  @each $breakpoint-name, $breakpoint-bounds-pair in $breakpoint-bounds {
48
70
  $min-width: map-get($breakpoint-bounds-pair, min);
49
71
  $max-width: map-get($breakpoint-bounds-pair, max);
@@ -51,24 +73,27 @@ $aspect-ratios: (
51
73
  @if $min-width and $max-width {
52
74
  @media ($min-width <= width < $max-width) {
53
75
  @each $aspect-ratio, $aspect-ratio-value in $aspect-ratios {
76
+ $padding-percentage: math.div(1, $aspect-ratio-value) * 100%;
54
77
  .p-image-container--#{$aspect-ratio}-on-#{$breakpoint-name} {
55
- aspect-ratio: $aspect-ratio-value;
78
+ @include apply-aspect-ratio-styles($padding-percentage);
56
79
  }
57
80
  }
58
81
  }
59
82
  } @else if $min-width {
60
83
  @media (width >= $min-width) {
61
84
  @each $aspect-ratio, $aspect-ratio-value in $aspect-ratios {
85
+ $padding-percentage: math.div(1, $aspect-ratio-value) * 100%;
62
86
  .p-image-container--#{$aspect-ratio}-on-#{$breakpoint-name} {
63
- aspect-ratio: $aspect-ratio-value;
87
+ @include apply-aspect-ratio-styles($padding-percentage);
64
88
  }
65
89
  }
66
90
  }
67
91
  } @else if $max-width {
68
92
  @media (width < $max-width) {
69
93
  @each $aspect-ratio, $aspect-ratio-value in $aspect-ratios {
94
+ $padding-percentage: math.div(1, $aspect-ratio-value) * 100%;
70
95
  .p-image-container--#{$aspect-ratio}-on-#{$breakpoint-name} {
71
- aspect-ratio: $aspect-ratio-value;
96
+ @include apply-aspect-ratio-styles($padding-percentage);
72
97
  }
73
98
  }
74
99
  }
@@ -79,32 +104,33 @@ $aspect-ratios: (
79
104
  @mixin vf-p-image {
80
105
  .p-image-container,
81
106
  [class^='p-image-container--'] {
82
- align-items: center;
83
- display: flex;
84
- justify-content: center;
85
- text-align: center;
107
+ display: block;
108
+ position: relative;
109
+ width: 100%;
86
110
 
87
- // If there is a child lazyloaded image, don't let it affect the layout
88
- & > .lazyloaded {
89
- display: contents;
111
+ .p-image-container__image {
112
+ display: block;
113
+ margin: auto;
90
114
  }
91
115
 
92
116
  &.is-highlighted {
93
117
  background: $colors--theme--background-alt;
94
118
  }
95
119
 
96
- .p-image-container__image {
97
- // max height prevents the image from stretching the container
98
- // when the aspect ratio is set, and object-fit ensures the aspect ratio
99
- // of the image content is maintained
100
- max-height: 100%;
101
- object-fit: contain;
120
+ // If there is a child lazyloaded image, don't let it affect the layout.
121
+ & > .lazyloaded {
122
+ display: contents;
102
123
  }
103
124
 
104
125
  &.is-cover {
105
126
  .p-image-container__image {
106
127
  height: 100%;
128
+ left: 0;
129
+ margin: 0;
107
130
  object-fit: cover;
131
+ position: absolute;
132
+ top: 0;
133
+ transform: none;
108
134
  width: 100%;
109
135
  }
110
136
  }