@1024pix/pix-ui 54.11.0 → 54.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,4 +1,4 @@
1
- <div class="pix-table">
1
+ <div class="pix-table" ...attributes>
2
2
  <table class={{this.tableClass}}>
3
3
  <caption class="screen-reader-only">{{this.caption}}</caption>
4
4
  <thead class={{this.headerClass}}>
@@ -7,9 +7,12 @@
7
7
  </tr>
8
8
  </thead>
9
9
  <tbody>
10
- {{#each @data as |row|}}
11
- <tr>
12
- {{yield row "cell" to="columns"}}
10
+ {{#each @data as |row index|}}
11
+ <tr
12
+ class={{if this.hasOnRowClick "pix-table__clickable-row" ""}}
13
+ {{on "click" (fn this.onClick row)}}
14
+ >
15
+ {{yield row "cell" index to="columns"}}
13
16
  </tr>
14
17
  {{/each}}
15
18
  </tbody>
@@ -1,4 +1,5 @@
1
1
  import { warn } from '@ember/debug';
2
+ import { action } from '@ember/object';
2
3
  import Component from '@glimmer/component';
3
4
 
4
5
  export default class PixTable extends Component {
@@ -39,4 +40,16 @@ export default class PixTable extends Component {
39
40
  get headerClass() {
40
41
  return `pix-table-header--${this.variant}`;
41
42
  }
43
+
44
+ get hasOnRowClick() {
45
+ return typeof this.args.onRowClick === 'function';
46
+ }
47
+
48
+ @action
49
+ onClick(row, event) {
50
+ event.stopPropagation();
51
+ if (this.hasOnRowClick) {
52
+ this.args.onRowClick(row);
53
+ }
54
+ }
42
55
  }
@@ -11,18 +11,38 @@
11
11
 
12
12
  @extend %pix-body-s;
13
13
 
14
- .pix-table__condensed {
14
+ &__condensed {
15
15
  th, td {
16
16
  padding: var(--pix-spacing-2x) var(--pix-spacing-4x);
17
17
  }
18
18
  }
19
19
 
20
+ &__clickable-row {
21
+ cursor: pointer;
22
+
23
+ &:hover, &:focus, &:active {
24
+ transition: 0.25s ease;
25
+ }
26
+
27
+ &:hover {
28
+ background-color: rgba(var(--pix-neutral-100-inline), 0.50);
29
+ }
30
+
31
+ &:focus {
32
+ background-color: rgba(var(--pix-neutral-100-inline), 0.40);
33
+ }
34
+
35
+ &:active {
36
+ background-color: rgba(var(--pix-neutral-100-inline), 0.75);
37
+ }
38
+ }
39
+
20
40
  table {
21
41
  min-width: 100%;
22
42
  border-collapse: collapse;
23
43
 
24
- tbody > tr:nth-of-type(even) {
25
- background-color: var(--pix-neutral-20);
44
+ tbody > tr:nth-of-type(even):not(.pix-table__clickable-row:hover, .pix-table__clickable-row:focus, .pix-table__clickable-row:active) {
45
+ background-color: rgba(var(--pix-neutral-20-inline), 0.80);
26
46
  }
27
47
 
28
48
  thead.pix-table-header {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1024pix/pix-ui",
3
- "version": "54.11.0",
3
+ "version": "54.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"