-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(examples): refactor system to run on docsite
- Loading branch information
1 parent
284e046
commit 03fa145
Showing
11 changed files
with
83 additions
and
190 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 |
---|---|---|
@@ -1,7 +1,8 @@ | ||
export function focus(elem) { | ||
// export function focus(elem) { | ||
const focusExample = document.querySelector('#focusExample'); | ||
const focusExampleBtnElem = document.querySelector('#focusExampleBtn'); | ||
|
||
focusExampleBtnElem.addEventListener('click', () => { | ||
elem.focus(); | ||
}) | ||
} | ||
focusExample.focus(); | ||
}); | ||
// } |
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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
export function persistentEventOption(elem) { | ||
elem.addEventListener('addNewAddress', () => { | ||
console.warn('addNewAddress event fired'); | ||
alert(`addNewAddress event fired`); | ||
}); | ||
} | ||
const persistentExample = document.querySelector('#persistent'); | ||
|
||
console.log(persistentExample); | ||
|
||
persistentExample.addEventListener('addNewAddress', () => { | ||
console.warn('addNewAddress event fired'); | ||
alert(`addNewAddress event fired`); | ||
}); |
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 |
---|---|---|
@@ -1,13 +1,15 @@ | ||
export function swapComboboxValues(selectors) { | ||
const btn = document.querySelector(selectors[0]); | ||
const comboboxOne = document.querySelector(selectors[1]); | ||
const comboboxTwo = document.querySelector(selectors[2]); | ||
const btn = document.querySelector('#swapExampleBtn'); | ||
const comboboxOne = document.querySelector('#swapExampleLeft'); | ||
const comboboxTwo = document.querySelector('#swapExampleRight'); | ||
|
||
btn.addEventListener('click', () => { | ||
const valueOne = comboboxOne.value; | ||
const valueTwo = comboboxTwo.value; | ||
console.log("hello"); | ||
console.log(btn); | ||
|
||
comboboxOne.value = valueTwo; | ||
comboboxTwo.value = valueOne; | ||
}); | ||
} | ||
btn.addEventListener('click', () => { | ||
console.log("btn clicked"); | ||
const valueOne = comboboxOne.value; | ||
const valueTwo = comboboxTwo.value; | ||
|
||
comboboxOne.value = valueTwo; | ||
comboboxTwo.value = valueOne; | ||
}); |
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 |
---|---|---|
@@ -1,14 +1,13 @@ | ||
export function initValueExamples(elem) { | ||
document.querySelector('#valueValidExampleBtn').addEventListener('click', () => { | ||
elem.value = 'Oranges'; | ||
}) | ||
const valueExample = document.querySelector('#valueExample'); | ||
|
||
document.querySelector('#valueInvalidExampleBtn').addEventListener('click', () => { | ||
console.warn('dragon fruit', elem); | ||
elem.value = 'Dragon Fruit'; | ||
}) | ||
document.querySelector('#valueValidExampleBtn').addEventListener('click', () => { | ||
valueExample.value = 'Oranges'; | ||
}); | ||
|
||
document.querySelector('#valueUndefinedExampleBtn').addEventListener('click', () => { | ||
elem.value = undefined; | ||
}) | ||
} | ||
document.querySelector('#valueInvalidExampleBtn').addEventListener('click', () => { | ||
valueExample.value = 'Dragon Fruit'; | ||
}); | ||
|
||
document.querySelector('#valueUndefinedExampleBtn').addEventListener('click', () => { | ||
valueExample.value = undefined; | ||
}); |
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 |
---|---|---|
@@ -1,55 +1,3 @@ | ||
import { populateCombobox } from '../apiExamples/dynamicMenu'; | ||
import { initValueExamples } from '../apiExamples/value'; | ||
import { focus } from './../apiExamples/focus'; | ||
|
||
class Examples { | ||
initialize() { | ||
function initializeExample(element, callback, retryCount) { | ||
const elem = document.querySelector(element); | ||
|
||
if (!elem || !elem.ready) { | ||
// If the component is not ready, retry until it is | ||
if (!retryCount && retryCount != 0) { | ||
retryCount = 0; | ||
} else { | ||
retryCount += 1; | ||
} | ||
|
||
if (retryCount < 10) { | ||
setTimeout(initializeExample, 500, element, callback, retryCount); | ||
} else { | ||
console.error('Unable to initialize functional example code for:', element); | ||
} | ||
} else { | ||
callback(elem); | ||
} | ||
} | ||
|
||
/** | ||
* Value examples | ||
*/ | ||
initializeExample('auro-combobox#valueExample', function(elem) { | ||
initValueExamples(elem); | ||
}); | ||
|
||
/** | ||
* Apply focus to trigger using element.focus() | ||
*/ | ||
initializeExample('#focusExample', function(elem) { | ||
focus(elem); | ||
}); | ||
|
||
/** | ||
* Populate combobox via Dynamic API | ||
*/ | ||
initializeExample('#dynamicMenuExample', function(elem) { | ||
const input = elem.shadowRoot.querySelector('auro-dropdown').querySelector('auro-input'); | ||
|
||
input.addEventListener('input', () => { | ||
populateCombobox(elem); | ||
}); | ||
}); | ||
} | ||
} | ||
|
||
export { Examples } | ||
import '../apiExamples/dynamicMenu'; | ||
import '../apiExamples/value'; | ||
import '../apiExamples/focus'; |
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 |
---|---|---|
@@ -1,55 +1,2 @@ | ||
import { persistentEventOption } from '../apiExamples/persistent'; | ||
import { swapComboboxValues } from '../apiExamples/swapValue'; | ||
|
||
class Examples { | ||
initialize() { | ||
function initializeExample(elements, callback, elementsPendingReady, retryCount) { | ||
if (!elementsPendingReady) { | ||
elementsPendingReady = elementsPendingReady || []; | ||
|
||
if (typeof elements === 'string') { | ||
elementsPendingReady.push(elements); | ||
} else { | ||
elementsPendingReady = elements; | ||
} | ||
|
||
initializeExample(elements, callback, elementsPendingReady); | ||
} else { | ||
let readyCount = 0; | ||
|
||
elementsPendingReady.forEach(element => { | ||
if (document.querySelector(element) && document.querySelector(element)['ready']) { | ||
readyCount++; | ||
} | ||
}); | ||
|
||
retryCount = retryCount || 0; | ||
|
||
if (elementsPendingReady.length != readyCount && retryCount < 10) { | ||
retryCount = retryCount + 1; | ||
setTimeout(initializeExample, 500, elements, callback, elementsPendingReady, retryCount); | ||
} else { | ||
callback(elements); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Persistent option with custom event | ||
*/ | ||
initializeExample('#persistent', function(selector) { | ||
persistentEventOption(document.querySelector(selector)); | ||
}); | ||
|
||
/** | ||
* swap values example | ||
*/ | ||
(function(){ | ||
initializeExample(['#swapExampleBtn', '#swapExampleLeft', '#swapExampleRight'], function(selectors) { | ||
swapComboboxValues(selectors); | ||
}); | ||
}()); | ||
} | ||
} | ||
|
||
export { Examples } | ||
import '../apiExamples/persistent'; | ||
import '../apiExamples/swapValue'; |
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