Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Tearsheet): Slug to aiLabel #6169

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
f54338a
feat(Tearsheet): slug to ai label
sangeethababu9223 Oct 7, 2024
245ae9d
feat(tearsheet): update cspell
sangeethababu9223 Oct 7, 2024
f01b87c
Merge remote-tracking branch 'upstream/main' into feat/tearsheet-slug…
sangeethababu9223 Oct 9, 2024
d135f42
feat(Tearsheet): deprecation message update
sangeethababu9223 Oct 9, 2024
b64d201
feat(Tearsheet): remove log
sangeethababu9223 Oct 9, 2024
5c5493b
feat(Tearsheet): test case fail fix
sangeethababu9223 Oct 9, 2024
90783ce
Merge remote-tracking branch 'upstream/main' into feat/tearsheet-slug…
sangeethababu9223 Oct 11, 2024
35137e1
feat(Tearsheet): aiLabel classes updated per core carbon
sangeethababu9223 Oct 11, 2024
6eb4e2a
feat(Tearhseet): story control update
sangeethababu9223 Oct 11, 2024
746d022
Update cspell.json
sangeethababu9223 Oct 18, 2024
489c4d7
Update cspell.json
sangeethababu9223 Oct 18, 2024
32cc5bb
Update packages/ibm-products/src/components/Tearsheet/Tearsheet.stori…
sangeethababu9223 Oct 18, 2024
e83df20
Update packages/ibm-products/src/components/Tearsheet/Tearsheet.stori…
sangeethababu9223 Oct 18, 2024
a072cf1
Update packages/ibm-products/src/components/Tearsheet/TearsheetShell.tsx
sangeethababu9223 Oct 18, 2024
1c0d842
Update packages/ibm-products/src/components/Tearsheet/TearsheetShell.tsx
sangeethababu9223 Oct 18, 2024
0fb5d09
Merge branch 'main' into feat/tearsheet-slug-to-ailabel
sangeethababu9223 Oct 18, 2024
2aa3ba2
fix(Tearsheet): spelling issue fix
sangeethababu9223 Oct 18, 2024
98c85ed
fix(tearsheet): resolve conflict
sangeethababu9223 Oct 21, 2024
099c149
fix(Tearsheet): resolve conflicts
sangeethababu9223 Oct 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
"disttags",
"dragbar",
"draggable",
"interstitialscreenviewmodule",
"draghandle",
"dragmode",
"editinplace",
Expand Down
2 changes: 1 addition & 1 deletion e2e/components/Tearsheet/TearsheetNarrow-test.avt.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ test.describe('TearsheetNarrow @avt', () => {
await expect(page).toHaveNoACViolations(
'TearsheetNarrow @avt-all-header-items'
);
await expect(page.locator('.slug-container')).toBeInViewport();
await expect(page.locator('.ai-label-container')).toBeInViewport();

// Selecting the first slug button
const slugButton1 = page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ $motion-duration: $duration-moderate-02;
}

&.#{$block-class}.#{$block-class}.#{$block-class}.#{$block-class}--has-slug
.#{$block-class}__container,
&.#{$block-class}.#{$block-class}.#{$block-class}.#{$block-class}--has-ai-label
.#{$block-class}__container {
border: 1px solid transparent;
border-bottom: 0;
Expand Down Expand Up @@ -276,11 +278,15 @@ $motion-duration: $duration-moderate-02;

&.#{$block-class}--wide
.#{$block-class}__header.#{$block-class}__header--with-close-icon,
&.#{$block-class}--has-slug .#{$block-class}__header.#{$block-class}__header {
&.#{$block-class}--has-slug .#{$block-class}__header.#{$block-class}__header,
&.#{$block-class}--has-ai-label
.#{$block-class}__header.#{$block-class}__header {
padding-inline-end: $spacing-11;
}

&.#{$block-class}--wide.#{$block-class}--has-slug
.#{$block-class}__header.#{$block-class}__header--with-close-icon,
&.#{$block-class}--wide.#{$block-class}--has-ai-label
.#{$block-class}__header.#{$block-class}__header--with-close-icon {
/* spacing 11 plus additional space for slug/close */
/* stylelint-disable-next-line carbon/layout-token-use */
Expand Down Expand Up @@ -362,7 +368,8 @@ $motion-duration: $duration-moderate-02;
flex-grow: 1;
}

&.#{$block-class}--has-slug .#{$block-class}__content {
&.#{$block-class}--has-slug .#{$block-class}__content,
&.#{$block-class}--has-ai-label .#{$block-class}__content {
@include utilities.ai-popover-gradient('default', 0);

box-shadow: inset 0 -80px 70px -65px $ai-inner-shadow;
Expand Down Expand Up @@ -418,12 +425,15 @@ $motion-duration: $duration-moderate-02;
background: $background;
}

&.#{$block-class}--has-slug {
&.#{$block-class}--has-slug,
&.#{$block-class}--has-ai-label {
/* stylelint-disable-next-line carbon/theme-token-use */
--overlay-color: #{$ai-overlay};
}

&.#{$block-class}--has-slug:not(.#{$block-class}--has-close)
.#{$carbon-prefix}--slug,
&.#{$block-class}--has-ai-label:not(.#{$block-class}--has-close)
.#{$carbon-prefix}--slug {
inset-inline-end: 0;
margin-block: 6px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import {
TabPanel,
TabList,
TextInput,
unstable__Slug as Slug,
unstable__SlugContent as SlugContent,
AILabel,
AILabelContent,
} from '@carbon/react';

import { Tearsheet, deprecatedProps } from './Tearsheet';
Expand Down Expand Up @@ -102,15 +102,29 @@ export default {
navigation: { control: { disable: true } },
open: { control: { disable: true } },
portalTarget: { control: { disable: true } },
aiLabel: {
control: {
type: 'select',
labels: {
0: 'No AI Label',
1: 'with AI Label',
},
default: 0,
},
description:
'Optional prop that is intended for any scenario where something is being generated by AI to reinforce AI transparency, accountability, and explainability at the UI level.',
options: [0, 1],
},
slug: {
control: {
type: 'select',
labels: {
0: 'No AI slug',
0: 'No AI Slug',
1: 'with AI Slug',
},
default: 0,
},
description: 'Deprecated: Property replaced by "aiLabel"',
options: [0, 1],
},
},
Expand Down Expand Up @@ -158,9 +172,9 @@ const mainContent = (

const title = 'Title of the tearsheet';

const sampleSlug = (
<Slug className="slug-container" size="xs">
<SlugContent>
const sampleAILabel = (
<AILabel className="ai-label-container" size="xs">
<AILabelContent>
<div>
<p className="secondary">AI Explained</p>
<h1>84%</h1>
Expand All @@ -174,13 +188,13 @@ const sampleSlug = (
<p className="secondary">Model type</p>
<p className="bold">Foundation model</p>
</div>
</SlugContent>
</Slug>
</AILabelContent>
</AILabel>
);

// Template.
// eslint-disable-next-line react/prop-types
const Template = ({ actions, slug, ...args }) => {
const Template = ({ actions, aiLabel, slug, ...args }) => {
const [open, setOpen] = useState(false);

const wiredActions =
Expand Down Expand Up @@ -211,7 +225,8 @@ const Template = ({ actions, slug, ...args }) => {
actions={wiredActions}
open={open}
onClose={() => setOpen(false)}
slug={slug && sampleSlug}
aiLabel={aiLabel && sampleAILabel}
slug={slug && sampleAILabel}
>
{mainContent}
</Tearsheet>
Expand All @@ -231,7 +246,7 @@ const tabs = (
</div>
);

const TemplateWithNav = ({ actions, slug, ...args }) => {
const TemplateWithNav = ({ actions, aiLabel, slug, ...args }) => {
const [open, setOpen] = useState(false);

const wiredActions =
Expand Down Expand Up @@ -263,7 +278,8 @@ const TemplateWithNav = ({ actions, slug, ...args }) => {
actions={wiredActions}
open={open}
onClose={() => setOpen(false)}
slug={slug && sampleSlug}
aiLabel={aiLabel && sampleAILabel}
slug={slug && sampleAILabel}
>
<TabPanels>
<TabPanel>Tab 1</TabPanel>
Expand All @@ -278,7 +294,7 @@ const TemplateWithNav = ({ actions, slug, ...args }) => {
);
};

const ReturnFocusTemplate = ({ actions, slug, ...args }) => {
const ReturnFocusTemplate = ({ actions, aiLabel, slug, ...args }) => {
const [open, setOpen] = useState(false);
const buttonRef = useRef(undefined);

Expand Down Expand Up @@ -312,7 +328,8 @@ const ReturnFocusTemplate = ({ actions, slug, ...args }) => {
actions={wiredActions}
open={open}
onClose={() => setOpen(false)}
slug={slug && sampleSlug}
aiLabel={aiLabel && sampleAILabel}
slug={slug && sampleAILabel}
launcherButtonRef={buttonRef}
>
{mainContent}
Expand All @@ -322,9 +339,8 @@ const ReturnFocusTemplate = ({ actions, slug, ...args }) => {
);
};

const FirstElementDisabledTemplate = ({ actions, slug, ...args }) => {
const FirstElementDisabledTemplate = ({ actions, aiLabel, slug, ...args }) => {
const [open, setOpen] = useState(false);

const wiredActions =
actions &&
Array.prototype.map.call(actions, (action) => {
Expand All @@ -342,7 +358,6 @@ const FirstElementDisabledTemplate = ({ actions, slug, ...args }) => {
});

const ref = useRef(undefined);

return (
<>
<style>{`.${pkg.prefix}--tearsheet { opacity: 0 }`};</style>
Expand All @@ -353,7 +368,8 @@ const FirstElementDisabledTemplate = ({ actions, slug, ...args }) => {
actions={wiredActions}
open={open}
onClose={() => setOpen(false)}
slug={slug && sampleSlug}
aiLabel={aiLabel && sampleAILabel}
slug={slug && sampleAILabel}
>
<div className="tearsheet-stories__dummy-content-block">
<Form>
Expand Down Expand Up @@ -389,7 +405,7 @@ const FirstElementDisabledTemplate = ({ actions, slug, ...args }) => {
};

// eslint-disable-next-line react/prop-types
const StackedTemplate = ({ mixedSizes, actions, slug, ...args }) => {
const StackedTemplate = ({ mixedSizes, actions, aiLabel, slug, ...args }) => {
const [open1, setOpen1] = useState(false);
const [open2, setOpen2] = useState(false);
const [open3, setOpen3] = useState(false);
Expand Down Expand Up @@ -485,7 +501,8 @@ const StackedTemplate = ({ mixedSizes, actions, slug, ...args }) => {
open={open1}
onClose={() => setOpen1(false)}
selectorPrimaryFocus="#stacked-input-1"
slug={slug && sampleSlug}
aiLabel={aiLabel && sampleAILabel}
slug={slug && sampleAILabel}
>
<div className="tearsheet-stories__dummy-content-block">
Main content 1
Expand Down Expand Up @@ -515,7 +532,8 @@ const StackedTemplate = ({ mixedSizes, actions, slug, ...args }) => {
open={open2}
onClose={() => setOpen2(false)}
selectorPrimaryFocus="#stacked-input-2"
slug={slug && sampleSlug}
aiLabel={aiLabel && sampleAILabel}
slug={slug && sampleAILabel}
>
<div className="tearsheet-stories__dummy-content-block">
Main content 2
Expand All @@ -533,7 +551,8 @@ const StackedTemplate = ({ mixedSizes, actions, slug, ...args }) => {
open={open3}
onClose={() => setOpen3(false)}
selectorPrimaryFocus="#stacked-input-3"
slug={slug && sampleSlug}
aiLabel={aiLabel && sampleAILabel}
slug={slug && sampleAILabel}
>
<div className="tearsheet-stories__dummy-content-block">
Main content 3
Expand Down Expand Up @@ -622,7 +641,8 @@ fullyLoaded.args = {
onClose: action('onClose called'),
title,
actions: 0,
slug: 1,
aiLabel: 1,
slug: 0,
};

// eslint-disable-next-line react/prop-types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import {
Form,
FormGroup,
TextInput,
unstable__Slug as Slug,
unstable__SlugContent as SlugContent,
AILabel,
AILabelContent,
} from '@carbon/react';

import { TearsheetNarrow, deprecatedProps } from './TearsheetNarrow';
Expand Down Expand Up @@ -59,15 +59,29 @@ export default {
onClose: { control: { disable: true } },
open: { control: { disable: true } },
portalTarget: { control: { disable: true } },
aiLabel: {
control: {
type: 'select',
labels: {
0: 'No AI Label',
1: 'with AI Label',
},
default: 0,
},
description:
'Optional prop that is intended for any scenario where something is being generated by AI to reinforce AI transparency, accountability, and explainability at the UI level.',
options: [0, 1],
},
slug: {
control: {
type: 'select',
labels: {
0: 'No AI slug',
0: 'No AI Slug',
1: 'with AI Slug',
},
default: 0,
},
description: 'deprecated Property replaced by "aiLabel"',
options: [0, 1],
},
},
Expand Down Expand Up @@ -99,9 +113,9 @@ const mainContent = (

const title = 'Title of the tearsheet';

const sampleSlug = (
<Slug className="slug-container" size="xs">
<SlugContent>
const sampleAILabel = (
<AILabel className="ai-label-container" size="xs">
<AILabelContent>
<div>
<p className="secondary">AI Explained</p>
<h1>84%</h1>
Expand All @@ -115,13 +129,13 @@ const sampleSlug = (
<p className="secondary">Model type</p>
<p className="bold">Foundation model</p>
</div>
</SlugContent>
</Slug>
</AILabelContent>
</AILabel>
);

// Template.
// eslint-disable-next-line react/prop-types
const Template = ({ actions, slug, ...args }) => {
const Template = ({ actions, aiLabel, slug, ...args }) => {
const [open, setOpen] = useState(false);
const ref = useRef(undefined);

Expand Down Expand Up @@ -149,7 +163,8 @@ const Template = ({ actions, slug, ...args }) => {
actions={wiredActions}
open={open}
onClose={() => setOpen(false)}
slug={slug && sampleSlug}
aiLabel={aiLabel && sampleAILabel}
slug={slug && sampleAILabel}
>
{mainContent}
</TearsheetNarrow>
Expand All @@ -159,7 +174,7 @@ const Template = ({ actions, slug, ...args }) => {
};

// eslint-disable-next-line react/prop-types
const StackedTemplate = ({ actions, slug, ...args }) => {
const StackedTemplate = ({ actions, aiLabel, slug, ...args }) => {
const [open1, setOpen1] = useState(false);
const [open2, setOpen2] = useState(false);
const [open3, setOpen3] = useState(false);
Expand Down Expand Up @@ -231,7 +246,8 @@ const StackedTemplate = ({ actions, slug, ...args }) => {
title="Tearsheet #1"
open={open1}
onClose={() => setOpen1(false)}
slug={slug && sampleSlug}
aiLabel={aiLabel && sampleAILabel}
slug={slug && sampleAILabel}
>
<div className="tearsheet-stories__narrow-content-block">
Main content 1
Expand All @@ -243,7 +259,8 @@ const StackedTemplate = ({ actions, slug, ...args }) => {
title="Tearsheet #2"
open={open2}
onClose={() => setOpen2(false)}
slug={slug && sampleSlug}
aiLabel={aiLabel && sampleAILabel}
slug={slug && sampleAILabel}
selectorPrimaryFocus="#main-content"
>
<div className="tearsheet-stories__narrow-content-block">
Expand All @@ -256,7 +273,8 @@ const StackedTemplate = ({ actions, slug, ...args }) => {
title="Tearsheet #3"
open={open3}
onClose={() => setOpen3(false)}
slug={slug && sampleSlug}
aiLabel={aiLabel && sampleAILabel}
slug={slug && sampleAILabel}
selectorPrimaryFocus="#main-content"
>
<div className="tearsheet-stories__narrow-content-block">
Expand Down Expand Up @@ -289,7 +307,8 @@ fullyLoaded.args = {
onClose: action('onClose called'),
title,
actions: 0,
slug: 1,
aiLabel: 1,
slug: 0,
};

export const stacked = StackedTemplate.bind({});
Expand Down
Loading
Loading