-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
1,517 additions
and
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<ids-modal id="my-modal"> | ||
<ids-layout-grid> | ||
<ids-text font-size="24" type="h2">Active IDS Modal</ids-text> | ||
</ids-layout-grid> | ||
<ids-layout-grid> | ||
<p>This is an active IDS Modal component</p> | ||
</ids-layout-grid> | ||
<ids-layout-grid auto="true"> | ||
<ids-layout-grid-cell> | ||
<ids-button id="modal-close-btn" type="secondary"> | ||
<span slot="text">OK</span> | ||
</ids-button> | ||
</ids-layout-grid-cell> | ||
</ids-layout-grid> | ||
</ids-modal> | ||
|
||
<ids-layout-grid> | ||
<ids-text font-size="12" type="h1">Modal</ids-text> | ||
</ids-layout-grid> | ||
<ids-layout-grid auto="true"> | ||
<ids-layout-grid-cell> | ||
<ids-button id="modal-trigger-btn" type="secondary"> | ||
<span slot="text">Trigger a Modal</span> | ||
</ids-button> | ||
</ids-layout-grid-cell> | ||
</ids-layout-grid> |
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,28 @@ | ||
// Supporting Components | ||
import IdsButton from '../../src/ids-button/ids-button'; | ||
|
||
document.addEventListener('DOMContentLoaded', () => { | ||
const triggerId = '#modal-trigger-btn'; | ||
const triggerBtn = document.querySelector(triggerId); | ||
const modal = document.querySelector('ids-modal'); | ||
const modalCloseBtn = modal.querySelector('ids-button'); | ||
|
||
// Links the Modal to its trigger button (sets up click/focus events) | ||
modal.target = triggerBtn; | ||
|
||
// Disable the trigger button when showing the Modal. | ||
modal.addEventListener('beforeshow', () => { | ||
triggerBtn.disabled = true; | ||
return true; | ||
}); | ||
|
||
// Close the modal when its inner button is clicked. | ||
modalCloseBtn.addEventListener('click', () => { | ||
modal.hide(); | ||
}); | ||
|
||
// After the modal is done hiding, re-enable its trigger button. | ||
modal.addEventListener('hide', () => { | ||
triggerBtn.disabled = false; | ||
}); | ||
}); |
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,3 @@ | ||
{{> ../layouts/head.html }} | ||
{{> example.html }} | ||
{{> ../layouts/footer.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import IdsModal from '../../src/ids-modal/ids-modal'; |
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,50 @@ | ||
{{> ../layouts/head.html }} | ||
|
||
<ids-modal id="parent-modal"> | ||
<ids-layout-grid> | ||
<ids-text font-size="24" type="h2">Parent Modal</ids-text> | ||
</ids-layout-grid> | ||
<ids-layout-grid> | ||
<p>This is the Parent IDS Modal</p> | ||
</ids-layout-grid> | ||
<ids-layout-grid auto="true"> | ||
<ids-layout-grid-cell> | ||
<ids-button id="parent-modal-close-btn" type="secondary"> | ||
<span slot="text">Close</span> | ||
</ids-button> | ||
<ids-button id="nested-modal-trigger-btn" type="primary"> | ||
<span slot="text">Open Another</span> | ||
</ids-button> | ||
</ids-layout-grid-cell> | ||
</ids-layout-grid> | ||
</ids-modal> | ||
|
||
<ids-modal id="nested-modal"> | ||
<ids-layout-grid> | ||
<ids-text font-size="24" type="h2">Nested Modal</ids-text> | ||
</ids-layout-grid> | ||
<ids-layout-grid> | ||
<p>This is the Nested IDS Modal</p> | ||
</ids-layout-grid> | ||
<ids-layout-grid auto="true"> | ||
<ids-layout-grid-cell> | ||
<ids-button id="nested-modal-close-btn" type="secondary"> | ||
<span slot="text">Close</span> | ||
</ids-button> | ||
</ids-layout-grid-cell> | ||
</ids-layout-grid> | ||
</ids-modal> | ||
|
||
<ids-layout-grid> | ||
<ids-text font-size="12" type="h1">Modal</ids-text> | ||
</ids-layout-grid> | ||
<ids-layout-grid auto="true"> | ||
<ids-layout-grid-cell> | ||
<ids-button id="parent-modal-trigger-btn" type="secondary"> | ||
<span slot="text">Trigger a Modal</span> | ||
</ids-button> | ||
</ids-layout-grid-cell> | ||
</ids-layout-grid> | ||
|
||
|
||
{{> ../layouts/footer.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import IdsModal from '../../src/ids-modal/ids-modal'; | ||
import IdsButton from '../../src/ids-button/ids-button'; | ||
|
||
document.addEventListener('DOMContentLoaded', () => { | ||
const parentTriggerId = '#parent-modal-trigger-btn'; | ||
const parentTriggerBtn = document.querySelector(parentTriggerId); | ||
const parentModal = document.querySelector('#parent-modal'); | ||
const parentModalCloseBtn = parentModal.querySelector('ids-button'); | ||
|
||
const nestedTriggerId = '#nested-modal-trigger-btn'; | ||
const nestedTriggerBtn = document.querySelector(nestedTriggerId); | ||
const nestedModal = document.querySelector('#nested-modal'); | ||
const nestedModalCloseBtn = nestedModal.querySelector('ids-button'); | ||
|
||
// Links the Modals to their trigger buttons | ||
parentModal.target = parentTriggerBtn; | ||
nestedModal.target = nestedTriggerBtn; | ||
|
||
// Disable the trigger buttons when showing their Modals. | ||
parentModal.addEventListener('beforeshow', () => { | ||
parentTriggerBtn.disabled = true; | ||
return true; | ||
}); | ||
nestedModal.addEventListener('beforeshow', () => { | ||
nestedTriggerBtn.disabled = true; | ||
return true; | ||
}); | ||
|
||
// Close the modals when their "close" buttons are clicked | ||
parentModalCloseBtn.addEventListener('click', () => { | ||
parentModal.hide(); | ||
}); | ||
nestedModalCloseBtn.addEventListener('click', () => { | ||
nestedModal.hide(); | ||
}); | ||
|
||
// When the modals are fully hidden, re-enable their trigger buttons | ||
parentModal.addEventListener('hide', () => { | ||
parentTriggerBtn.disabled = false; | ||
}); | ||
nestedModal.addEventListener('hide', () => { | ||
nestedTriggerBtn.disabled = false; | ||
}); | ||
}); |
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,33 @@ | ||
{{> ../layouts/head.html }} | ||
|
||
<ids-modal id="my-modal" visible="true"> | ||
<ids-layout-grid> | ||
<ids-text font-size="24" type="h2">Active IDS Modal</ids-text> | ||
</ids-layout-grid> | ||
<ids-layout-grid> | ||
<p>This is an active IDS Modal component</p> | ||
</ids-layout-grid> | ||
<ids-layout-grid auto="true"> | ||
<ids-layout-grid-cell> | ||
<ids-button id="modal-close-btn" type="secondary"> | ||
<span slot="text">OK</span> | ||
</ids-button> | ||
</ids-layout-grid-cell> | ||
</ids-layout-grid> | ||
</ids-modal> | ||
|
||
<ids-layout-grid> | ||
<ids-text font-size="12" type="h1">Modal (visibility example)</ids-text> | ||
</ids-layout-grid> | ||
<ids-layout-grid> | ||
<ids-text>This Modal example will be visible when the page loads</ids-text> | ||
</ids-layout-grid> | ||
<ids-layout-grid auto="true"> | ||
<ids-layout-grid-cell> | ||
<ids-button id="modal-trigger-btn" type="secondary"> | ||
<span slot="text">Trigger a Modal</span> | ||
</ids-button> | ||
</ids-layout-grid-cell> | ||
</ids-layout-grid> | ||
|
||
{{> ../layouts/footer.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import IdsModal from '../../src/ids-modal/ids-modal'; | ||
import IdsButton from '../../src/ids-button/ids-button'; | ||
|
||
document.addEventListener('DOMContentLoaded', () => { | ||
const triggerId = '#modal-trigger-btn'; | ||
const triggerBtn = document.querySelector(triggerId); | ||
const modal = document.querySelector('ids-modal'); | ||
const modalCloseBtn = modal.querySelector('ids-button'); | ||
|
||
// Links the Modal to its trigger button | ||
modal.target = triggerBtn; | ||
|
||
// Disable the trigger button when showing the Modal. | ||
modal.addEventListener('beforeshow', () => { | ||
triggerBtn.disabled = true; | ||
return true; | ||
}); | ||
|
||
// Close the modal when its inner button is clicked | ||
modalCloseBtn.addEventListener('click', () => { | ||
modal.hide(); | ||
}); | ||
|
||
// After the modal is done hiding, re-enable its trigger button. | ||
modal.addEventListener('hide', () => { | ||
triggerBtn.disabled = false; | ||
}); | ||
}); |
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
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
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,4 @@ | ||
/** prevents a function that runs on intervals from running too frequently */ | ||
declare function debounce(func: CallableFunction, duration?: number, execAsap?: boolean): void; | ||
|
||
export default debounce; |
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,44 @@ | ||
import renderLoop from '../ids-render-loop/ids-render-loop-global'; | ||
import IdsRenderLoopItem from '../ids-render-loop/ids-render-loop-item'; | ||
|
||
/** | ||
* Debounces a function, preventing running the function too frequently while looping. | ||
* This is ideal for functions that run on intervals. | ||
* @param {Function} func the callback function to be run on a stagger. | ||
* @param {number} [duration] the amount of time in CPU ticks to delay. | ||
* @param {boolean} [execAsap] if true, executes the callback immediately | ||
* instead of waiting for the threshold to complete. | ||
* @returns {void} | ||
*/ | ||
/* istanbul ignore next */ | ||
export default function debounce(func, duration = 60, execAsap) { | ||
let timeout; | ||
|
||
// Clears the render loop item | ||
const destroyTimeout = () => { | ||
timeout.destroy(true); | ||
timeout = null; | ||
}; | ||
|
||
return function debounced(...args) { | ||
const obj = this; | ||
const timeoutCallback = () => { | ||
if (!execAsap) { | ||
func.apply(obj, args); | ||
} | ||
destroyTimeout(); | ||
}; | ||
|
||
if (timeout) { | ||
destroyTimeout(); | ||
} else if (execAsap) { | ||
func.apply(obj, args); | ||
} | ||
|
||
timeout = new IdsRenderLoopItem({ | ||
duration, | ||
timeoutCallback | ||
}); | ||
renderLoop.register(timeout); | ||
}; | ||
} |
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
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
Oops, something went wrong.