@1024pix/pix-ui 55.11.2 → 55.12.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.
@@ -1,8 +1,7 @@
1
- <div
2
- class="pix-modal__overlay {{unless @showModal ' pix-modal__overlay--hidden'}}"
3
- {{on "click" this.closeAction}}
4
- {{trap-focus @showModal}}
5
- {{on-escape-action @onCloseButtonClick}}
1
+ <PixOverlay
2
+ @isVisible={{@showModal}}
3
+ @onClose={{@onCloseButtonClick}}
4
+ @focusOnClose={{@focusOnClose}}
6
5
  >
7
6
  <div
8
7
  class="pix-modal"
@@ -30,4 +29,4 @@
30
29
  {{yield to="footer"}}
31
30
  </div>
32
31
  </div>
33
- </div>
32
+ </PixOverlay>
@@ -1,4 +1,3 @@
1
- import { action } from '@ember/object';
2
1
  import { guidFor } from '@ember/object/internals';
3
2
  import Component from '@glimmer/component';
4
3
 
@@ -11,17 +10,6 @@ export default class PixModal extends Component {
11
10
  }
12
11
  }
13
12
 
14
- @action
15
- closeAction(event) {
16
- if (this.args.onCloseButtonClick && this.isClickOnOverlay(event)) {
17
- this.args.onCloseButtonClick(event);
18
- }
19
- }
20
-
21
- isClickOnOverlay(event) {
22
- return event.target.classList.contains('pix-modal__overlay');
23
- }
24
-
25
13
  get id() {
26
14
  return guidFor(this);
27
15
  }
@@ -0,0 +1,8 @@
1
+ <div
2
+ class="pix-overlay {{unless @isVisible ' pix-overlay--hidden'}}"
3
+ {{on "click" this.onClick}}
4
+ {{trap-focus @isVisible @focusOnClose}}
5
+ {{on-escape-action @onClose}}
6
+ >
7
+ {{yield}}
8
+ </div>
@@ -0,0 +1,13 @@
1
+ import { action } from '@ember/object';
2
+ import Component from '@glimmer/component';
3
+
4
+ export default class PixOverlay extends Component {
5
+ @action
6
+ onClick(event) {
7
+ const isClickOnOverlay = event.target.classList.contains('pix-overlay');
8
+
9
+ if (this.args.onClose && isClickOnOverlay) {
10
+ this.args.onClose(event);
11
+ }
12
+ }
13
+ }
@@ -1,9 +1,4 @@
1
- <div
2
- class="pix-sidebar__overlay {{unless @showSidebar ' pix-sidebar__overlay--hidden'}}"
3
- {{on "click" this.closeAction}}
4
- {{trap-focus @showSidebar @focusOnClose}}
5
- {{on-escape-action @onClose}}
6
- >
1
+ <PixOverlay @isVisible={{@showSidebar}} @onClose={{@onClose}} @focusOnClose={{@focusOnClose}}>
7
2
  <div
8
3
  class="pix-sidebar {{unless @showSidebar ' pix-sidebar--hidden'}}"
9
4
  role="dialog"
@@ -30,4 +25,4 @@
30
25
  {{yield to="footer"}}
31
26
  </div>
32
27
  </div>
33
- </div>
28
+ </PixOverlay>
@@ -1,4 +1,3 @@
1
- import { action } from '@ember/object';
2
1
  import { guidFor } from '@ember/object/internals';
3
2
  import Component from '@glimmer/component';
4
3
 
@@ -11,17 +10,6 @@ export default class PixSidebar extends Component {
11
10
  }
12
11
  }
13
12
 
14
- @action
15
- closeAction(event) {
16
- if (this.args.onClose && this.isClickOnOverlay(event)) {
17
- this.args.onClose(event);
18
- }
19
- }
20
-
21
- isClickOnOverlay(event) {
22
- return event.target.classList.contains('pix-sidebar__overlay');
23
- }
24
-
25
13
  get id() {
26
14
  return guidFor(this);
27
15
  }
@@ -2,51 +2,18 @@
2
2
  @use "pix-design-tokens/typography";
3
3
  @use "pix-design-tokens/shadows";
4
4
 
5
- .pix-modal__overlay {
6
- position: fixed;
7
- top: 0;
8
- right: 0;
9
- bottom: 0;
10
- left: 0;
11
- z-index: 1000;
12
- padding: var(--pix-spacing-2x) 0;
13
- overflow-y: auto;
14
- text-align: center; // Used to center horizontally the inline-block modal content
15
- // we inline the pix-neutral-800 value
16
- background-color: rgba(37,56,88, .5);
17
- transition: all 0.3s ease-in-out;
18
-
19
- // This block is used to center vertically the modal
20
- // if the content is less than 100vh
21
- // Inspired by https://mui.com/material-ui/react-dialog/#scrolling-long-content
22
- &::after {
23
- display: inline-block;
24
- width: 0;
25
- height: 100%;
26
- vertical-align: middle;
27
- content: '';
28
- }
29
-
30
- &--hidden {
31
- visibility: hidden;
32
- opacity: 0;
33
- }
34
- }
35
-
36
5
  .pix-modal {
37
6
  @extend %pix-shadow-sm;
38
7
 
39
- display: inline-block;
8
+ position: absolute;
9
+ top: 50%;
10
+ left: 50%;
40
11
  width: 512px;
41
- max-width: calc(
42
- 100% - var(--pix-spacing-4x)
43
- ); // Horizontal margin sets here to have extra space for the .pix-modal__overlay::after on mobile
44
-
12
+ max-width: calc(100% - var(--pix-spacing-4x));
45
13
  overflow: hidden;
46
- text-align: initial;
47
- vertical-align: middle; // Centered vertically with the .pix-modal__overlay::after which is 100% height
48
14
  background-color: var(--pix-neutral-20);
49
15
  border-radius: 4px;
16
+ transform: translate(-50%, -50%);
50
17
 
51
18
  &__header {
52
19
  display: flex;
@@ -0,0 +1,13 @@
1
+ .pix-overlay {
2
+ position: fixed;
3
+ z-index: 1000;
4
+ inset: 0;
5
+ overflow-y: auto;
6
+ background-color: rgba(var(--pix-primary-700-inline), 0.3);
7
+ transition: all 0.3s ease-in-out;
8
+
9
+ &--hidden {
10
+ visibility: hidden;
11
+ opacity: 0;
12
+ }
13
+ }
@@ -46,6 +46,7 @@
46
46
  @use 'pix-app-layout';
47
47
  @use 'pix-structure-switcher';
48
48
  @use 'pix-code';
49
+ @use 'pix-overlay';
49
50
  @use 'pix-tabs';
50
51
  @use 'pix-gauge';
51
52
 
@@ -0,0 +1 @@
1
+ export { default } from '@1024pix/pix-ui/components/pix-overlay';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1024pix/pix-ui",
3
- "version": "55.11.2",
3
+ "version": "55.12.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"