-
Notifications
You must be signed in to change notification settings - Fork 3
feat: expandable pills and tool workflow styling from Ozwell widget #294
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
Open
aditya-damerla128
wants to merge
12
commits into
mieweb:main
Choose a base branch
from
aditya-damerla128:feat/ai-pill-components
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
cada229
feat: add expandable pills and tool workflow styling from Ozwell widget
aditya-damerla128 6d80258
feat: pill-first tool call, hide flag, safelist + review fixes
aditya-damerla128 cde658c
fix: address ai pill review feedback
aditya-damerla128 933cb0e
Apply suggestions from code review
aditya-damerla128 42f25b4
Potential fix for pull request finding
aditya-damerla128 714560f
fix: address pill accessibility review
aditya-damerla128 6e9bd51
fix: set cancelled pill dark text
aditya-damerla128 eba8a23
fix: address ai pill review followups
aditya-damerla128 c946107
fix: sync pill open state with status
aditya-damerla128 07b3be0
fix: render static pill without disclosure aria
aditya-damerla128 c19f84d
fix: cover pill select accessibility edge cases
aditya-damerla128 a4c4ef1
fix: address copilot cleanup comments
aditya-damerla128 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import { describe, expect, it } from 'vitest'; | ||
| import { screen } from '@testing-library/react'; | ||
| import { renderWithTheme } from '../../test/test-utils'; | ||
| import { CollapsiblePill } from './CollapsiblePill'; | ||
|
|
||
| describe('CollapsiblePill', () => { | ||
| it('renders as a plain pill when there is no content to expand', () => { | ||
| renderWithTheme(<CollapsiblePill label="Tool" />); | ||
|
|
||
| const button = screen.getByRole('button', { name: /tool/i }); | ||
| expect(button).toBeDisabled(); | ||
| expect(button).not.toHaveAttribute('aria-expanded'); | ||
| expect(button).not.toHaveAttribute('aria-controls'); | ||
| expect(button.querySelector('svg')).not.toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('syncs open state when defaultOpen changes', () => { | ||
| const { rerender } = renderWithTheme( | ||
| <CollapsiblePill label="Tool" defaultOpen={false}> | ||
| <div>Tool details</div> | ||
| </CollapsiblePill> | ||
| ); | ||
|
|
||
| const button = screen.getByRole('button', { name: /tool/i }); | ||
| const content = document.getElementById( | ||
| button.getAttribute('aria-controls') ?? '' | ||
| ); | ||
| expect(button).toHaveAttribute('aria-expanded', 'false'); | ||
| expect(content).toHaveAttribute('aria-hidden', 'true'); | ||
|
|
||
| rerender( | ||
| <CollapsiblePill label="Tool" defaultOpen> | ||
| <div>Tool details</div> | ||
| </CollapsiblePill> | ||
| ); | ||
|
|
||
| expect(button).toHaveAttribute('aria-expanded', 'true'); | ||
| expect(content).toHaveAttribute('aria-hidden', 'false'); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| import * as React from 'react'; | ||
| import { cn } from '../../utils/cn'; | ||
| import { ChevronIcon } from './icons'; | ||
|
|
||
| export interface CollapsiblePillProps { | ||
| label: string; | ||
| leadingIcon?: React.ReactNode; | ||
| density?: 'standard' | 'condensed'; | ||
| defaultOpen?: boolean; | ||
| pillClassName?: string; | ||
| className?: string; | ||
| /** Native tooltip shown on hover (e.g. "Show details") */ | ||
| title?: string; | ||
| children?: React.ReactNode; | ||
| } | ||
|
|
||
| export function CollapsiblePill({ | ||
| label, | ||
| leadingIcon, | ||
| density = 'standard', | ||
| defaultOpen = false, | ||
| pillClassName, | ||
| className, | ||
| title, | ||
| children, | ||
| }: CollapsiblePillProps) { | ||
| const hasContent = Boolean(children); | ||
| const [isOpen, setIsOpen] = React.useState(defaultOpen); | ||
| const contentId = React.useId(); | ||
|
|
||
| React.useEffect(() => { | ||
| setIsOpen(defaultOpen); | ||
| }, [defaultOpen]); | ||
|
|
||
| const toggle = () => { | ||
| setIsOpen((open) => !open); | ||
| }; | ||
|
|
||
| return ( | ||
| <div data-slot="collapsible-pill" className={className}> | ||
| <button | ||
| type="button" | ||
| onClick={hasContent ? toggle : undefined} | ||
| aria-expanded={hasContent ? isOpen : undefined} | ||
| aria-controls={hasContent ? contentId : undefined} | ||
| title={title} | ||
| disabled={!hasContent} | ||
| className={cn( | ||
| 'focus-visible:ring-ring inline-flex items-center gap-1.5 border font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1', | ||
| density === 'condensed' | ||
| ? 'rounded-[8px] px-2 py-0.5 text-[10px]' | ||
| : 'rounded-[10px] px-[11px] py-1 text-[11px]', | ||
| pillClassName | ||
| )} | ||
| > | ||
| {leadingIcon} | ||
| <span>{label}</span> | ||
| {hasContent && ( | ||
| <ChevronIcon | ||
| direction={isOpen ? 'down' : 'right'} | ||
| className={ | ||
| density === 'condensed' | ||
| ? 'h-2.5 w-2.5 opacity-60' | ||
| : 'h-3 w-3 opacity-60' | ||
| } | ||
| /> | ||
| )} | ||
| </button> | ||
| {hasContent && ( | ||
| <div | ||
| id={contentId} | ||
| aria-hidden={!isOpen} | ||
| inert={!isOpen || undefined} | ||
| className={cn( | ||
| 'overflow-hidden transition-[max-height,opacity] duration-300 ease-in-out', | ||
| isOpen | ||
| ? 'max-h-[500px] overflow-y-auto opacity-100' | ||
| : 'max-h-0 opacity-0' | ||
| )} | ||
| > | ||
| <div className="mt-1.5">{children}</div> | ||
| </div> | ||
| )} | ||
| </div> | ||
| ); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.