@1024pix/pix-ui 18.0.1 → 18.1.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.
@@ -4,9 +4,13 @@ on:
4
4
  pull_request:
5
5
  types:
6
6
  - labeled
7
+ - unlabeled
7
8
  check_suite:
8
9
  types:
9
10
  - completed
11
+ status:
12
+ types:
13
+ - success
10
14
 
11
15
  permissions: write-all
12
16
 
@@ -14,13 +18,6 @@ jobs:
14
18
  automerge:
15
19
  runs-on: ubuntu-latest
16
20
  steps:
17
- - name: automerge
18
- uses: "pascalgn/automerge-action@v0.14.3"
19
- env:
20
- GITHUB_TOKEN: "${{ github.token }}"
21
- MERGE_LABELS: ":rocket: Ready to Merge"
22
- MERGE_COMMIT_MESSAGE: "pull-request-title"
23
- UPDATE_LABELS: ":rocket: Ready to Merge"
24
- UPDATE_METHOD: "rebase"
25
- MERGE_FORKS: "false"
26
- LOG: "TRACE"
21
+ - uses: 1024pix/pix-actions/auto-merge@v0
22
+ with:
23
+ auto_merge_token: "${{ github.token }}"
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Pix-UI Changelog
2
2
 
3
+ ## v18.1.0 (15/09/2022)
4
+
5
+
6
+ ### :rocket: Amélioration
7
+ - [#253](https://github.com/1024pix/pix-ui/pull/253) [FEATURE] Améliorer de l'accessibilité de Pix-Sidebar.
8
+
9
+ ## v18.0.2 (06/09/2022)
10
+
11
+
12
+ ### :bug: Correction
13
+ - [#251](https://github.com/1024pix/pix-ui/pull/251) [BUGFIX] Évite de casser les tests d'acceptance des applis (PIX-5619)
14
+
15
+ ### :coffee: Autre
16
+ - [#250](https://github.com/1024pix/pix-ui/pull/250) [CLEANUP] Utilise l'action commune d'automerge
17
+
3
18
  ## v18.0.1 (02/09/2022)
4
19
 
5
20
 
@@ -2,7 +2,7 @@
2
2
  class="pix-modal__overlay {{unless @showModal ' pix-modal__overlay--hidden'}}"
3
3
  {{on "click" this.closeAction}}
4
4
  {{trap-focus @showModal}}
5
- {{on-escape-action this.closeAction}}
5
+ {{on-escape-action @onCloseButtonClick}}
6
6
  >
7
7
  <div
8
8
  class="pix-modal"
@@ -10,14 +10,13 @@
10
10
  aria-labelledby="modal-title"
11
11
  aria-describedby="modal-content"
12
12
  aria-modal="true"
13
- {{on "click" this.stopPropagation}}
14
13
  ...attributes
15
14
  >
16
15
  <header class="pix-modal__header">
17
16
  <h1 id="modal-title" class="pix-modal__title">{{@title}}</h1>
18
17
  <PixIconButton
19
18
  @icon="xmark"
20
- @triggerAction={{this.closeAction}}
19
+ @triggerAction={{@onCloseButtonClick}}
21
20
  @ariaLabel="Fermer"
22
21
  @size="small"
23
22
  @withBackground={{true}}
@@ -11,14 +11,13 @@ export default class PixModal extends Component {
11
11
  }
12
12
 
13
13
  @action
14
- stopPropagation(event) {
15
- event.stopPropagation();
14
+ closeAction(event) {
15
+ if (this.args.onCloseButtonClick && this.isClickOnOverlay(event)) {
16
+ this.args.onCloseButtonClick(event);
17
+ }
16
18
  }
17
19
 
18
- @action
19
- closeAction(params) {
20
- if (this.args.onCloseButtonClick) {
21
- this.args.onCloseButtonClick(params);
22
- }
20
+ isClickOnOverlay(event) {
21
+ return event.target.classList.contains('pix-modal__overlay');
23
22
  }
24
23
  }
@@ -2,29 +2,28 @@
2
2
  class="pix-sidebar__overlay {{unless @showSidebar ' pix-sidebar__overlay--hidden'}}"
3
3
  {{on "click" this.closeAction}}
4
4
  {{trap-focus @showSidebar}}
5
- {{on-escape-action this.closeAction}}
5
+ {{on-escape-action @onClose}}
6
6
  >
7
7
  <div
8
8
  class="pix-sidebar {{unless @showSidebar ' pix-sidebar--hidden'}}"
9
9
  role="dialog"
10
- aria-labelledby="sidebar-title"
11
- aria-describedby="sidebar-content"
10
+ aria-labelledby="sidebar-title--{{this.id}}"
11
+ aria-describedby="sidebar-content--{{this.id}}"
12
12
  aria-modal="true"
13
- {{on "click" this.stopPropagation}}
14
13
  ...attributes
15
14
  >
16
15
  <header class="pix-sidebar__header">
17
- <h1 id="sidebar-title" class="pix-sidebar__title">{{@title}}</h1>
16
+ <h1 id="sidebar-title--{{this.id}}" class="pix-sidebar__title">{{@title}}</h1>
18
17
  <PixIconButton
19
18
  @icon="xmark"
20
- @triggerAction={{this.closeAction}}
19
+ @triggerAction={{@onClose}}
21
20
  @ariaLabel="Fermer"
22
21
  @size="small"
23
22
  @withBackground={{true}}
24
23
  class="pix-sidebar__close-button"
25
24
  />
26
25
  </header>
27
- <main id="sidebar-content" class="pix-sidebar__content">
26
+ <main id="sidebar-content--{{this.id}}" class="pix-sidebar__content">
28
27
  {{yield to="content"}}
29
28
  </main>
30
29
  <footer class="pix-sidebar__footer">
@@ -1,5 +1,6 @@
1
1
  import Component from '@glimmer/component';
2
2
  import { action } from '@ember/object';
3
+ import uniqueId from '@1024pix/pix-ui/utils/unique-id';
3
4
 
4
5
  export default class PixSidebar extends Component {
5
6
  constructor(...args) {
@@ -11,14 +12,17 @@ export default class PixSidebar extends Component {
11
12
  }
12
13
 
13
14
  @action
14
- stopPropagation(event) {
15
- event.stopPropagation();
15
+ closeAction(event) {
16
+ if (this.args.onClose && this.isClickOnOverlay(event)) {
17
+ this.args.onClose(event);
18
+ }
16
19
  }
17
20
 
18
- @action
19
- closeAction(params) {
20
- if (this.args.onClose) {
21
- this.args.onClose(params);
22
- }
21
+ isClickOnOverlay(event) {
22
+ return event.target.classList.contains('pix-sidebar__overlay');
23
+ }
24
+
25
+ get id() {
26
+ return uniqueId();
23
27
  }
24
28
  }
@@ -0,0 +1,3 @@
1
+ .body__trap-focus {
2
+ overflow: hidden;
3
+ }
@@ -28,6 +28,7 @@
28
28
  @import 'pix-dropdown';
29
29
  @import 'pix-pagination';
30
30
  @import 'pix-checkbox';
31
+ @import 'trap-focus';
31
32
 
32
33
  html {
33
34
  font-size: 16px;
@@ -0,0 +1,5 @@
1
+ export default function uniqueId() {
2
+ return ([3e7] + -1e3 + -4e3 + -2e3 + -1e11).replace(/[0-3]/g, (a) =>
3
+ ((a * 4) ^ ((Math.random() * 16) >> (a & 2))).toString(16)
4
+ );
5
+ }
@@ -6,9 +6,11 @@ export default modifier(function trapFocus(element, [isOpen]) {
6
6
  const [firstFocusableElement] = findFocusableElements(element);
7
7
 
8
8
  if (isOpen) {
9
+ preventPageScrolling();
9
10
  sourceActiveElement = document.activeElement;
10
11
  focusElement(firstFocusableElement, element);
11
12
  } else if (sourceActiveElement) {
13
+ allowPageScrolling();
12
14
  focusElement(sourceActiveElement, element);
13
15
  }
14
16
 
@@ -58,6 +60,14 @@ function focusElement(elementToFocus, element) {
58
60
  };
59
61
  }
60
62
 
63
+ function preventPageScrolling() {
64
+ document.body.classList.add('body__trap-focus');
65
+ }
66
+
67
+ function allowPageScrolling() {
68
+ document.body.classList.remove('body__trap-focus');
69
+ }
70
+
61
71
  function hasTransitionDuration(element) {
62
72
  return hasDurationByKey(element, 'transition-duration');
63
73
  }
@@ -12,12 +12,14 @@ export const Template = (args) => {
12
12
  </:content>
13
13
  <:footer>
14
14
  <div style="display: flex; gap: 8px">
15
- <PixButton @backgroundColor="transparent-light" @isBorderVisible="true">Annuler</PixButton>
16
- <PixButton>Valider</PixButton>
15
+ <PixButton @backgroundColor="transparent-light" @isBorderVisible="true" @triggerAction={{fn (mut showSidebar) (not showSidebar)}}>Annuler</PixButton>
16
+ <PixButton @triggerAction={{fn (mut showSidebar) (not showSidebar)}}>Valider</PixButton>
17
17
  </div>
18
18
  </:footer>
19
19
  </PixSidebar>
20
- <PixButton @triggerAction={{fn (mut showSidebar) (not showSidebar)}}>Ouvrir la sidebar</PixButton>
20
+ <div style="display:flex; justify-content:center; align-items:center; height:105vh;">
21
+ <PixButton @triggerAction={{fn (mut showSidebar) (not showSidebar)}} style="height:45px">Ouvrir la sidebar</PixButton>
22
+ </div>
21
23
  `,
22
24
  context: args,
23
25
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1024pix/pix-ui",
3
- "version": "18.0.1",
3
+ "version": "18.1.0",
4
4
  "description": "Pix-UI is the implementation of Pix design principles and guidelines for its products.",
5
5
  "keywords": [
6
6
  "ember-addon"