-
Notifications
You must be signed in to change notification settings - Fork 39
chore(atomic): migrate atomic-insight-edit-toggle to Lit #6848
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
Merged
alexprudhomme
merged 11 commits into
main
from
copilot/migrate-atomic-insight-edit-toggle
Jan 7, 2026
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
dc7c0d8
Initial plan
Copilot bbde908
Migrate atomic-insight-edit-toggle component to Lit with unit tests
Copilot 0cc8d3f
Add Storybook stories and MDX documentation for atomic-insight-edit-tβ¦
Copilot 9fbc790
Remove duplicate global declaration in atomic-insight-edit-toggle
Copilot d45e895
try with chromatic
alexprudhomme 65f0224
Merge branch 'main' into copilot/migrate-atomic-insight-edit-toggle
alexprudhomme 4083c87
done
alexprudhomme a048d73
Merge branch 'main' into copilot/migrate-atomic-insight-edit-toggle
alexprudhomme 56bac5e
done
alexprudhomme 271dfc6
Merge branch 'main' into copilot/migrate-atomic-insight-edit-toggle
alexprudhomme de51249
Add generated files
developer-experience-bot[bot] 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
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
26 changes: 26 additions & 0 deletions
26
...rc/components/insight/atomic-insight-edit-toggle/atomic-insight-edit-toggle.mdx
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,26 @@ | ||
| import { Meta } from '@storybook/addon-docs/blocks'; | ||
| import * as AtomicInsightEditToggleStories from './atomic-insight-edit-toggle.new.stories'; | ||
| import { AtomicDocTemplate } from '@/storybook-utils/documentation/atomic-doc-template'; | ||
|
|
||
| <Meta of={AtomicInsightEditToggleStories} /> | ||
|
|
||
| <AtomicDocTemplate | ||
| stories={AtomicInsightEditToggleStories} | ||
| githubPath="insight/atomic-insight-edit-toggle/atomic-insight-edit-toggle.ts" | ||
| tagName="atomic-insight-edit-toggle" | ||
| className="AtomicInsightEditToggle" | ||
| > | ||
|
|
||
| The `atomic-insight-edit-toggle` component provides an edit button for insight interfaces. This is an internal component typically used within other Insight components to provide editing functionality. | ||
|
|
||
| The component can be configured with a callback function and optional tooltip. | ||
|
|
||
| ## Styling | ||
|
|
||
| The component uses the following part attributes for styling: | ||
|
|
||
| - `insight-edit-toggle-container`: The container wrapper | ||
| - `insight-edit-toggle-button`: The button element | ||
| - `insight-edit-toggle-icon`: The edit icon | ||
|
|
||
| </AtomicDocTemplate> |
38 changes: 38 additions & 0 deletions
38
.../components/insight/atomic-insight-edit-toggle/atomic-insight-edit-toggle.new.stories.tsx
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,38 @@ | ||
| import type {Meta, StoryObj as Story} from '@storybook/web-components-vite'; | ||
| import {getStorybookHelpers} from '@wc-toolkit/storybook-helpers'; | ||
| import {parameters} from '@/storybook-utils/common/common-meta-parameters'; | ||
| import {wrapInInsightInterface} from '@/storybook-utils/insight/insight-interface-wrapper'; | ||
|
|
||
| const {decorator, play} = wrapInInsightInterface(); | ||
| const {events, args, argTypes, template} = getStorybookHelpers( | ||
| 'atomic-insight-edit-toggle', | ||
| {excludeCategories: ['methods']} | ||
| ); | ||
|
|
||
| const meta: Meta = { | ||
| component: 'atomic-insight-edit-toggle', | ||
| title: 'Insight/Edit Toggle', | ||
| id: 'atomic-insight-edit-toggle', | ||
| render: (args) => template(args), | ||
| decorators: [decorator], | ||
| parameters: { | ||
| ...parameters, | ||
| actions: { | ||
| handles: events, | ||
| }, | ||
| }, | ||
| args, | ||
| argTypes, | ||
| play, | ||
| }; | ||
|
|
||
| export default meta; | ||
|
|
||
| export const Default: Story = {}; | ||
|
|
||
| export const WithTooltip: Story = { | ||
| name: 'With tooltip', | ||
| args: { | ||
| tooltip: 'Click to edit this item', | ||
| }, | ||
| }; |
1 change: 0 additions & 1 deletion
1
.../atomic/src/components/insight/atomic-insight-edit-toggle/atomic-insight-edit-toggle.pcss
This file was deleted.
Oops, something went wrong.
58 changes: 58 additions & 0 deletions
58
...omic/src/components/insight/atomic-insight-edit-toggle/atomic-insight-edit-toggle.spec.ts
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,58 @@ | ||
| import {html} from 'lit'; | ||
| import {describe, expect, it, vi} from 'vitest'; | ||
| import {page} from 'vitest/browser'; | ||
| import {fixture} from '@/vitest-utils/testing-helpers/fixture'; | ||
| import './atomic-insight-edit-toggle'; | ||
| import type {AtomicInsightEditToggle} from './atomic-insight-edit-toggle'; | ||
|
|
||
| describe('atomic-insight-edit-toggle', () => { | ||
| const renderComponent = async ({ | ||
| clickCallback = vi.fn(), | ||
| tooltip = '', | ||
| } = {}) => { | ||
| const element = await fixture<AtomicInsightEditToggle>(html` | ||
| <atomic-insight-edit-toggle | ||
| .clickCallback=${clickCallback} | ||
| .tooltip=${tooltip} | ||
| ></atomic-insight-edit-toggle> | ||
| `); | ||
|
|
||
| const button = page.getByRole('button', {name: 'Edit'}); | ||
|
|
||
| return { | ||
| element, | ||
| button, | ||
| }; | ||
| }; | ||
|
|
||
| it('should render the edit button', async () => { | ||
| const {button} = await renderComponent(); | ||
| await expect.element(button).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('should call clickCallback when button is clicked', async () => { | ||
| const clickCallback = vi.fn(); | ||
| const {button} = await renderComponent({clickCallback}); | ||
|
|
||
| await button.click(); | ||
|
|
||
| expect(clickCallback).toHaveBeenCalledOnce(); | ||
| }); | ||
|
|
||
| it('should apply tooltip to button', async () => { | ||
| const tooltip = 'Edit this item'; | ||
| const {button} = await renderComponent({tooltip}); | ||
|
|
||
| await expect.element(button).toHaveAttribute('title', tooltip); | ||
| }); | ||
|
|
||
| it('should have correct aria-label', async () => { | ||
| const {button} = await renderComponent(); | ||
| await expect.element(button).toHaveAttribute('aria-label', 'Edit'); | ||
| }); | ||
|
|
||
| it('should render with default empty tooltip', async () => { | ||
| const {button} = await renderComponent(); | ||
| await expect.element(button).toHaveAttribute('title', ''); | ||
| }); | ||
| }); |
45 changes: 45 additions & 0 deletions
45
...es/atomic/src/components/insight/atomic-insight-edit-toggle/atomic-insight-edit-toggle.ts
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,45 @@ | ||
| import {html, LitElement} from 'lit'; | ||
| import {customElement, property} from 'lit/decorators.js'; | ||
| import {renderIconButton} from '@/src/components/common/icon-button'; | ||
| import {withTailwindStyles} from '@/src/decorators/with-tailwind-styles'; | ||
| import EditIcon from '../../../images/edit.svg'; | ||
|
|
||
| /** | ||
| * The `atomic-insight-edit-toggle` component provides an edit button for insight interfaces. | ||
| * | ||
| * @part insight-edit-toggle-container - The container element wrapping the edit toggle icon button. | ||
| * @part insight-edit-toggle-button - The edit button element. | ||
| * @part insight-edit-toggle-icon - The edit icon element displayed inside the button. | ||
| */ | ||
| @customElement('atomic-insight-edit-toggle') | ||
| @withTailwindStyles | ||
| export class AtomicInsightEditToggle extends LitElement { | ||
| /** | ||
| * The callback function to be executed when the button is clicked. | ||
| */ | ||
| @property({type: Function}) public clickCallback: () => void = () => {}; | ||
|
|
||
| /** | ||
| * The tooltip text to display on hover. | ||
| */ | ||
| @property({type: String}) public tooltip = ''; | ||
|
|
||
| protected render() { | ||
| return html`${renderIconButton({ | ||
| props: { | ||
| partPrefix: 'insight-edit-toggle', | ||
| style: 'outline-neutral', | ||
| icon: EditIcon, | ||
| ariaLabel: 'Edit', | ||
| onClick: this.clickCallback, | ||
| title: this.tooltip, | ||
| }, | ||
| })}`; | ||
| } | ||
| } | ||
|
|
||
| declare global { | ||
| interface HTMLElementTagNameMap { | ||
| 'atomic-insight-edit-toggle': AtomicInsightEditToggle; | ||
| } | ||
| } | ||
30 changes: 0 additions & 30 deletions
30
...s/atomic/src/components/insight/atomic-insight-edit-toggle/atomic-insight-edit-toggle.tsx
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
...c/src/components/insight/atomic-insight-edit-toggle/e2e/atomic-insight-edit-toggle.e2e.ts
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,11 @@ | ||
| import {expect, test} from './fixture'; | ||
|
|
||
| test.describe('edit toggle', () => { | ||
| test.beforeEach(async ({editToggle}) => { | ||
| await editToggle.load(); | ||
| }); | ||
|
|
||
| test('should display the edit toggle button', async ({editToggle}) => { | ||
| await expect(editToggle.editButton).toBeVisible(); | ||
| }); | ||
| }); |
14 changes: 14 additions & 0 deletions
14
packages/atomic/src/components/insight/atomic-insight-edit-toggle/e2e/fixture.ts
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,14 @@ | ||
| import {test as base} from '@playwright/test'; | ||
| import {EditTogglePageObject} from './page-object'; | ||
|
|
||
| type AtomicInsightEditToggleE2EFixtures = { | ||
| editToggle: EditTogglePageObject; | ||
| }; | ||
|
|
||
| export const test = base.extend<AtomicInsightEditToggleE2EFixtures>({ | ||
| editToggle: async ({page}, use) => { | ||
| await use(new EditTogglePageObject(page)); | ||
| }, | ||
| }); | ||
|
|
||
| export {expect} from '@playwright/test'; |
12 changes: 12 additions & 0 deletions
12
packages/atomic/src/components/insight/atomic-insight-edit-toggle/e2e/page-object.ts
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,12 @@ | ||
| import type {Page} from '@playwright/test'; | ||
| import {BasePageObject} from '@/playwright-utils/lit-base-page-object'; | ||
|
|
||
| export class EditTogglePageObject extends BasePageObject { | ||
| constructor(page: Page) { | ||
| super(page, 'atomic-insight-edit-toggle'); | ||
| } | ||
|
|
||
| get editButton() { | ||
| return this.page.getByRole('button', {name: 'Edit'}); | ||
| } | ||
| } |
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
Oops, something went wrong.
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.