Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/github_actions/github/codeql-acti…
Browse files Browse the repository at this point in the history
…on-3
  • Loading branch information
kennylam authored Dec 15, 2023
2 parents e5f3b07 + 6f5a1b1 commit 5dec64f
Show file tree
Hide file tree
Showing 20 changed files with 1,158 additions and 72 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: ci-check

on:
push:
branches: [ main, release/v2*, feat/*, fix/content-updates ]
branches: [ main, release/*, release-cwc/*, feat/*, fix/content-updates ]
pull_request:
branches: [ main, release/v2*, feat/*, fix/content-updates ]
branches: [ main, release/*, release-cwc/*, feat/*, fix/content-updates ]

concurrency:
group: ci-check-${{ github.ref }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/e2e-tests-parallel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
run: yarn build-storybook

- name: Save build folder
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: storybook-build
path: packages/web-components/storybook-static
Expand Down Expand Up @@ -90,7 +90,7 @@ jobs:
cache: 'yarn'

- name: Download the build folders
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: storybook-build
path: packages/web-components/storybook-static
Expand Down Expand Up @@ -125,7 +125,7 @@ jobs:

- name: Save failure file
if: steps.cypress-tests-wc.outcome == 'failure'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: failure-wc
path: failure-wc.txt
Expand All @@ -139,7 +139,7 @@ jobs:
runs-on: ubuntu-20.04
needs: web-components-tests
steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
continue-on-error: true
with:
name: failure-wc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import { html } from 'lit';
import { action } from '@storybook/addon-actions';
import { boolean } from '@storybook/addon-knobs';
import { ifDefined } from 'lit/directives/if-defined.js';
import { prefix } from '../../globals/settings';
import textNullable from '../../../.storybook/knob-text-nullable';
import './index';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,20 @@
:host(#{$prefix}-table-header-cell[sort-direction]) {
height: $spacing-09;
position: relative;

.#{$prefix}--table-sort__flex {
display: flex;
align-items: center;
justify-content: space-between;
block-size: 100%;
inline-size: 100%;
min-block-size: $spacing-09;
}
}

:host(#{$prefix}-table-header-cell[slug]),
:host(#{$prefix}-table-header-cell[slug]) .#{$prefix}--table-sort {
@include ai-gradient('top', 100%);
}

:host(#{$prefix}-table-header-cell[sticky-header]) {
Expand All @@ -85,6 +99,17 @@
padding-top: rem(14px);
}

:host(#{$prefix}-table-header-cell[slug]) {
.#{$prefix}--table-header-label--slug {
display: flex;
align-items: center;
}

::slotted(#{$prefix}-slug) {
margin-inline-start: $spacing-03;
}
}

//
// Common style for table cell and table header cell
//
Expand Down Expand Up @@ -186,6 +211,35 @@
}
}

:host(#{$prefix}-table-header-row),
:host(#{$prefix}-table-row) {
.#{$prefix}--table-column-checkbox div,
.#{$prefix}--table-expand div {
display: flex;
height: 100%;
}
}

:host(#{$prefix}-table-header-row[rows-with-slug]) {
.#{$prefix}--table-column-checkbox,
.#{$prefix}--table-expand {
padding-left: $spacing-08;
}
}
:host(#{$prefix}-table-header-row[rows-with-slug]),
:host(#{$prefix}-table-row[rows-with-slug]) {
#{$prefix}-checkbox {
padding-left: $spacing-03;
}
}

:host(#{$prefix}-table-header-row[rows-with-slug][selection-name][expandable]),
:host(#{$prefix}-table-row[rows-with-slug][selection-name][expandable]) {
.#{$prefix}--table-column-checkbox {
padding-left: 0;
}
}

//
// Table row
//
Expand Down Expand Up @@ -396,6 +450,26 @@
}
}

:host(#{$prefix}-table-row[rows-with-slug]) {
::slotted(#{$prefix}-slug) {
padding: 0 $spacing-03;
margin-left: -$spacing-07;
}
}

:host(#{$prefix}-table-row[rows-with-slug]) {
.#{$prefix}--table-column-checkbox,
.#{$prefix}--table-expand {
padding-left: $spacing-08;
}
}

:host(#{$prefix}-table-row[slug]) {
@include ai-gradient('left', 50%);

background-attachment: fixed;
}

:host(#{$prefix}-table-header-title) {
@extend .#{$prefix}--data-table-header__title;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,16 @@
:host(#{$prefix}-table-row[filtered]) {
display: none !important;
}

:host(#{$prefix}-table-row[selected][slug]) {
.#{$prefix}--table-column-checkbox,
::slotted(#{$prefix}-table-cell),
.#{$prefix}--table-expand,
.#{$prefix}--table-column-checkbox {
background-color: transparent;
}
}

:host(#{$prefix}-table-row[selected][rows-with-slug]) {
background-color: $layer-selected;
}
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,6 @@
//
// "selection" and "expandable" sizes
//
:host(#{$prefix}-table-header-row[selection-name][expandable]),
:host(#{$prefix}-table-row[selection-name][expandable]) {
::slotted(#{$prefix}-table-header-cell),
::slotted(#{$prefix}-table-cell) {
padding-left: $spacing-03;
}
}

:host(#{$prefix}-table-header-row[selection-name][expandable][size='xs']),
:host(#{$prefix}-table-row[selection-name][expandable][size='xs']) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,10 @@
.#{$prefix}--table-sort__icon {
transform: rotate(180deg);
}

:host(#{$prefix}-table-header-cell[sort-direction]) {
::slotted(#{$prefix}-slug) {
margin-inline-end: auto;
margin-inline-start: $spacing-03;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ $css--plex: true !default;
@use '@carbon/styles/scss/spacing' as *;
@use '@carbon/styles/scss/motion' as *;
@use '@carbon/styles/scss/utilities/convert' as *;
@use '@carbon/styles/scss/utilities/ai-gradient' as *;
@use '@carbon/styles/scss/components/checkbox';

@use '@carbon/styles/scss/components/data-table' as *;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import { LitElement, html } from 'lit';
import { property } from 'lit/decorators.js';
import { classMap } from 'lit/directives/class-map.js';
import ArrowsVertical32 from '@carbon/icons/lib/arrows--vertical/32';
import ArrowDown32 from '@carbon/icons/lib/arrow--down/32';
import { prefix } from '../../globals/settings';
Expand Down Expand Up @@ -37,23 +38,29 @@ class CDSTableHeaderCell extends FocusMixin(LitElement) {
* Handles `click` event on the sort button.
*
*/
private _handleClickSortButton() {
const nextSortDirection = this._getNextSort();
const init = {
bubbles: true,
cancelable: true,
composed: true,
detail: {
oldSortDirection: this.sortDirection,
sortDirection: nextSortDirection,
},
};
const constructor = this.constructor as typeof CDSTableHeaderCell;
private _handleClickSortButton(event) {
if (
this.dispatchEvent(new CustomEvent(constructor.eventBeforeSort, init))
!(event.target as HTMLElement).matches(
(this.constructor as typeof CDSTableHeaderCell).slugItem
)
) {
this.sortActive = true;
this.sortDirection = nextSortDirection;
const nextSortDirection = this._getNextSort();
const init = {
bubbles: true,
cancelable: true,
composed: true,
detail: {
oldSortDirection: this.sortDirection,
sortDirection: nextSortDirection,
},
};
const constructor = this.constructor as typeof CDSTableHeaderCell;
if (
this.dispatchEvent(new CustomEvent(constructor.eventBeforeSort, init))
) {
this.sortActive = true;
this.sortDirection = nextSortDirection;
}
}
}

Expand All @@ -65,6 +72,26 @@ class CDSTableHeaderCell extends FocusMixin(LitElement) {
this.requestUpdate();
}

/**
* Handles `slotchange` event.
*/
protected _handleSlugSlotChange({ target }: Event) {
const hasContent = (target as HTMLSlotElement)
.assignedNodes()
.filter((elem) =>
(elem as HTMLElement).matches !== undefined
? (elem as HTMLElement).matches(
(this.constructor as typeof CDSTableHeaderCell).slugItem
)
: false
);
if (hasContent.length > 0) {
this._hasSlug = Boolean(hasContent);
(hasContent[0] as HTMLElement).setAttribute('size', 'mini');
}
this.requestUpdate();
}

/**
* @returns The next sort direction.
*/
Expand Down Expand Up @@ -94,6 +121,11 @@ class CDSTableHeaderCell extends FocusMixin(LitElement) {
return directions[(index + 1) % directions.length];
}

/**
* `true` if there is a slug.
*/
protected _hasSlug = false;

/**
* `true` if the table has expandable rows
*/
Expand Down Expand Up @@ -149,10 +181,19 @@ class CDSTableHeaderCell extends FocusMixin(LitElement) {
if (this.isSortable && !changedProperties.has('sortDirection')) {
this.sortDirection = TABLE_SORT_DIRECTION.NONE;
}
if (this._hasSlug) {
this.setAttribute('slug', '');
} else {
this.removeAttribute('slug');
}
}

render() {
const { sortDirection } = this;
const labelClasses = classMap({
[`${prefix}--table-header-label`]: true,
[`${prefix}--table-header-label--slug`]: this._hasSlug,
});
if (sortDirection) {
const sortIcon =
sortDirection === TABLE_SORT_DIRECTION.NONE
Expand All @@ -170,14 +211,29 @@ class CDSTableHeaderCell extends FocusMixin(LitElement) {
class="${prefix}--table-sort"
title="${this.textContent}"
@click=${this._handleClickSortButton}>
<span part="label-text" class="${prefix}--table-header-label"
><slot @slotchange=${this._handleSlotChange}></slot
></span>
${sortIcon}
<span class="${prefix}--table-sort__flex">
<span part="label-text" class="${prefix}--table-header-label"
><slot @slotchange=${this._handleSlotChange}></slot
></span>
<slot
name="slug"
@slotchange="${this._handleSlugSlotChange}"></slot>
${sortIcon}
</span>
</button>
`;
}
return html` <slot></slot> `;
return html`<span part="label-text" class="${labelClasses}">
<slot></slot
><slot name="slug" @slotchange="${this._handleSlugSlotChange}"></slot
></span> `;
}

/**
* A selector that will return the slug item.
*/
static get slugItem() {
return `${prefix}-slug`;
}

/**
Expand Down
Loading

0 comments on commit 5dec64f

Please sign in to comment.