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(select): add new decorator prop #18107

Merged
merged 21 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -6830,6 +6830,9 @@ Map {
"className": Object {
"type": "string",
},
"decorator": Object {
"type": "node",
},
"defaultValue": Object {
"type": "any",
},
Expand Down Expand Up @@ -6878,9 +6881,7 @@ Map {
],
"type": "oneOf",
},
"slug": Object {
"type": "node",
},
"slug": [Function],
"warn": Object {
"type": "bool",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ import {
ToggletipButton,
ToggletipContent,
} from '../Toggletip';
import { Information } from '@carbon/icons-react';
import Button from '../Button';
import { AILabel, AILabelContent, AILabelActions } from '../AILabel';
import { IconButton } from '../IconButton';
import { Information, View, FolderOpen, Folders } from '@carbon/icons-react';
import mdx from './FluidSelect.mdx';

export default {
Expand Down Expand Up @@ -113,6 +116,52 @@ export const Default = () => (
</div>
);

const aiLabel = (
<AILabel className="ai-label-container">
<AILabelContent>
<div>
<p className="secondary">AI Explained</p>
<h1>84%</h1>
<p className="secondary bold">Confidence score</p>
<p className="secondary">
Lorem ipsum dolor sit amet, di os consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut fsil labore et dolore magna aliqua.
</p>
<hr />
<p className="secondary">Model type</p>
<p className="bold">Foundation model</p>
</div>
<AILabelActions>
<IconButton kind="ghost" label="View">
<View />
</IconButton>
<IconButton kind="ghost" label="Open Folder">
<FolderOpen />
</IconButton>
<IconButton kind="ghost" label="Folders">
<Folders />
</IconButton>
<Button>View details</Button>
</AILabelActions>
</AILabelContent>
</AILabel>
);

export const withAILabel = () => (
<div style={{ width: 400 }}>
<FluidSelect id="select-1" labelText="Select an option" decorator={aiLabel}>
<SelectItem value="" text="" />
<SelectItem
value="An example option that is really long to show what should be done to handle long text"
text="An example option that is really long to show what should be done to handle long text"
/>
<SelectItem value="Option 2" text="Option 2" />
<SelectItem value="Option 3" text="Option 3" />
<SelectItem value="Option 4" text="Option 4" />
</FluidSelect>
</div>
);

export const Playground = (args) => (
<div style={{ width: args.playgroundWidth }}>
<FluidSelect {...args} id="select-1">
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/components/Form/Form.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ export const withAILabel = (args) => {
id="select-1"
labelText="Select an option"
helperText="Optional helper text"
slug={aiLabel}
decorator={aiLabel}
{...rest}>
<SelectItem value="" text="" />
<SelectItem
Expand Down Expand Up @@ -476,7 +476,7 @@ export const withAILabel = (args) => {
/>
</div>
<div style={{ display: 'flex' }}>
<FluidSelect slug={aiLabel} {...rest} id="select-2">
<FluidSelect decorator={aiLabel} {...rest} id="select-2">
<SelectItem value="" text="" />
<SelectItem value="option-1" text="Option 1" />
<SelectItem value="option-2" text="Option 2" />
Expand Down
Loading
Loading