Skip to content

Commit f9f5d26

Browse files
committed
Port back changes and utils
1 parent 1c9515d commit f9f5d26

30 files changed

+1053
-64
lines changed

src/shared/components/callbacks/disabled.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ registerDocumentSetup((document) => {
1414

1515
/** Listener that selectively disables event propagation if aria-disabled */
1616
function preventDefaultIfAriaDisabled(event: Event) {
17-
const target = event.target as HTMLElement;
18-
if (!target) return;
17+
const target = event.target;
18+
if (!target || !(target instanceof HTMLElement)) return;
1919

2020
const closestAriaDisabled = target.closest('[aria-disabled]');
2121
if (closestAriaDisabled && closestAriaDisabled?.getAttribute('aria-disabled') !== 'false') {

src/shared/components/callbacks/top-nav.ts

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { createMounter } from '~/shared/utility/callback-attrs/mount';
2-
import { getScrollableParent } from '~/shared/utility/get-scrollable-parent';
2+
import {
3+
getScrollableParent,
4+
getScrollListenerParent,
5+
} from '~/shared/utility/get-scrollable-parent';
36
import { createMagicProp } from '~/shared/utility/magic-prop';
47
import { elmWin } from '~/shared/utility/multi-view';
58
import { onUnmount } from '~/shared/utility/unmount-observer';
@@ -25,28 +28,9 @@ const TOP_NAV_SCROLL_THRESHOLD = 500;
2528
* Attach scroll handler to scrollable parent of top nav layout
2629
*/
2730
export const topNavScroll = createMounter('modal__open-scroll-state', (elm) => {
28-
let parent = getScrollableParent(elm) as {
29-
addEventListener: (
30-
type: string,
31-
listener: EventListener,
32-
options?: boolean | AddEventListenerOptions,
33-
) => void;
34-
removeEventListener: (
35-
type: string,
36-
listener: EventListener,
37-
options?: boolean | AddEventListenerOptions,
38-
) => void;
39-
ownerDocument: Document | null;
40-
};
31+
const parent = getScrollListenerParent(elm);
4132
if (!parent) return;
4233

43-
if (
44-
parent === parent.ownerDocument?.scrollingElement ||
45-
parent === parent.ownerDocument?.documentElement
46-
) {
47-
parent = parent.ownerDocument;
48-
}
49-
5034
const onScroll = (event: Event) => handleScroll(elm, event);
5135
parent.addEventListener('scroll', onScroll, { passive: true });
5236
onUnmount(elm, () => {

src/shared/components/card.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@
1515
&.o-grid {
1616
container-type: normal;
1717
}
18+
19+
@mixin v-breakpoint-tablet {
20+
.o-container & {
21+
box-shadow: none;
22+
}
23+
24+
:modal &,
25+
:popover-open & {
26+
box-shadow: var(--v-shadow-md);
27+
}
28+
}
1829
}
1930

2031
.c-card__header {

src/shared/components/card.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { SpinnerSuspense } from '~/shared/components/spinner';
77

88
export type CardProps = JSX.IntrinsicAttributes &
99
Omit<JSX.HTMLAttributes<HTMLDivElement>, 'onError'> & {
10-
as?: 'article' | 'div' | 'section';
10+
as?: 'article' | 'div' | 'section' | undefined;
1111
/** Error boundary render callback */
1212
onError?: ((err: Error & { code: string }, eventId: string) => void) | undefined;
1313
/** Error boundary reload callback */

src/shared/components/details.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { type JSX, splitProps } from 'solid-js';
33

44
export interface DetailsProps
55
extends Omit<JSX.DetailsHtmlAttributes<HTMLDetailsElement>, 'children'> {
6+
/** Summary props */
7+
summary?: JSX.HTMLAttributes<HTMLElement>;
68
/** Two children in render funcs -- one for summary and one for details */
79
children: [() => JSX.Element, () => JSX.Element];
810
}
@@ -24,10 +26,12 @@ export interface DetailsProps
2426
* ```
2527
*/
2628
export function Details(props: DetailsProps) {
27-
const [local, rest] = splitProps(props, ['class', 'children']);
29+
const [local, rest] = splitProps(props, ['class', 'summary', 'children']);
2830
return (
2931
<details {...rest} class={cx('c-details', local.class)}>
30-
<summary class="c-details__summary">{local.children[0]()}</summary>
32+
<summary {...local.summary} class={cx('c-details__summary', local.summary?.class)}>
33+
{local.children[0]()}
34+
</summary>
3135
<div class="c-details__content">{local.children[1]()}</div>
3236
</details>
3337
);

src/shared/components/labelled-action.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
.c-labelled-action {
55
display: flex;
66
align-items: center;
7-
gap: var(--v-inline-gap);
7+
gap: var(--v-spacing);
88
}
99

1010
.c-labelled-action__label {

src/shared/components/labelled-action.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export function LabelledAction(props: LabelledInputProps) {
112112
*/
113113
export function LabelledActionCard(props: LabelledInputProps) {
114114
return (
115-
<Card>
115+
<Card as="div">
116116
<CardContent>
117117
<LabelledAction {...props} />
118118
</CardContent>

src/shared/components/modal.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,17 @@ export function Modal(props: DialogProps) {
115115
const [dialog, setDialog] = createSignal<HTMLDialogElement | null>(null);
116116
const [local, rest] = splitProps(props, ['children', 'id', 'open', 'onError', 'onReload']);
117117

118-
// Open state
119-
const [open, setOpen] = createSignal<boolean | undefined>();
118+
// Mounting state
119+
const [mounted, setMounted] = createSignal<boolean | undefined>();
120120
createRenderEffect(() => {
121121
if (local.open !== false) {
122-
setOpen(true);
122+
setMounted(true);
123123
return;
124124
}
125125

126126
// Defer updating closed state for a set amount of time to allow for transitions
127127
// This can be long since there are other things
128-
const timeout = setTimeout(() => setOpen(false), MODAL_CLOSE_SYNC_DELAY);
128+
const timeout = setTimeout(() => setMounted(false), MODAL_CLOSE_SYNC_DELAY);
129129
onCleanup(() => clearTimeout(timeout));
130130
});
131131

@@ -135,7 +135,7 @@ export function Modal(props: DialogProps) {
135135
// Handle open state changes after mount
136136
createEffect(() => {
137137
const dialogElm = dialog();
138-
if (!dialogElm) return;
138+
if (!dialogElm || !mounted()) return;
139139
if (local.open) {
140140
openModal(dialogElm);
141141
} else if (local.open === false && dialogElm.open) {
@@ -154,7 +154,7 @@ export function Modal(props: DialogProps) {
154154
return (
155155
// local.open being undefined implies we should show and rely on the dialog's
156156
// own open state to control visibility
157-
<Show when={open()}>
157+
<Show when={mounted()}>
158158
<ModalContext.Provider value={id}>
159159
<dialog
160160
{...rest}

src/shared/components/select-option-list.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,17 +109,17 @@ export function SelectOptionList(props: SelectOptionListProps) {
109109
</ListBox>
110110
{props.selectInputTextId ? (
111111
<div role="status" class="c-select__status">
112-
<span class="c-select__no_match">
112+
<span class="c-select__no-match">
113113
<T>
114114
No matches found for{' '}
115115
<strong
116116
id={local.selectInputTextId}
117-
class="c-select__no_match_value"
117+
class="c-select__no-match-value"
118118
{...emptyAttr()}
119119
/>
120120
</T>
121121
</span>
122-
<span class="c-select__no_value">
122+
<span class="c-select__no-value">
123123
<T>Type something</T>
124124
</span>
125125
<div class="c-select__busy">

src/shared/components/select.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@
111111
display: block;
112112
}
113113

114-
.c-select__no_match,
115-
.c-select__no_value,
114+
.c-select__no-match,
115+
.c-select__no-value,
116116
.c-select__busy {
117117
display: none;
118118
}
@@ -126,11 +126,11 @@
126126

127127
/* Different empty states depending on whether there's input */
128128
:has(.c-select__items[data-t-empty]):not([aria-busy='true']) + & {
129-
.c-select__no_match:not(:has(.c-select__no_match_value[data-t-empty])) {
129+
.c-select__no-match:not(:has(.c-select__no-match-value[data-t-empty])) {
130130
display: block;
131131
}
132132

133-
.c-select__no_match:has(.c-select__no_match_value[data-t-empty]) + .c-select__no_value {
133+
.c-select__no-match:has(.c-select__no-match-value[data-t-empty]) + .c-select__no-value {
134134
display: block;
135135
}
136136
}

0 commit comments

Comments
 (0)