diff --git a/src/dev/pages/app-bar/app-bar.ejs b/src/dev/pages/app-bar/app-bar.ejs index da46d51e2..5ee4617d0 100644 --- a/src/dev/pages/app-bar/app-bar.ejs +++ b/src/dev/pages/app-bar/app-bar.ejs @@ -15,7 +15,6 @@ +
- Show overlay + Show overlay - -
- Lorem ipsum dolor sit amet consectetur adipisicing elit. Ea labore tenetur illum aliquam corporis veritatis quos accusamus. Laborum ullam autem fugiat eligendi ratione beatae consequuntur provident earum, nemo neque itaque! - Show child overlay - -

Nested overlay test

+ + diff --git a/src/dev/pages/overlay/overlay.html b/src/dev/pages/overlay/overlay.html index 9be8dd647..9b3a71345 100644 --- a/src/dev/pages/overlay/overlay.html +++ b/src/dev/pages/overlay/overlay.html @@ -34,14 +34,34 @@ { label: 'Absolute', value: 'absolute' } ] }, + { + type: 'select', + label: 'Flip', + id: 'opt-flip', + defaultValue: 'auto', + options: [ + { label: 'Auto', value: 'auto' }, + { label: 'Main', value: 'main' }, + { label: 'Cross', value: 'cross' }, + { label: 'Off', value: 'off' }, + ] + }, + { + type: 'select', + label: 'Hide', + id: 'opt-hide', + defaultValue: 'auto', + options: [ + { label: 'Auto', value: 'auto' }, + { label: 'Off', value: 'off' }, + ] + }, { type: 'switch', label: 'Inline', id: 'opt-inline' }, { type: 'switch', label: 'Static', id: 'opt-static' }, - { type: 'switch', label: 'Dialog', id: 'opt-dialog'}, - { type: 'switch', label: 'Modal', id: 'opt-modal'}, - { type: 'switch', label: 'Hide', id: 'opt-hide', defaultValue: true }, { type: 'switch', label: 'Shift', id: 'opt-shift' }, - { type: 'switch', label: 'Flip', id: 'opt-flip', defaultValue: true }, { type: 'switch', label: 'Auto', id: 'opt-auto' }, + { type: 'switch', label: 'Show arrow', id: 'opt-show-arrow' }, + { type: 'switch', label: 'Set boundary', id: 'opt-set-boundary' }, { type: 'switch', label: 'Use small container', id: 'opt-use-small-container' }, { type: 'switch', label: 'Force containment', id: 'opt-force-containment' }, { type: 'switch', label: 'Use offset', id: 'opt-use-offset' }, diff --git a/src/dev/pages/overlay/overlay.scss b/src/dev/pages/overlay/overlay.scss index 55c6e3b72..55a38e5c7 100644 --- a/src/dev/pages/overlay/overlay.scss +++ b/src/dev/pages/overlay/overlay.scss @@ -17,6 +17,7 @@ width: 300px; padding: 8px; border: 1px dashed var(--forge-theme-primary); + background-color: var(--forge-theme-surface); } .scroll-container { @@ -26,3 +27,12 @@ align-items: center; justify-content: center; } + +.arrow { + position: absolute; + background-color: var(--forge-theme-error); + height: 24px; + width: 24px; + rotate: 45deg; + z-index: -1; +} diff --git a/src/dev/pages/overlay/overlay.ts b/src/dev/pages/overlay/overlay.ts index 78d22ae0f..0ecbbe819 100644 --- a/src/dev/pages/overlay/overlay.ts +++ b/src/dev/pages/overlay/overlay.ts @@ -1,5 +1,5 @@ import '$src/shared'; -import { ISelectComponent, ISwitchComponent } from '@tylertech/forge'; +import { ISelectComponent, ISwitchComponent, OverlayFlipState, OverlayHideState } from '@tylertech/forge'; import type { IOverlayComponent } from '@tylertech/forge'; import { toggleClass } from '@tylertech/forge-core'; import '@tylertech/forge/button'; @@ -7,21 +7,28 @@ import '@tylertech/forge/overlay'; import './overlay.scss'; const overlay = document.querySelector('#my-overlay') as IOverlayComponent; -const childOverlay = overlay.querySelector('#my-child-overlay') as IOverlayComponent; +const nestedOverlay = overlay.querySelector('#my-nested-overlay') as IOverlayComponent; const showOverlayButton = document.querySelector('#my-btn') as HTMLButtonElement; -const showChildOverlayButton = document.querySelector('#child-btn') as HTMLButtonElement; +const showNestedOverlayButton = document.querySelector('#nested-btn') as HTMLButtonElement; const clippingContainer = document.querySelector('.clipping-container') as HTMLElement; -overlay.addEventListener('forge-overlay-light-dismiss', ({ detail }: CustomEvent) => { - console.log('forge-overlay-beforetoggle', detail); +overlay.addEventListener('forge-overlay-light-dismiss', (evt: CustomEvent) => { + console.log(evt.type); + showOverlayButton.setAttribute('aria-expanded', 'false'); }); -overlay.addEventListener('forge-overlay-toggle', ({ detail }: CustomEvent) => { - console.log('forge-overlay-toggle', detail); -}); +showOverlayButton.addEventListener('click', () => { + overlay.open = !overlay.open; + + showOverlayButton.setAttribute('aria-expanded', String(overlay.open)); -showOverlayButton.addEventListener('click', () => overlay.open = !overlay.open); -showChildOverlayButton.addEventListener('click', () => childOverlay.open = !childOverlay.open); + const arrowEl = overlay.querySelector('.arrow') as HTMLElement; + if (arrowEl) { + const offset = Math.sqrt(2 * arrowEl.offsetWidth ** 2) / 2; + overlay.arrowElementOffset = offset; + } +}); +showNestedOverlayButton.addEventListener('click', () => nestedOverlay.open = !nestedOverlay.open); centerDemoButton(); const placementSelect = document.getElementById('opt-placement') as ISelectComponent; @@ -30,31 +37,43 @@ placementSelect.addEventListener('change', ({ detail: selected }) => overlay.pla const positionStrategySelect = document.getElementById('opt-position-strategy') as ISelectComponent; positionStrategySelect.addEventListener('change', ({ detail: selected }) => overlay.positionStrategy = selected); +const flipSelect = document.getElementById('opt-flip') as ISelectComponent; +flipSelect.addEventListener('change', ({ detail: selected }) => overlay.flip = selected as OverlayFlipState); + +const hideSelect = document.getElementById('opt-hide') as ISelectComponent; +hideSelect.addEventListener('change', ({ detail: selected }) => overlay.hide = selected as OverlayHideState); + const inlineToggle = document.getElementById('opt-inline') as ISwitchComponent; inlineToggle.addEventListener('forge-switch-change', ({ detail: selected }) => overlay.inline = selected); const staticToggle = document.getElementById('opt-static') as ISwitchComponent; staticToggle.addEventListener('forge-switch-change', ({ detail: selected }) => overlay.static = selected); -const dialogToggle = document.getElementById('opt-dialog') as ISwitchComponent; -dialogToggle.addEventListener('forge-switch-change', ({ detail: selected }) => overlay.dialog = selected); - -const modalToggle = document.getElementById('opt-modal') as ISwitchComponent; -modalToggle.addEventListener('forge-switch-change', ({ detail: selected }) => overlay.modal = selected); - -const hideToggle = document.getElementById('opt-hide') as ISwitchComponent; -hideToggle.addEventListener('forge-switch-change', ({ detail: selected }) => overlay.hide = selected); - const shiftToggle = document.getElementById('opt-shift') as ISwitchComponent; shiftToggle.addEventListener('forge-switch-change', ({ detail: selected }) => overlay.shift = selected); -const flipToggle = document.getElementById('opt-flip') as ISwitchComponent; -flipToggle.addEventListener('forge-switch-change', ({ detail: selected }) => overlay.flip = selected); - const autoToggle = document.getElementById('opt-auto') as ISwitchComponent; autoToggle.addEventListener('forge-switch-change', ({ detail: selected }) => { overlay.auto = selected; - flipToggle.disabled = selected; + flipSelect.disabled = selected; +}); + +const showArrowToggle = document.getElementById('opt-show-arrow') as ISwitchComponent; +showArrowToggle.addEventListener('forge-switch-change', ({ detail: selected }) => { + if (selected) { + const arrowEl = document.createElement('div'); + arrowEl.classList.add('arrow'); + overlay.appendChild(arrowEl); + overlay.arrowElement = arrowEl; + } else { + overlay.querySelector('.arrow')?.remove(); + overlay.arrowElement = null; + } +}); + +const setBoundaryToggle = document.getElementById('opt-set-boundary') as ISwitchComponent; +setBoundaryToggle.addEventListener('forge-switch-change', ({ detail: selected }) => { + overlay.boundaryElement = selected ? clippingContainer : null; }); const useSmallContainerToggle = document.getElementById('opt-use-small-container') as ISwitchComponent; diff --git a/src/dev/pages/popover/popover.ejs b/src/dev/pages/popover/popover.ejs index 539dd6bc6..a88b83636 100644 --- a/src/dev/pages/popover/popover.ejs +++ b/src/dev/pages/popover/popover.ejs @@ -7,7 +7,7 @@