Skip to content

Commit

Permalink
feat(slug): ai callout updates for 2.2.0 (#11453)
Browse files Browse the repository at this point in the history
* feat(slug): ai callout updates for 2.2.0

* fix(carbon): upgrade react
  • Loading branch information
ariellalgilmore authored Jan 26, 2024
1 parent 10570d8 commit 8f0b9f6
Show file tree
Hide file tree
Showing 27 changed files with 376 additions and 305 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion packages/carbon-web-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
],
"dependencies": {
"@babel/runtime": "^7.16.3",
"@carbon/styles": "1.47.0",
"@carbon/styles": "1.48.1",
"flatpickr": "4.6.1",
"lit": "^2.7.6",
"lodash-es": "^4.17.21"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license
*
* Copyright IBM Corp. 2019, 2023
* Copyright IBM Corp. 2019, 2024
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
Expand Down Expand Up @@ -332,6 +332,15 @@ class CDSDatePickerInput extends FocusMixin(LitElement) {
`;
}

updated() {
this.shadowRoot
?.querySelector("slot[name='slug']")
?.classList.toggle(
`${prefix}--slug--revert`,
this.querySelector(`${prefix}-slug`)?.hasAttribute('revert-active')
);
}

/**
* The default value for `pattern` property.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license
*
* Copyright IBM Corp. 2019, 2023
* Copyright IBM Corp. 2019, 2024
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
Expand Down Expand Up @@ -676,6 +676,13 @@ class CDSDropdown extends ValidityMixin(
this._hasSlug
? this.setAttribute('slug', '')
: this.removeAttribute('slug');

this.shadowRoot
?.querySelector("slot[name='slug']")
?.classList.toggle(
`${prefix}--slug--revert`,
this.querySelector(`${prefix}-slug`)?.hasAttribute('revert-active')
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright IBM Corp. 2019, 2023
// Copyright IBM Corp. 2019, 2024
//
// This source code is licensed under the Apache-2.0 license found in the
// LICENSE file in the root directory of this source tree.
Expand Down Expand Up @@ -51,6 +51,8 @@
}

:host(#{$prefix}-modal-close-button) {
@extend .#{$prefix}--modal-close-button;

outline: none;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license
*
* Copyright IBM Corp. 2019, 2023
* Copyright IBM Corp. 2019, 2024
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
Expand Down Expand Up @@ -174,13 +174,13 @@ $popover-caret-height: custom-property.get-var(
:host(#{$prefix}-toggletip[alignment='left-bottom']),
:host(#{$prefix}-slug[alignment='left-bottom']) {
.#{$prefix}--popover-content {
inset-block-end: -50%;
inset-block-end: 50%;
inset-inline-end: 100%;
// Add in 0.1px to prevent rounding errors where the content is
// moved farther than the caret
transform: translate(
calc(-1 * $popover-offset),
calc(0.5 * $popover-offset - 16px)
calc(0.5 * $popover-offset + $spacing-05)
);
}
}
Expand All @@ -190,13 +190,13 @@ $popover-caret-height: custom-property.get-var(
:host(#{$prefix}-toggletip[alignment='left-top']),
:host(#{$prefix}-slug[alignment='left-top']) {
.#{$prefix}--popover-content {
inset-block-start: -50%;
inset-block-start: 50%;
inset-inline-end: 100%;
// Add in 0.1px to prevent rounding errors where the content is
// moved farther than the caret
transform: translate(
calc(-1 * $popover-offset),
calc(-1 * 0.5 * $popover-offset + 16px)
calc(-1 * 0.5 * $popover-offset - $spacing-05)
);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license
*
* Copyright IBM Corp. 2020, 2023
* Copyright IBM Corp. 2020, 2024
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
Expand Down Expand Up @@ -342,6 +342,13 @@ class CDSSelect extends FormMixin(LitElement) {
// given reflecting `value` requires child `<option>`s/`<optgroup>`s being there beforehand
this._selectNode.value = !value ? placeholderItemValue : value;
}

this.shadowRoot
?.querySelector("slot[name='slug']")
?.classList.toggle(
`${prefix}--slug--revert`,
this.querySelector(`${prefix}-slug`)?.hasAttribute('revert-active')
);
}

render() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license
*
* Copyright IBM Corp. 2019, 2023
* Copyright IBM Corp. 2019, 2024
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
Expand Down Expand Up @@ -41,7 +41,7 @@ const actions = html`
${Folders16({ slot: 'icon' })}
<span slot="tooltip-content"> Folders </span>
</cds-icon-button>
<cds-slug-action-button>View Literature</cds-slug-action-button>
<cds-slug-action-button>View details</cds-slug-action-button>
`;

export default {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license
*
* Copyright IBM Corp. 2019, 2023
* Copyright IBM Corp. 2019, 2024
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
Expand Down Expand Up @@ -75,7 +75,7 @@ const actions = html`
${Folders16({ slot: 'icon' })}
<span slot="tooltip-content"> Folders </span>
</cds-icon-button>
<cds-slug-action-button>View Literature</cds-slug-action-button>
<cds-slug-action-button>View details</cds-slug-action-button>
`;

export default {
Expand Down Expand Up @@ -468,65 +468,28 @@ export const _Select = () => {
</div> `;
};

const tagTypes = [
'red',
'magenta',
'purple',
'blue',
'cyan',
'teal',
'green',
'gray',
'cool-gray',
'warm-gray',
'high-contrast',
'outline',
];

export const _Tag = () => {
return html`
<style>
return html` <style>
${styles}
</style>
<div class="slug-tag-container">
${tagTypes.map(
(e) => html`<cds-tag type="${e}"
>Tag
<cds-slug alignment="bottom-left"> ${content}${actions}</cds-slug>
</cds-tag>`
)}
</div>
<div class="slug-tag-container">
${tagTypes.map(
(e) =>
html`<cds-tag filter type="${e}">
Tag
<cds-slug alignment="bottom-left"> ${content}${actions}</cds-slug>
</cds-tag>`
)}
</div>
<div class="slug-tag-container">
${tagTypes.map(
(e) =>
html`<cds-tag type="${e}">
${Asleep16({ slot: 'icon' })} Tag
<cds-slug alignment="bottom-left"> ${content}${actions}</cds-slug>
</cds-tag>`
)}
</div>
<div class="slug-tag-container">
${tagTypes.map(
(e) =>
html`<cds-tag filter type="${e}">
${Asleep16({ slot: 'icon' })} Tag
<cds-slug alignment="bottom-left"> ${content}${actions}</cds-slug>
</cds-tag>`
)}
</div>
`;
<cds-tag type="red"
>Tag
<cds-slug alignment="bottom-left"> ${content}${actions}</cds-slug>
</cds-tag>
<cds-tag filter type="purple">
Tag
<cds-slug alignment="bottom-left"> ${content}${actions}</cds-slug>
</cds-tag>
<cds-tag type="blue">
${Asleep16({ slot: 'icon' })} Tag
<cds-slug alignment="bottom-left"> ${content}${actions}</cds-slug>
</cds-tag>
<cds-tag filter type="green">
${Asleep16({ slot: 'icon' })} Tag
<cds-slug alignment="bottom-left"> ${content}${actions}</cds-slug>
</cds-tag>`;
};

export const _TextInput = () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license
*
* Copyright IBM Corp. 2019, 2023
* Copyright IBM Corp. 2019, 2024
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
Expand Down Expand Up @@ -74,7 +74,7 @@ const actions = html`
${Folders16({ slot: 'icon' })}
<span slot="tooltip-content"> Folders </span>
</cds-icon-button>
<cds-slug-action-button>View Literature</cds-slug-action-button>
<cds-slug-action-button>View details</cds-slug-action-button>
`;

export default {
Expand Down
26 changes: 15 additions & 11 deletions packages/carbon-web-components/src/components/slug/slug-story.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/**
* @license
*
* Copyright IBM Corp. 2019, 2024
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
* @license
*
* Copyright IBM Corp. 2019, 2024
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

@use '@carbon/styles/scss/spacing' as *;
@use '@carbon/styles/scss/theme' as *;
Expand All @@ -22,6 +22,14 @@
}
}

.slug-container-example.centered {
align-items: center;
justify-content: center;
margin: 0;
block-size: calc(100vh - 84px);
inline-size: calc(100vw - 84px);
}

p {
@include type-style('body-compact-01');
}
Expand Down Expand Up @@ -111,7 +119,3 @@ div #{$prefix}-selectable-tile::-moz-list-bullet {
#{$prefix}-checkbox-group:not(:first-of-type) {
margin-block-start: $spacing-07;
}

.slug-tag-container {
margin-block-end: $spacing-10;
}
38 changes: 35 additions & 3 deletions packages/carbon-web-components/src/components/slug/slug-story.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license
*
* Copyright IBM Corp. 2019, 2023
* Copyright IBM Corp. 2019, 2024
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
Expand Down Expand Up @@ -81,7 +81,7 @@ const actions = html`
${Folders16({ slot: 'icon' })}
<span slot="tooltip-content"> Folders </span>
</cds-icon-button>
<cds-slug-action-button>View Literature</cds-slug-action-button>
<cds-slug-action-button>View details</cds-slug-action-button>
`;

export const Default = () => {
Expand Down Expand Up @@ -236,7 +236,7 @@ Playground.parameters = {
tooltipAlignments,
POPOVER_ALIGNMENT.BOTTOM
),
size: select('Slug size (size)', sizes, SLUG_SIZE.MEDIUM),
size: select('Slug size (size)', sizes, SLUG_SIZE.EXTRA_SMALL),
kind,
dotType,
aiTextLabel: textNullable('Ai text label', ''),
Expand All @@ -246,6 +246,38 @@ Playground.parameters = {
},
};

export const Test = (args) => {
const { alignment, showActions } = args?.[`${prefix}-slug`] ?? {};
return html`
<style>
${styles}
</style>
<div class="slug-container-example slug-container centered">
<cds-slug
open
alignment="${ifDefined(alignment)}"
size="${SLUG_SIZE.EXTRA_SMALL}">
${content} ${showActions ? actions : ''}
</cds-slug>
</div>
`;
};

Test.parameters = {
knobs: {
[`${prefix}-slug`]: () => {
return {
alignment: select(
'Slug alignment to trigger button (alignment)',
tooltipAlignments,
POPOVER_ALIGNMENT.BOTTOM
),
showActions: boolean('Show actions', false),
};
},
},
};

export default {
title: 'Experimental/Slug',
parameters: {
Expand Down
Loading

0 comments on commit 8f0b9f6

Please sign in to comment.