vanilla-framework 3.2.0 → 3.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/package.json CHANGED
@@ -27,10 +27,11 @@
27
27
  },
28
28
  "scripts": {
29
29
  "start": "yarn build && yarn serve",
30
- "build": "yarn build-scss && yarn build-js",
31
- "build-scss": "yarn run build-js && sass --load-path=node_modules --embed-sources --style=compressed scss:build/css && postcss --use autoprefixer --replace 'build/css/**/*.css' --map",
30
+ "build": "yarn build-scss && yarn build-js && yarn build-class-references",
31
+ "build-scss": "sass --load-path=node_modules --embed-sources --style=compressed scss:build/css && postcss --use autoprefixer --replace 'build/css/**/*.css' --map",
32
32
  "build:essential": "yarn run build-js && sass --load-path=node_modules --embed-sources --style=compressed scss/build.scss:build/css/build.css scss/docs:build/css/docs && postcss --use autoprefixer --replace 'build/css/**/*.css' --map",
33
33
  "build-js": "mkdir -p build/js/modules && cp node_modules/@canonical/cookie-policy/build/js/cookie-policy.js build/js/modules && cp node_modules/@canonical/latest-news/dist/latest-news.js build/js/modules",
34
+ "build-class-references": "node scripts/create-class-references.js",
34
35
  "serve": "./entrypoint 0.0.0.0:${PORT}",
35
36
  "test-scss": "node -e 'require(\"./tests/parker\").parkerTest()'",
36
37
  "test-spelling": "mdspell templates/docs/**/*.md -r -n -a --en-gb",
@@ -44,7 +45,7 @@
44
45
  "percy": "percy exec -- node snapshots.js",
45
46
  "icon-svgs-to-mixins": "node scripts/convert-svgs-to-icon-mixins.js icons"
46
47
  },
47
- "version": "3.2.0",
48
+ "version": "3.5.0",
48
49
  "files": [
49
50
  "_index.scss",
50
51
  "/scss",
@@ -54,10 +55,12 @@
54
55
  "dependencies": {
55
56
  "@canonical/cookie-policy": "3.4.0",
56
57
  "@canonical/latest-news": "1.3.0",
57
- "autoprefixer": "10.4.4",
58
- "postcss": "8.4.12",
58
+ "autoprefixer": "10.4.7",
59
+ "postcss": "8.4.14",
59
60
  "postcss-cli": "9.1.0",
60
- "sass": "1.49.11"
61
+ "postcss-scss": "4.0.4",
62
+ "sass": "1.52.2",
63
+ "yaml": "1.10.2"
61
64
  },
62
65
  "devDependencies": {
63
66
  "@percy/script": "1.1.0",
@@ -65,7 +68,7 @@
65
68
  "markdown-spellcheck": "1.3.1",
66
69
  "parker": "0.0.10",
67
70
  "prettier": "2.6.2",
68
- "stylelint": "14.6.1",
71
+ "stylelint": "14.8.5",
69
72
  "stylelint-config-prettier": "9.0.3",
70
73
  "stylelint-config-recommended-scss": "5.0.2",
71
74
  "stylelint-order": "5.0.0",
@@ -16,48 +16,45 @@
16
16
  }
17
17
 
18
18
  .p-accordion__tab {
19
- // calculate icon top position based on top padding (from %single-border-text-vpadding--scaling)
20
- // and offset to align it with baseline of accordion tab text element
21
- $icon-top-position: calc(#{$table-cell-vertical-padding + (map-get($line-heights, default-text) - $icon-size) * 0.5});
22
-
23
19
  @extend %single-border-text-vpadding--scaling;
24
20
  @include vf-focus;
25
21
 
26
- background: {
27
- color: inherit;
28
- position: top $icon-top-position left $sph--large;
29
- repeat: no-repeat;
30
- }
31
-
22
+ background-color: inherit;
32
23
  border: 0;
33
24
  border-radius: 0;
34
25
  font-size: inherit;
35
26
  justify-content: flex-start;
36
27
  margin-bottom: 0;
37
- padding-left: $sph--large + $icon-size + $sph--large;
38
28
  padding-right: $sph--large;
29
+ position: relative;
39
30
  text-align: left;
40
31
  transition-duration: 0s;
41
32
  width: 100%;
42
33
  z-index: 2;
43
34
 
35
+ &::before {
36
+ @include vf-icon-chevron($color-mid-dark);
37
+ @include vf-animation($property: transform, $duration: fast);
38
+ @extend %icon;
39
+
40
+ content: '';
41
+ margin-right: $sph--large;
42
+ }
43
+
44
44
  // aria-selected controls the open and closed state for the accordion tab
45
45
  &[aria-expanded='true'] {
46
- @include vf-icon-minus($color-mid-dark);
47
-
48
46
  // override base expanded button styles
49
47
  background-color: inherit;
48
+
50
49
  &:hover {
51
50
  background-color: $colors--light-theme--background-hover;
52
51
  }
53
-
54
- background-size: $icon-size;
55
52
  }
56
53
 
57
54
  &[aria-expanded='false'] {
58
- @include vf-icon-plus($color-mid-dark);
59
-
60
- background-size: $icon-size;
55
+ &::before {
56
+ transform: rotate(-90deg);
57
+ }
61
58
  }
62
59
  }
63
60
 
@@ -74,25 +71,17 @@
74
71
  }
75
72
 
76
73
  // stylelint-disable selector-max-type
77
- h2.p-accordion__heading > .p-accordion__tab,
78
- .p-heading--2 > .p-accordion__tab {
79
- $icon-top-position: calc(#{$table-cell-vertical-padding + (map-get($line-heights, h2) - $icon-size) * 0.5});
80
-
81
- background-position-y: $icon-top-position;
74
+ .p-heading--2 > .p-accordion__tab::before,
75
+ h2.p-accordion__heading > .p-accordion__tab::before {
76
+ @include vf-icon-size($x-height);
77
+ vertical-align: 0;
82
78
  }
83
79
 
84
- h3.p-accordion__heading > .p-accordion__tab,
85
- .p-heading--3 > .p-accordion__tab {
86
- $icon-top-position: calc(#{$table-cell-vertical-padding + (map-get($line-heights, h3) - $icon-size) * 0.5});
87
-
88
- background-position-y: $icon-top-position;
89
- }
90
-
91
- h4.p-accordion__heading > .p-accordion__tab,
92
- .p-heading--4 > .p-accordion__tab {
93
- $icon-top-position: calc(#{$table-cell-vertical-padding + (map-get($line-heights, h4) - $icon-size) * 0.5});
94
-
95
- background-position-y: $icon-top-position;
80
+ .p-heading--3 > .p-accordion__tab::before,
81
+ .p-heading--4 > .p-accordion__tab::before,
82
+ h3.p-accordion__heading > .p-accordion__tab::before,
83
+ h4.p-accordion__heading > .p-accordion__tab::before {
84
+ vertical-align: 0;
96
85
  }
97
86
  // stylelint-enable selector-max-type
98
87
 
@@ -1,3 +1,49 @@
1
+ /*
2
+ @classreference
3
+ code-snippet:
4
+ Root element:
5
+ .p-code-snippet:
6
+ Main element of the code snippet component.
7
+ "&.is-bordered":
8
+ Bordered variant, to be used when additional content (such as iframes) is used inside the code snippet component.
9
+
10
+ Code block:
11
+ .p-code-snippet__block:
12
+ Code block without any additonal styling elements.
13
+ "&.is-wrapped":
14
+ Code block with wrapped content in lines.
15
+ .p-code-snippet__block--icon:
16
+ Code block that starts with an icon. Default icon is a UNIX prompt. To be used with Linux CLI examples.
17
+ "&.is-windows-prompt":
18
+ Changes the `.p-code-snippet__block--icon` to use a Windows prompt icon. To be used with Windows CLI examples.
19
+ "&.is-url":
20
+ Changes the `.p-code-snippet__block--icon` to use a link icon. To be used with URLs.
21
+ .p-code-snippet__block--numbered:
22
+ Code block with numbered lines of code (to be used with longer pieces of code examples). Requires `.p-code-snippet__line`.
23
+
24
+ Code line:
25
+ .p-code-snippet__line:
26
+ A wrapper around single line of code. Needed with numbered variant of a code block.
27
+
28
+ Code block header:
29
+ .p-code-snippet__header:
30
+ A header of a code block. Contains a title and optional dropdowns.
31
+ "&.is-stacked":
32
+ A stacked version of a header (with a title displayed above the dropdowns). To be used when there are multiple dropdowns with a long title.
33
+
34
+ Code block title:
35
+ .p-code-snippet__title:
36
+ The title of a code block.
37
+
38
+ Dropdowns container:
39
+ .p-code-snippet__dropdowns:
40
+ The container element for any dropdowns in the header.
41
+
42
+ Dropdown:
43
+ .p-code-snippet__dropdown:
44
+ An individual dropdown in code block header.
45
+ */
46
+
1
47
  @import 'settings';
2
48
 
3
49
  $color-snippet-heading-bg: rgba($color-x-dark, 0.08);
@@ -68,11 +68,13 @@ $spv-navigation-logo: 0.3125rem;
68
68
  display: block;
69
69
  font-weight: $font-weight-bold;
70
70
  line-height: map-get($line-heights, default-text);
71
- margin-bottom: 0;
71
+ margin: 0;
72
72
  overflow: hidden;
73
73
  position: relative;
74
+ text-align: left;
74
75
  text-overflow: ellipsis;
75
76
  white-space: nowrap;
77
+ width: 100%;
76
78
 
77
79
  &::before {
78
80
  content: '';
@@ -1,5 +1,57 @@
1
1
  @import 'settings';
2
2
 
3
+ /*
4
+ @classreference
5
+ notification:
6
+ Root element:
7
+ .p-notification:
8
+ Notification in default variant. Same as `.p-notification--information`.
9
+ .p-notification--information:
10
+ Information notification. Same as default `.p-notification`.
11
+ .p-notification--positive:
12
+ Positive notification.
13
+ .p-notification--caution:
14
+ Caution notification.
15
+ .p-notification--negative:
16
+ Negative notification.
17
+ "&.is-borderless":
18
+ Borderless variant of notification. Used when notification is embeded into another container element.
19
+ "&.is-inline":
20
+ Inline version of notification with title and message rendered side by side.
21
+
22
+ Content container:
23
+ .p-notification__content:
24
+ Container element for notification content (title and message).
25
+
26
+ Title:
27
+ .p-notification__title:
28
+ The notification title.
29
+
30
+ Message:
31
+ .p-notification__message:
32
+ Text of the notification message.
33
+
34
+ Close button:
35
+ .p-notification__close:
36
+ The button to close the notification.
37
+
38
+ Meta-data container:
39
+ .p-notification__meta:
40
+ The container element for notification meta-data (timestamp and action buttons).
41
+
42
+ Timestamp:
43
+ .p-notification__timestamp:
44
+ Notification timestamp or date.
45
+
46
+ Actions container:
47
+ .p-notification__actions:
48
+ Container element for notification action buttons.
49
+
50
+ Action button:
51
+ .p-notification__action:
52
+ Single action button.
53
+ */
54
+
3
55
  // space on the left of the icon + icon width + space on the right of the icon
4
56
  $notification-content-icon-space: 2 * $sph--large + map-get($icon-sizes, default);
5
57
 
@@ -13,7 +13,11 @@
13
13
  }
14
14
  }
15
15
 
16
- .p-pagination {
16
+ // .p-pagination on the <ol> element is deprecated. It should be used on the wrapping <nav> element instead, and .p-pagination__items on the <ol> or <ul> element.
17
+
18
+ // stylelint-disable selector-max-type
19
+ .p-pagination:not(nav),
20
+ .p-pagination__items {
17
21
  display: flex;
18
22
  flex-direction: row;
19
23
  list-style: none;
@@ -1,9 +1,14 @@
1
- @mixin vf-p-tab-buttons {
1
+ @mixin vf-p-segmented-control {
2
+ .p-segmented-control,
3
+ // p-tab-buttons is deprecated,
4
+ // please use p-segmented-control instead
2
5
  .p-tab-buttons {
6
+ .p-segmented-control__list,
3
7
  .p-tab-buttons__list {
4
8
  display: flex;
5
9
  }
6
10
 
11
+ .p-segmented-control__button,
7
12
  .p-tab-buttons__button {
8
13
  @extend %vf-button-has-icon;
9
14
 
@@ -41,8 +46,14 @@
41
46
  }
42
47
  }
43
48
 
49
+ &.is-dense .p-segmented-control__button,
44
50
  &.is-dense .p-tab-buttons__button {
45
51
  @extend %vf-button-dense-vertical-padding;
46
52
  }
47
53
  }
48
54
  }
55
+
56
+ // Deprecated mixin kept for compatibility
57
+ @mixin vf-p-tab-buttons {
58
+ @include vf-p-segmented-control;
59
+ }
@@ -1,5 +1,81 @@
1
1
  @import 'settings';
2
2
 
3
+ /*
4
+ @classreference
5
+ side-navigation:
6
+ Root element:
7
+ .p-side-navigation:
8
+ Side navigation in default variant.
9
+ .p-side-navigation--icons:
10
+ Side navigation with item icons.
11
+ .p-side-navigation--raw-html:
12
+ Raw HTML version of side navigation (used with links generated by an external service).
13
+ "&.is-drawer-expanded":
14
+ Set `.is-drawer-expanded` when side navigation drawer is open on small screens.
15
+ "&.is-drawer-collapsed":
16
+ Set `.is-drawer-collapsed` when side navigation drawer is closed on small screens.
17
+ "&.is-drawer-hidden":
18
+ Set `.is-drawer-hidden` when side navigation drawer is closed on small screens.
19
+ "&.is-sticky":
20
+ Sticky version of side navigation.
21
+ "&.is-dark":
22
+ Side navigation in dark theme (if default is light).
23
+ "&.is-light":
24
+ Side navigation in light theme (if default is dark).
25
+
26
+ Overlay:
27
+ .p-side-navigation__overlay:
28
+ Screen overlay to display when side navigation drawer is open on small screens.
29
+
30
+ Drawer:
31
+ .p-side-navigation__drawer:
32
+ Side navigation drawer (to allow expanding and collapsing the navigation on small screens).
33
+
34
+ Drawer header:
35
+ .p-side-navigation__drawer-header:
36
+ Header of the side navigation drawer.
37
+
38
+ Toggle button:
39
+ .p-side-navigation__toggle:
40
+ Side navigation toggle button (to open side navigation on small screens).
41
+ .p-side-navigation__toggle--in-drawer:
42
+ Side navigation toggle button in drawer (to close navigation on small screens).
43
+
44
+ Items list heading:
45
+ .p-side-navigation__heading:
46
+ Heading for side navigation items group (text only).
47
+ .p-side-navigation__heading--linked:
48
+ Heading for side navigation items group that contains a link (`.p-side-navigation__link`).
49
+
50
+ Items list:
51
+ .p-side-navigation__list:
52
+ Group of side navigation items (usually a `<ul>` element).
53
+
54
+ Item element:
55
+ .p-side-navigation__item:
56
+ Single item in side navigation (usually a `<li>` element). May contain nested items lists.
57
+ .p-side-navigation__item--title:
58
+ Single title item in side navigation (usually a `<li>` element).
59
+ "&.has-active-child":
60
+ Set `.has-active-child` on a item that contains an active nested item. This is used in collapsible side navigation in application layout.
61
+
62
+ Item link:
63
+ .p-side-navigation__link:
64
+ Single link in the side navigation.
65
+
66
+ Item text:
67
+ .p-side-navigation__text:
68
+ Single text item in side navigation (for items that are not linked).
69
+
70
+ Item icon:
71
+ .p-side-navigation__icon:
72
+ An icon in side navigation item (used with `.p-side-navigation--icons` variant).
73
+
74
+ Item status:
75
+ .p-side-navigation__status:
76
+ A container for status icon or label inside the navigation item.
77
+ */
78
+
3
79
  @mixin vf-p-side-navigation {
4
80
  // STYLING OF SIDE NAVIGATION RESPONSIVE DRAWER
5
81
 
@@ -35,8 +111,11 @@
35
111
 
36
112
  .p-side-navigation:target &,
37
113
  [class*='p-side-navigation--']:target &,
114
+ // is-expanded and is-collapsed are deprecated and replaced by is-drawer-expanded and is-drawer-collapsed
38
115
  .p-side-navigation.is-expanded &,
39
- [class*='p-side-navigation--'].is-expanded & {
116
+ .p-side-navigation.is-drawer-expanded &,
117
+ [class*='p-side-navigation--'].is-expanded &,
118
+ [class*='p-side-navigation--'].is-drawer-expanded & {
40
119
  @extend %vf-has-box-shadow;
41
120
 
42
121
  animation: vf-p-side-navigation-expand map-get($animation-duration, brisk);
@@ -44,10 +123,20 @@
44
123
  }
45
124
 
46
125
  .p-side-navigation.is-collapsed &,
47
- [class*='p-side-navigation--'].is-collapsed & {
126
+ .p-side-navigation.is-drawer-collapsed &,
127
+ [class*='p-side-navigation--'].is-collapsed &,
128
+ [class*='p-side-navigation--'].is-drawer-collapsed & {
48
129
  animation: vf-p-side-navigation-collapse map-get($animation-duration, brisk);
49
130
  }
50
131
 
132
+ .p-side-navigation.is-drawer-hidden &,
133
+ [class*='p-side-navigation--'].is-drawer-hidden & {
134
+ display: none;
135
+ @media (min-width: $threshold-6-12-col) {
136
+ display: block;
137
+ }
138
+ }
139
+
51
140
  @media (min-width: $breakpoint-x-small) {
52
141
  max-width: 20rem;
53
142
  }
@@ -68,7 +157,9 @@
68
157
  .p-side-navigation:target &,
69
158
  [class*='p-side-navigation--']:target &,
70
159
  .p-side-navigation.is-expanded &,
71
- [class*='p-side-navigation--'].is-expanded & {
160
+ .p-side-navigation.is-drawer-expanded &,
161
+ [class*='p-side-navigation--'].is-expanded &,
162
+ [class*='p-side-navigation--'].is-drawer-expanded & {
72
163
  opacity: 1;
73
164
  pointer-events: all;
74
165
  }
@@ -134,7 +225,9 @@
134
225
  .p-side-navigation:target .p-side-navigation__drawer,
135
226
  [class*='p-side-navigation--']:target .p-side-navigation__drawer,
136
227
  .p-side-navigation.is-expanded .p-side-navigation__drawer,
137
- [class*='p-side-navigation--'].is-expanded .p-side-navigation__drawer {
228
+ .p-side-navigation.is-drawer-expanded .p-side-navigation__drawer,
229
+ [class*='p-side-navigation--'].is-expanded .p-side-navigation__drawer,
230
+ [class*='p-side-navigation--'].is-drawer-expanded .p-side-navigation__drawer {
138
231
  box-shadow: none;
139
232
  display: block;
140
233
  max-width: none;
@@ -189,6 +282,18 @@
189
282
  padding-top: $spv--x-small;
190
283
  }
191
284
 
285
+ %side-navigation__heading {
286
+ @extend %side-navigation__text;
287
+
288
+ // reset heading styles
289
+ @extend %common-default-text-properties;
290
+ @extend %bold;
291
+
292
+ display: block;
293
+ font-size: map-get($base-font-sizes, base);
294
+ margin: 0;
295
+ }
296
+
192
297
  %side-navigation__link {
193
298
  @include vf-focus;
194
299
 
@@ -213,6 +318,7 @@
213
318
  @extend %side-navigation__link;
214
319
  }
215
320
 
321
+ .p-side-navigation__heading,
216
322
  .p-side-navigation__text,
217
323
  .p-side-navigation__link {
218
324
  @extend %side-navigation__text;
@@ -258,6 +364,15 @@
258
364
  padding-left: $spv--small;
259
365
  }
260
366
 
367
+ .p-side-navigation__heading,
368
+ .p-side-navigation__heading--linked {
369
+ @extend %side-navigation__heading;
370
+ }
371
+
372
+ .p-side-navigation__heading--linked {
373
+ padding: 0; // padding will come from the link in heading
374
+ }
375
+
261
376
  // Styles for markup in raw HTML docs variant
262
377
  .p-side-navigation--raw-html {
263
378
  // stylelint-disable selector-max-type -- we support raw HTML markup for discourse-generated side nav
@@ -266,14 +381,7 @@
266
381
  h4,
267
382
  h5,
268
383
  h6 {
269
- @extend %side-navigation__text;
270
-
271
- // reset heading styles
272
- @extend %common-default-text-properties;
273
- @extend %bold;
274
-
275
- font-size: map-get($base-font-sizes, base);
276
- margin: 0;
384
+ @extend %side-navigation__heading;
277
385
  }
278
386
 
279
387
  ul {
@@ -416,6 +524,15 @@
416
524
  &::before {
417
525
  @include vf-icon-chevron($color-sidenav-toggle-icon);
418
526
  }
527
+
528
+ &[aria-expanded='true'] {
529
+ background-color: $color-transparent;
530
+
531
+ &:hover {
532
+ background: $color-sidenav-item-background-hover;
533
+ color: $color-sidenav-text-active;
534
+ }
535
+ }
419
536
  }
420
537
 
421
538
  .p-side-navigation__drawer {
@@ -462,6 +579,8 @@
462
579
  }
463
580
  }
464
581
 
582
+ .p-side-navigation__heading,
583
+ .p-side-navigation__heading--linked .p-side-navigation__link,
465
584
  .p-side-navigation__item--title,
466
585
  .p-side-navigation__item--title .p-side-navigation__link {
467
586
  color: $color-sidenav-text-active;
@@ -55,3 +55,8 @@
55
55
  color: $color-x-light;
56
56
  }
57
57
  }
58
+
59
+ // Deprecated mixin kept for compatibility
60
+ @mixin vf-p-label {
61
+ @include vf-p-status-label;
62
+ }
@@ -41,7 +41,7 @@
41
41
  @import 'patterns_status-label';
42
42
  @import 'patterns_strip';
43
43
  @import 'patterns_switch';
44
- @import 'patterns_tab-buttons';
44
+ @import 'patterns_segmented-control';
45
45
  @import 'patterns_table-icons';
46
46
  @import 'patterns_table-expanding';
47
47
  @import 'patterns_table-of-contents';
@@ -116,13 +116,13 @@
116
116
  @include vf-p-pull-quotes;
117
117
  @include vf-p-search-and-filter;
118
118
  @include vf-p-search-box;
119
+ @include vf-p-segmented-control;
119
120
  @include vf-p-separator;
120
121
  @include vf-p-side-navigation;
121
122
  @include vf-p-slider;
122
123
  @include vf-p-status-label;
123
124
  @include vf-p-strip;
124
125
  @include vf-p-switch;
125
- @include vf-p-tab-buttons;
126
126
  @include vf-p-table-icons;
127
127
  @include vf-p-table-expanding;
128
128
  @include vf-p-table-of-contents;