From 74e572f14ac0a1cb8249261e2271758bf789e51b Mon Sep 17 00:00:00 2001 From: Ashley Echols Date: Fri, 10 May 2024 13:12:04 -0500 Subject: [PATCH] refactor(sortable): updates sortable item handle prop name and tests --- libs/core/src/components.d.ts | 4 ++-- .../pds-sortable/docs/pds-sortable.mdx | 20 +++++++++---------- .../pds-sortable-item/pds-sortable-item.tsx | 12 +++++------ .../pds-sortable/pds-sortable-item/readme.md | 2 +- .../stories/pds-sortable-item.stories.js | 4 ++-- .../test/pds-sortable-item.spec.tsx | 10 +++++----- .../stories/pds-sortable.stories.js | 6 +++--- .../pds-sortable/test/pds-sortable.e2e.ts | 4 ++-- 8 files changed, 31 insertions(+), 31 deletions(-) diff --git a/libs/core/src/components.d.ts b/libs/core/src/components.d.ts index 93643e367..1bf93dc9b 100644 --- a/libs/core/src/components.d.ts +++ b/libs/core/src/components.d.ts @@ -590,7 +590,7 @@ export namespace Components { * Determines whether `sortable-item` should have a handle. * @defaultValue false */ - "handle": boolean; + "showHandle": boolean; } interface PdsSwitch { /** @@ -1805,7 +1805,7 @@ declare namespace LocalJSX { * Determines whether `sortable-item` should have a handle. * @defaultValue false */ - "handle"?: boolean; + "showHandle"?: boolean; } interface PdsSwitch { /** diff --git a/libs/core/src/components/pds-sortable/docs/pds-sortable.mdx b/libs/core/src/components/pds-sortable/docs/pds-sortable.mdx index b20d92f51..d9f2c85dc 100644 --- a/libs/core/src/components/pds-sortable/docs/pds-sortable.mdx +++ b/libs/core/src/components/pds-sortable/docs/pds-sortable.mdx @@ -87,25 +87,25 @@ When `dividers` is set to `true`, a border will display between items. ### Handle -When `handle` is set to `true` on a `pds-sortable-item` a handle icon will be displayed within an item. +When `show-handle` is set to `true` on a `pds-sortable-item`, a handle icon will be displayed within an item. - Item 1 - Item 2 - Item 3 + Item 1 + Item 2 + Item 3 `, webComponent: ` - Item 1 - Item 2 - Item 3 + Item 1 + Item 2 + Item 3 `}}> - Item 1 - Item 2 - Item 3 + Item 1 + Item 2 + Item 3 diff --git a/libs/core/src/components/pds-sortable/pds-sortable-item/pds-sortable-item.tsx b/libs/core/src/components/pds-sortable/pds-sortable-item/pds-sortable-item.tsx index b9072890c..4b4b75962 100644 --- a/libs/core/src/components/pds-sortable/pds-sortable-item/pds-sortable-item.tsx +++ b/libs/core/src/components/pds-sortable/pds-sortable-item/pds-sortable-item.tsx @@ -1,6 +1,6 @@ import { Component, Element, Host, h, Prop } from '@stencil/core'; -import { handle } from '@pine-ds/icons/icons'; +import { handle as handleIcon } from '@pine-ds/icons/icons'; /** * @slot sortable-item-actions - Content is placed within the `pds-sortable-item__actions` element as children. This slot is only rendered if `actions` is set to `true`. */ @@ -27,24 +27,24 @@ export class PdsSortableItem { * Determines whether `sortable-item` should have a handle. * @defaultValue false */ - @Prop({ mutable: true }) handle = false; + @Prop({ mutable: true }) showHandle = false; componentWillRender() { // When the parent sortable has a type of 'handle', the sortable items - // will automatically set handle to 'true'. + // will automatically set showHandle to 'true'. this.sortableRef = this.el.closest('pds-sortable') as HTMLPdsSortableElement; if (this.sortableRef && this.sortableRef.handleType === 'handle') { - this.handle = true; + this.showHandle = true; } } render() { return ( - {this.handle && ( + {this.showHandle && (
- +
)} diff --git a/libs/core/src/components/pds-sortable/pds-sortable-item/readme.md b/libs/core/src/components/pds-sortable/pds-sortable-item/readme.md index 09eaebf41..8adc94707 100644 --- a/libs/core/src/components/pds-sortable/pds-sortable-item/readme.md +++ b/libs/core/src/components/pds-sortable/pds-sortable-item/readme.md @@ -11,7 +11,7 @@ | --------------- | ---------------- | ------------------------------------------------------------------ | --------- | ----------- | | `componentId` | `component-id` | A unique identifier used for the sortable item `id` attribute. | `string` | `undefined` | | `enableActions` | `enable-actions` | Determines whether `sortable-item-actions` slot should be enabled. | `boolean` | `false` | -| `handle` | `handle` | Determines whether `sortable-item` should have a handle. | `boolean` | `false` | +| `showHandle` | `show-handle` | Determines whether `sortable-item` should have a handle. | `boolean` | `false` | ## Slots diff --git a/libs/core/src/components/pds-sortable/pds-sortable-item/stories/pds-sortable-item.stories.js b/libs/core/src/components/pds-sortable/pds-sortable-item/stories/pds-sortable-item.stories.js index 14fbeca3d..f17c352b8 100644 --- a/libs/core/src/components/pds-sortable/pds-sortable-item/stories/pds-sortable-item.stories.js +++ b/libs/core/src/components/pds-sortable/pds-sortable-item/stories/pds-sortable-item.stories.js @@ -11,7 +11,7 @@ const BaseTemplate = (args) => html` Item `; @@ -20,5 +20,5 @@ export const Default = BaseTemplate.bind(); Default.args = { componentId: 'default', enableActions: false, - handle: false, + showHandle: false, }; diff --git a/libs/core/src/components/pds-sortable/pds-sortable-item/test/pds-sortable-item.spec.tsx b/libs/core/src/components/pds-sortable/pds-sortable-item/test/pds-sortable-item.spec.tsx index 72cc9b440..d9e7334e1 100644 --- a/libs/core/src/components/pds-sortable/pds-sortable-item/test/pds-sortable-item.spec.tsx +++ b/libs/core/src/components/pds-sortable/pds-sortable-item/test/pds-sortable-item.spec.tsx @@ -1,7 +1,7 @@ import { newSpecPage } from '@stencil/core/testing'; import { PdsSortableItem } from '../pds-sortable-item'; -import { handle } from '@pine-ds/icons/icons'; +import { handle as handleIcon } from '@pine-ds/icons/icons'; describe('pds-sortable-item', () => { it('renders', async () => { @@ -27,19 +27,19 @@ describe('pds-sortable-item', () => { `); }); - it('renders with handle when prop is set', async () => { + it('renders with handle icon when prop is set', async () => { const page = await newSpecPage({ components: [PdsSortableItem], html: ` - + `, }); expect(page.root).toEqualHtml(` - +
- +
`); diff --git a/libs/core/src/components/pds-sortable/stories/pds-sortable.stories.js b/libs/core/src/components/pds-sortable/stories/pds-sortable.stories.js index e27121ec9..6ebba2fc6 100644 --- a/libs/core/src/components/pds-sortable/stories/pds-sortable.stories.js +++ b/libs/core/src/components/pds-sortable/stories/pds-sortable.stories.js @@ -52,7 +52,7 @@ const ActionsTemplate = (args) => html` const FullDemoTemplate = (args) => html` - +
Item 1
Item 1 description copy text
@@ -61,7 +61,7 @@ const FullDemoTemplate = (args) => html` action
- +
Item 2
Item 2 description copy text
@@ -70,7 +70,7 @@ const FullDemoTemplate = (args) => html` action
- +
Item 3
Item 3 description copy text
diff --git a/libs/core/src/components/pds-sortable/test/pds-sortable.e2e.ts b/libs/core/src/components/pds-sortable/test/pds-sortable.e2e.ts index faae5b85f..c70986d17 100644 --- a/libs/core/src/components/pds-sortable/test/pds-sortable.e2e.ts +++ b/libs/core/src/components/pds-sortable/test/pds-sortable.e2e.ts @@ -9,7 +9,7 @@ describe('pds-sortable', () => { expect(element).toHaveClass('hydrated'); }); - it('sets sortable item handle prop to true when handleType is set to "handle"', async () => { + it('sets sortable item show-handle prop to true when handleType is set to "handle"', async () => { const page = await newE2EPage(); await page.setContent(` @@ -20,7 +20,7 @@ describe('pds-sortable', () => { `); const item = await page.find('.pds-sortable-item'); - expect(await item.getProperty('handle')).toBe(true); + expect(await item.getProperty('showHandle')).toBe(true); }) it('reorders items when an item is dragged and dropped', async () => {