From 57be102a2c8ec2c7945c8e7cabafcdc364cb81ab Mon Sep 17 00:00:00 2001 From: ZIA-Hans <1025013204@qq.com> Date: Wed, 27 Mar 2024 14:46:59 +0800 Subject: [PATCH 1/2] feat(modal): let modal can custom close icon --- .changeset/shy-beers-clean.md | 6 ++++ docs/example/Modal/demos/basicUsage.tsx | 2 +- packages/banana/src/modal/index.test.ts | 14 +++++++++ packages/banana/src/modal/index.ts | 38 +++++++++++++------------ 4 files changed, 41 insertions(+), 19 deletions(-) create mode 100644 .changeset/shy-beers-clean.md diff --git a/.changeset/shy-beers-clean.md b/.changeset/shy-beers-clean.md new file mode 100644 index 00000000..8a6e7727 --- /dev/null +++ b/.changeset/shy-beers-clean.md @@ -0,0 +1,6 @@ +--- +'@banana-ui/banana': patch +'@banana-ui/react': patch +--- + +let modal can custom close icon diff --git a/docs/example/Modal/demos/basicUsage.tsx b/docs/example/Modal/demos/basicUsage.tsx index e5b8680d..85f471d1 100644 --- a/docs/example/Modal/demos/basicUsage.tsx +++ b/docs/example/Modal/demos/basicUsage.tsx @@ -3,7 +3,7 @@ */ import { Button, Message, Modal } from '@banana-ui/react'; -import React, { useState } from 'react'; +import { useState } from 'react'; export default function BasicUsage() { const [visible, setVisible] = useState(false); diff --git a/packages/banana/src/modal/index.test.ts b/packages/banana/src/modal/index.test.ts index 95e706a5..d13300b7 100644 --- a/packages/banana/src/modal/index.test.ts +++ b/packages/banana/src/modal/index.test.ts @@ -85,6 +85,20 @@ describe('slots', () => { expect(footerSlot.assignedElements().length).to.equal(1); expect(footerSlot.assignedElements()[0].textContent).to.equal('Modal footer'); }); + + it('should render the closeIcon slot', async () => { + const element = await fixture(html` + +

Modal content

+

Modal content

+

CLOSE

+
+ `); + const iconSlot = element.shadowRoot?.querySelector('slot[name="closeIcon"]') as HTMLSlotElement; + + expect(iconSlot.assignedElements().length).to.equal(1); + expect(iconSlot.assignedElements()[0].textContent).to.equal('CLOSE'); + }); }); describe('custom width', () => { diff --git a/packages/banana/src/modal/index.ts b/packages/banana/src/modal/index.ts index c01dbce4..969a8b7f 100644 --- a/packages/banana/src/modal/index.ts +++ b/packages/banana/src/modal/index.ts @@ -74,24 +74,26 @@ export default class BModal extends LitElement {