Skip to content

Commit

Permalink
Merge branch 'main' of github.com:carbon-design-system/carbon-for-ibm…
Browse files Browse the repository at this point in the history
…-dotcom into renovate/carbon-react-1.x
  • Loading branch information
kennylam committed Apr 17, 2024
2 parents 22c7a5f + 1074e67 commit edc3ca4
Show file tree
Hide file tree
Showing 40 changed files with 295 additions and 499 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.
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.
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.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<link rel="stylesheet"
href="https://1.www.s81c.com/common/carbon-for-ibm-dotcom/tag/v1/latest/plex.css"/>
<link rel="stylesheet" href="https://1.www.s81c.com/common/carbon/web-components/tag/v2/latest/grid.css" />
<link rel="stylesheet" href="https://1.www.s81c.com/common/carbon/web-components/tag/v2/latest/themes.css" />
<link rel="stylesheet" href="https://1.www.s81c.com/common/carbon/web-components/tag/v2/latest/themes.css" />
<style>
/* Suppress custom element until styles are loaded */
cds-slug:not(:defined) {
Expand All @@ -24,7 +24,7 @@
<script type="module" src="https://1.www.s81c.com/common/carbon/web-components/slug/v2/latest/slug.min.js"></script>
</head>
<body class="cds-theme-zone-white">
<cds-slug size="mini" kind="hollow" alignment="bottom-left">
<cds-slug size="mini" alignment="bottom-left">
<span slot="body-text">AI was used to generate this content</span>
</cds-slug>
</body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<meta charset="UTF-8" />
<link rel="stylesheet"
href="https://1.www.s81c.com/common/carbon-for-ibm-dotcom/tag/v1/latest/plex.css"/>

<link rel="stylesheet" href="src/styles.scss" />
<style>
/* Suppress custom element until styles are loaded */
Expand All @@ -24,7 +24,7 @@
<script type="module" src="src/index.js"></script>
</head>
<body>
<cds-slug size="mini" kind="hollow" alignment="bottom-left">
<cds-slug size="mini" alignment="bottom-left">
<span slot="body-text">AI was used to generate this content</span>
</cds-slug>
</body>
Expand Down
4 changes: 2 additions & 2 deletions packages/carbon-web-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"dependencies": {
"@babel/runtime": "^7.16.3",
"@carbon/ibm-products-styles": "^2.30.1",
"@carbon/styles": "1.53.0",
"@carbon/styles": "1.54.0",
"@floating-ui/dom": "^1.6.3",
"@ibm/telemetry-js": "^1.2.1",
"flatpickr": "4.6.13",
Expand Down Expand Up @@ -194,7 +194,7 @@
"resize-observer-polyfill": "^1.5.0",
"rollup": "^2.55.1",
"rollup-plugin-multi-input": "^1.3.1",
"sass": "~1.74.0",
"sass": "~1.75.0",
"sass-loader": "^10.0.0",
"strip-comments": "^1.0.0",
"style-loader": "^2.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,15 @@
border: 1px solid transparent;
background-color: $layer;
box-shadow: inset 0 -80px 70px -65px $ai-inner-shadow,
0 4px 10px 2px $ai-drop-shadow;
0 24px 40px -24px $ai-drop-shadow;
}

:host(#{$prefix}-modal[slug][has-footer]) .#{$prefix}--modal-container {
@include ai-popover-gradient('default', 64px, 'layer');

box-shadow: inset 0 -80px 0 -16px $layer,
inset 0 -160px 70px -65px $ai-inner-shadow, 0 4px 10px 2px $ai-drop-shadow;
inset 0 -160px 70px -65px $ai-inner-shadow,
0 24px 40px -24px $ai-drop-shadow;
}

:host(#{$prefix}-modal[slug][has-scrolling-content]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ const content = html`
</div>
`;

const hollowContent = html`<span slot="body-text"
>AI was used to generate this content</span
>`;

const actions = html`
<cds-icon-button kind="ghost" slot="actions" size="lg">
${View16({ slot: 'icon' })}
Expand Down Expand Up @@ -230,7 +226,7 @@ Tooltip.parameters = {
};

export const Slug = (args) => {
const { alignment, aiTextLabel, size, kind, dotType, revertActive } =
const { alignment, aiTextLabel, size, kind, revertActive } =
args?.[`${prefix}-slug`] ?? {};
return html`
<style>
Expand All @@ -242,11 +238,9 @@ export const Slug = (args) => {
alignment="${ifDefined(alignment)}"
size="${size}"
kind="${kind}"
dot-type="${dotType}"
ai-text-label="${aiTextLabel}"
?revert-active="${revertActive}">
${kind === 'hollow' || dotType === 'hollow' ? hollowContent : content}
${kind === 'hollow' || dotType === 'hollow' ? '' : actions}
${content} ${actions}
</cds-slug>
</div>
`;
Expand All @@ -255,15 +249,7 @@ export const Slug = (args) => {
Slug.parameters = {
knobs: {
[`${prefix}-slug`]: () => {
const kind = select(
'Kind (kind)',
['default', 'hollow', 'inline'],
'default'
);
const dotType =
kind === 'inline'
? select('DotType (dotType)', ['default', 'hollow'], 'default')
: ``;
const kind = select('Kind (kind)', ['default', 'inline'], 'default');

return {
alignment: select(
Expand All @@ -273,7 +259,6 @@ Slug.parameters = {
),
size: select('Slug size (size)', sizes, SLUG_SIZE.EXTRA_SMALL),
kind,
dotType,
aiTextLabel: textNullable('Ai text label', ''),
revertActive: boolean('Revert active', false),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ $popover-caret-height: custom-property.get-var(
}
}

:host(#{$prefix}-slug[alignment^='bottom']:not([autoalign]))
.#{$prefix}--popover-caret {
clip-path: none;
}

:host(#{$prefix}-tooltip-content[align='bottom']:not([autoalign])),
:host(#{$prefix}-popover-content[align='bottom']:not([autoalign])),
:host(#{$prefix}-toggletip[alignment='bottom']:not([autoalign])),
Expand Down
22 changes: 1 addition & 21 deletions packages/carbon-web-components/src/components/slug/defs.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @license
*
* Copyright IBM Corp. 2020, 2022, 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 @@ -56,28 +56,8 @@ export enum SLUG_KIND {
*/
DEFAULT = '',

/**
* Hollow kind.
*/
HOLLOW = 'hollow',

/**
* Inline kind.
*/
INLINE = 'inline',
}

/**
* Slug dot type.
*/
export enum SLUG_DOT_TYPE {
/**
* Default dot type.
*/
DEFAULT = '',

/**
* Hollow dot type.
*/
HOLLOW = 'hollow',
}
48 changes: 13 additions & 35 deletions packages/carbon-web-components/src/components/slug/slug-story.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import { cdnJs, cdnCss } from '../../globals/internal/storybook-cdn';
[![Edit carbon-web-components](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/github/carbon-design-system/carbon-for-ibm-dotcom/tree/main/packages/carbon-web-components/examples/codesandbox/basic/components/slug)

The AI slug is intended for any scenario where something is being generated by (or with) AI to reinforce AI transparency, accountability, and explainability at any interface level. This also enables more effective recognition and recall of AI instances in a way that is identifiable across any IBM product.
The AI slug is intended for any scenario where something is being generated by
(or with) AI to reinforce AI transparency, accountability, and explainability at
any interface level. This also enables more effective recognition and recall of
AI instances in a way that is identifiable across any IBM product.

## Getting started

Expand All @@ -32,22 +35,20 @@ import '@carbon/web-components/es/components/slug/index.js';

```html
<cds-slug size="mini" alignment="bottom-left">
<div slot="body-text">
{Content Here}
</div>
<div slot="body-text">{Content Here}</div>
</cds-slug>
```

### HTML (with actions)

The `Slug` also supports the rendering of an action bar at the bottom of the
callout. To achieve this, you can add elements with `slot="actions"` inside the `slot="body-text"` element
callout. To achieve this, you can add elements with `slot="actions"` inside the
`slot="body-text"` element

```html
<cds-slug size="mini" alignment="bottom-left">
<div slot="body-text">
{Content Here}
{Optional Slug action bar}
{Content Here} {Optional Slug action bar}
<cds-icon-button kind="ghost" slot="actions" size="lg">
${View16({ slot: 'icon' })}
<span slot="tooltip-content"> View </span>
Expand All @@ -70,12 +71,9 @@ callout. To achieve this, you can add elements with `slot="actions"` inside the
If needed, you can change the text inside the `Slug` when translating to
different languages.


```html
<cds-slug ai-text="IA">
<div slot="body-text">
Explanation of AI-generated content
</div>
<div slot="body-text">Explanation of AI-generated content</div>
</cds-slug>
```

Expand All @@ -86,43 +84,23 @@ the `ai-text-label` prop.

```html
<cds-slug kind="inline" ai-text-label="Text goes here">
<div slot="body-text">
Explanation of AI-generated content
</div>
</cds-slug>
```

### Slug `dotType`

When using the `inline` variant, you can switch between the `hollow` slug for
content that does not need additional explainability or the `default` variant
that will render the AI callout.

```html
<cds-slug kind="inline" dot-type="hollow" ai-text-label="Text goes here">
<div slot="body-text">
Explanation of AI-generated content
</div>
<div slot="body-text">Explanation of AI-generated content</div>
</cds-slug>
```

### Slug `kind`

The `Slug` component has three variants, `default`, `hollow`, and `inline`. The
`hollow` slugs represent items that don’t have any additional explainability.
Therefore they don’t use the AI callout and instead use the standard Carbon
tooltip, with a simple message.
The `Slug` component has two variants, `default` and `inline`.

```html
<cds-slug kind="hollow" size="xs">
<cds-slug size="xs">
<div slot="body-text">AI was used to generate this content</div>
</cds-slug>
```

The `inline` `Slug` with the standard icon can also trigger the AI
explainability callout.


```html
<cds-slug kind="inline" ai-text-label="Text goes here" size="xs">
<div slot="body-text">Explanation of AI-generated content</div>
Expand All @@ -146,4 +124,4 @@ Note: For `boolean` attributes, `true` means simply setting the attribute (e.g.
`<cds-slug revert-active>`) and `false` means not setting the attribute (e.g.
`<cds-slug>` without `revertActive` attribute).

<Props of="cds-slug" />
<Props of="cds-slug" />
Loading

0 comments on commit edc3ca4

Please sign in to comment.