mp-design-system 0.6.4 → 0.7.2

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": "mp-design-system",
3
- "version": "0.6.4",
3
+ "version": "0.7.2",
4
4
  "description": "",
5
5
  "main": "app.js",
6
6
  "scripts": {
@@ -24,19 +24,19 @@ module.exports = {
24
24
  {
25
25
  title: 'Petrol',
26
26
  context: {
27
- classes: 'c-campaign__petrol'
27
+ classes: 'c-campaign--petrol'
28
28
  }
29
29
  },
30
30
  {
31
31
  title: 'Blue',
32
32
  context: {
33
- classes: 'c-campaign__blue'
33
+ classes: 'c-campaign--blue'
34
34
  }
35
35
  },
36
36
  {
37
37
  title: 'Orange',
38
38
  context: {
39
- classes: 'c-campaign__orange'
39
+ classes: 'c-campaign--orange'
40
40
  }
41
41
  }
42
42
  ],
@@ -52,6 +52,11 @@
52
52
  }
53
53
  }
54
54
 
55
+ thead img {
56
+ @include space('max-height', '3xl');
57
+ object-fit: contain;
58
+ }
59
+
55
60
  }
56
61
 
57
62
  @media only screen and (min-width: 640px) {
@@ -3,7 +3,7 @@
3
3
  <aside class="c-slat c-slat--grey c-slat--padded">
4
4
  <div class="u-wrap u-flow">
5
5
  <h3 class="c-h c-h--upper">Related events</h3>
6
- <div class="o-grid o-grid--of-three">
6
+ <div class="o-grid o-grid--of-three o-grid--swipeable">
7
7
  {{ card({
8
8
  theme: {
9
9
  layout: 'single',
@@ -3,7 +3,7 @@
3
3
  <aside class="mp c-slat c-slat--grey c-slat--padded">
4
4
  <div class="u-wrap u-flow--xl">
5
5
  <h2 class="c-h c-h--step-3">Related resources</h2>
6
- <div class="o-grid o-grid--of-three">
6
+ <div class="o-grid o-grid--of-three o-grid--swipeable">
7
7
  {{ card({
8
8
  theme: {
9
9
  layout: 'single',
@@ -14,10 +14,31 @@
14
14
  <meta property="og:image:alt" content="{{ config.name }}" />
15
15
  <meta name="twitter:image" content="{{ config.openGraphImage }}" />
16
16
  <link rel="preconnect" href="https://fonts.gstatic.com">
17
- <script>if(document.documentElement){
18
- document.documentElement.classList.add('has-js');
19
- document.documentElement.classList.remove('no-js');
20
- }</script>
17
+ <script>
18
+ if(document.documentElement){
19
+ document.documentElement.classList.add('has-js');
20
+ document.documentElement.classList.remove('no-js');
21
+ }
22
+ // Calculate the height of the sidebar so it doesn't cause double scrollbars
23
+ function debounce(func, wait, immediate) {
24
+ var timeout;
25
+ return function() {
26
+ var context = this, args = arguments;
27
+ var later = function() {
28
+ timeout = null;
29
+ if (!immediate) func.apply(context, args);
30
+ };
31
+ var callNow = immediate && !timeout;
32
+ clearTimeout(timeout);
33
+ timeout = setTimeout(later, wait);
34
+ if (callNow) func.apply(context, args);
35
+ };
36
+ };
37
+ var resizeSidebar = debounce(function() {
38
+ var headerHeight = document.querySelector('.c-library__header').offsetHeight + 'px';
39
+ document.documentElement.style.setProperty('--headerHeight', headerHeight)
40
+ }, 250);
41
+ </script>
21
42
  <link rel="icon" type="image/png" sizes="32x32" href="/static/img/favicon-32x32.png">
22
43
  <link rel="stylesheet" href="/build/scss/main.css" />
23
44
  <script>window.MSInputMethodContext && document.documentMode && document.write('<script src="https://cdn.jsdelivr.net/gh/nuxodin/ie11CustomProperties@4.1.0/ie11CustomProperties.min.js"><\/script>');</script>
@@ -30,12 +51,15 @@
30
51
  <script src="/build/js/app.js"></script>
31
52
  <script>
32
53
  (function() {
54
+ // Prevent empty links from jumping to the top of page when clicked
33
55
  var links = document.querySelectorAll('a[href=""],a[href="#"]');
34
56
  for(var i = 0; links.length > i; i++) {
35
57
  links[i].addEventListener('click', function(event) {
36
58
  event.preventDefault();
37
59
  })
38
60
  }
61
+ window.addEventListener('resize', resizeSidebar);
62
+ resizeSidebar();
39
63
  })();
40
64
  </script>
41
65
  </body>
@@ -5,6 +5,7 @@ import Gallery from './imports/gallery';
5
5
  import HeroPattern from './imports/hero-pattern';
6
6
  import ResponsiveTable from './imports/responsive-table';
7
7
  import ScrollSpy from './imports/scroll-spy';
8
+ import ScrollbarWidth from './imports/scrollbar-width';
8
9
  import Tabs from './imports/tabs';
9
10
 
10
11
  (() => {
@@ -23,4 +24,5 @@ import Tabs from './imports/tabs';
23
24
  Tabs();
24
25
  ScrollSpy();
25
26
  ResponsiveTable();
27
+ ScrollbarWidth();
26
28
  })();
@@ -0,0 +1,15 @@
1
+ import { debounce } from './utilities';
2
+
3
+ function ScrollbarWidth() {
4
+ setScrollbarWidth();
5
+ window.addEventListener('resize', debounce(setScrollbarWidth, 250));
6
+ }
7
+
8
+ function setScrollbarWidth() {
9
+ document.documentElement.style.setProperty(
10
+ '--scrollbarWidth',
11
+ window.innerWidth - document.body.clientWidth + 'px'
12
+ );
13
+ }
14
+
15
+ export default ScrollbarWidth;
@@ -15,6 +15,16 @@ export function userPrefersReducedMotion() {
15
15
  return prefersReducedMotion;
16
16
  }
17
17
 
18
+ export const debounce = (func, limit) => {
19
+ let wait = false;
20
+ return () => {
21
+ if (wait) return;
22
+ func();
23
+ wait = true;
24
+ setTimeout(() => wait = false, limit);
25
+ }
26
+ }
27
+
18
28
  export const lerp = (x, y, a) => x * (1 - a) + y * a;
19
29
  export const clamp = (a, min = 0, max = 1) => Math.min(max, Math.max(min, a));
20
30
  export const invlerp = (x, y, a) => clamp((a - x) / (y - x));
@@ -10,8 +10,13 @@
10
10
  width: 100%;
11
11
 
12
12
  img {
13
- margin: 0 auto;
14
13
  display: block;
14
+ margin: 0 auto;
15
+
16
+ @supports (object-fit:contain) {
17
+ max-height: 500px;
18
+ object-fit: contain;
19
+ }
15
20
  }
16
21
 
17
22
  &:not(.active) {
@@ -24,29 +29,22 @@
24
29
  @include padding-bottom('s');
25
30
  display: flex;
26
31
  flex-direction: row;
27
- flex-wrap: nowrap;
28
- -webkit-overflow-scrolling: touch;
29
- scroll-behavior: smooth;
30
- scroll-snap-type: x mandatory;
31
- overflow-x: auto;
32
+ flex-wrap: wrap;
33
+ gap: 2%;
34
+ gap: max(8px, 2%);
32
35
 
33
36
  & > * {
34
37
  background: color('grey', 'step-3');
35
- max-width: 25%;
36
- max-height: var(--space-2xl);
37
- min-width: var(--space-l);
38
- min-height: var(--space-l);
39
- width: auto;
40
- scroll-snap-align: start;
41
-
42
- & + * {
43
- margin-left: var(--space-xs-s);
44
- }
38
+ @include space('min-height', 'l');
39
+ @include space('max-height', '2xl');
40
+ @include space('min-width', 'l');
41
+ max-width: 10.75%;
45
42
 
46
43
  img {
47
- min-height: 100%;
48
- opacity: 0.9;
44
+ height: 100%;
45
+ opacity: 0.8;
49
46
  object-fit: cover;
47
+ width: 100%;
50
48
  }
51
49
 
52
50
  &.active img {
@@ -71,7 +71,7 @@
71
71
  @media only screen and (min-width: 600px) {
72
72
  &--components &__body > * {
73
73
  overflow-y: scroll;
74
- height: calc(100vh - 115px);
74
+ height: calc( 100vh - var(--headerHeight) - 1px );
75
75
  }
76
76
  }
77
77
 
@@ -212,7 +212,11 @@
212
212
  }
213
213
 
214
214
  &__main {
215
- overflow-y: scroll;
215
+ overflow-y: auto;
216
+
217
+ @media only screen and (min-width: 600px) {
218
+ overflow-y: scroll;
219
+ }
216
220
  }
217
221
 
218
222
  &__frame {
@@ -3,9 +3,11 @@
3
3
 
4
4
  @mixin breakout($pad: 0) {
5
5
  left: 50%;
6
+ left: calc( 50% + var(--scrollbarWidth)/2.0001 );
6
7
  position: relative;
7
8
  transform: translateX(-50vw);
8
9
  width: 100vw;
10
+ width: calc( 100vw - var(--scrollbarWidth) );
9
11
  padding-left: safe-space($pad);
10
12
  padding-right: safe-space($pad);
11
13
  }
@@ -12,4 +12,8 @@
12
12
 
13
13
  .u-border {
14
14
  border: 1px solid color('petrol', 'step-2');
15
+ }
16
+
17
+ .o-prose hr {
18
+ @extend .u-hr
15
19
  }
@@ -63,17 +63,60 @@ More typography utility classes are documented on the [typography page](/compone
63
63
  ```
64
64
 
65
65
  ```html
66
- <div class="u-sticky">Sticky positioning at the top of the viewport</div>
66
+ <p class="u-sticky">This will "stick" to the top of the screen while scrolling</p>
67
67
  ```
68
68
 
69
69
  ```html
70
- <div class="u-sticky--gutter">Sticky positioning with gutter spacing</div>
70
+ <div class="u-sticky--gutter">Sticky positioning, with a gap above</div>
71
71
  ```
72
72
 
73
73
  ```html
74
74
  <div class="u-split">
75
- <h2>Webinars and events</h2>
76
- <a href>View all</a>
75
+ <p>Split: aligned left</p>
76
+ <a class="u-link">Aligned right</a>
77
77
  </div>
78
78
  The two child items will be aligned in a horizontal row
79
+ ```
80
+ <div class="u-split u-pad-s u-border">
81
+ <p>Split: aligned left</p>
82
+ <a class="u-link">Aligned right</a>
83
+ </div>
84
+
85
+ ## Padding and margins
86
+
87
+ More padding and margin utility classes are documented on the [space page](/components/space).
88
+
89
+ #### Syntax:
90
+ `u`-`(pad or margin)`-`(optional direction)`-`(size)`-`(optional flex size)`
91
+
92
+ Sizes | Directions
93
+ ------|-----------
94
+ 3xs | top
95
+ 2xs | bottom
96
+ xs | left
97
+ s | right
98
+ m | y
99
+ l | x
100
+ xl |
101
+ 2xl |
102
+ 3xl |
103
+ 4xl |
104
+
105
+ N.B. Not all permutations are available in the existing CSS, as that would amount to over 4800 extra lines of code. Currently we've only implemented a handful - but we can add more as needed.
106
+
107
+ ```html
108
+ <div class="u-pad-s">Small padding on all sides</div>
109
+ ```
110
+
111
+ ```html
112
+ <div class="u-margin-y-xl">Extra large margin on top and bottom</div>
113
+ ```
114
+
115
+ ```html
116
+ <div class="u-margin-left-m">Medium margin on left side only</div>
117
+ ```
118
+
119
+ ```html
120
+ <div class="u-pad-x-s-xl">Flexible (small to XL) padding on left and right</div>
121
+ Grows from small padding on small screens, to xl padding on large screens
79
122
  ```
@@ -445,7 +445,7 @@ tags: prototype
445
445
  </div>
446
446
 
447
447
  <div id="tab-events" class="c-tab">
448
- <div class="o-grid o-grid--of-three">
448
+ <div class="o-grid o-grid--of-three o-grid--swipeable">
449
449
  {{ card({
450
450
  theme: {
451
451
  layout: 'single',