-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(modal): border radius is now correctly applied to card modals (#2…
- Loading branch information
1 parent
009dff5
commit 1f4f8eb
Showing
4 changed files
with
125 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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 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,10 @@ | ||
import { testModal } from '../test.utils'; | ||
|
||
const DIRECTORY = 'card'; | ||
|
||
test('modal: card', async () => { | ||
await testModal(DIRECTORY, '#card', true); | ||
}); | ||
test('modal: card - custom', async () => { | ||
await testModal(DIRECTORY, '#card-custom', true); | ||
}); |
This file contains 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,94 @@ | ||
<!DOCTYPE html> | ||
<html lang="en" dir="ltr"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Modal - Card</title> | ||
<meta name="apple-mobile-web-app-capable" content="yes"> | ||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"> | ||
<meta name="viewport" content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"> | ||
<link href="../../../../../css/ionic.bundle.css" rel="stylesheet"> | ||
<link href="../../../../../scripts/testing/styles.css" rel="stylesheet"> | ||
<script src="../../../../../scripts/testing/scripts.js"></script> | ||
<script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script> | ||
<script type="module"> | ||
import { modalController } from '../../../../dist/ionic/index.esm.js'; | ||
window.modalController = modalController; | ||
</script> | ||
<style> | ||
ion-modal#custom { | ||
--border-radius: 50px !important; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<ion-app> | ||
|
||
<div class="ion-page"> | ||
<ion-header> | ||
<ion-toolbar> | ||
<ion-title>Card</ion-title> | ||
</ion-toolbar> | ||
</ion-header> | ||
|
||
<ion-content class="ion-padding"> | ||
<ion-button expand="block" id="card" onclick="presentModal(document.querySelectorAll('.ion-page')[1])">Card Modal</ion-button> | ||
<ion-button expand="block" id="card-custom" onclick="presentModal(document.querySelectorAll('.ion-page')[1], { id: 'custom' })">Card Modal Custom Radius</ion-button> | ||
</ion-content> | ||
</div> | ||
</ion-app> | ||
|
||
<script> | ||
async function createModal(presentingEl, opts) { | ||
|
||
// create component to open | ||
const element = document.createElement('div'); | ||
element.innerHTML = ` | ||
<ion-header id="modal-header"> | ||
<ion-toolbar> | ||
<ion-title>Contacts</ion-title> | ||
<ion-buttons slot="end"> | ||
<ion-button class="add"> | ||
<ion-icon name="add" slot="icon-only"></ion-icon> | ||
</ion-button> | ||
</ion-buttons> | ||
</ion-toolbar> | ||
</ion-header> | ||
<ion-content class="ion-padding"> | ||
Hello World! | ||
<ion-button class="dismiss">Dismiss Modal</ion-button> | ||
</ion-content> | ||
`; | ||
|
||
// listen for close event | ||
const button = element.querySelector('ion-button.dismiss'); | ||
button.addEventListener('click', () => { | ||
modalController.dismiss(); | ||
}); | ||
|
||
const create = element.querySelector('ion-button.add'); | ||
create.addEventListener('click', async () => { | ||
const topModal = await modalController.getTop(); | ||
|
||
presentModal(topModal, opts); | ||
}); | ||
|
||
// present the modal | ||
const modalElement = await modalController.create({ | ||
presentingElement: presentingEl, | ||
component: element, | ||
swipeToClose: true, | ||
...opts | ||
}); | ||
return modalElement; | ||
} | ||
|
||
async function presentModal(presentingEl, opts) { | ||
const modal = await createModal(presentingEl, opts); | ||
await modal.present(); | ||
} | ||
</script> | ||
</body> | ||
|
||
</html> |
This file contains 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