Skip to content

Commit c596e24

Browse files
feat(popover): Signing cla
1 parent a13cdf0 commit c596e24

File tree

4 files changed

+50
-32
lines changed

4 files changed

+50
-32
lines changed

apps/website/src/routes/docs/headless/(components)/popover/examples.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Slot, component$ } from '@builder.io/qwik';
22
import { Popover, PopoverContent, PopoverTrigger } from '@qwik-ui/headless';
3-
import { GitHubIcon } from 'apps/website/src/components/icons/GitHubIcon';
43
import { PreviewCodeExample } from 'apps/website/src/components/preview-code-example/preview-code-example';
54

65
export const MainExample = component$(() => {
@@ -11,7 +10,9 @@ export const MainExample = component$(() => {
1110
<PopoverContent>
1211
<div class="p-4 bg-gray-500">Hi, I'm the content</div>
1312
</PopoverContent>
14-
<PopoverTrigger> Click on me </PopoverTrigger>
13+
<PopoverTrigger ariaAttributes={{ ariaLabel: 'click-friend' }}>
14+
Click on me
15+
</PopoverTrigger>
1516
</Popover>
1617
</div>
1718
<div q:slot="codeExample">
@@ -31,7 +32,9 @@ export const Example1 = component$(() => {
3132
Hi, I'm the content, but now on top
3233
</div>
3334
</PopoverContent>
34-
<PopoverTrigger> Click on me </PopoverTrigger>
35+
<PopoverTrigger ariaAttributes={{ ariaLabel: 'no-click-friend' }}>
36+
Click on me
37+
</PopoverTrigger>
3538
</Popover>
3639
</div>
3740
<div q:slot="codeExample">

cla-signs/v1/cla.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,14 @@
287287
"created_at": "2023-06-17T13:56:24Z",
288288
"repoId": 545159943,
289289
"pullRequestNo": 340
290+
},
291+
{
292+
"name": "Zankel-Engineering",
293+
"id": 43412711,
294+
"comment_id": 1802088836,
295+
"created_at": "2023-07-15T17:00:00Z",
296+
"repoId": 666652720,
297+
"pullRequestNo": 363
290298
}
291299
]
292-
}
300+
}

packages/kit-headless/src/utils/aria-attributes-helper.ts

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,33 +20,26 @@ type FunctionType = (
2020
ariaAttributes?: Partial<QwikUiAriaAttributesKebab>
2121
) => Partial<AriaAttributes>;
2222

23+
const cacheMap: Map<string, Partial<AriaAttributes>> = new Map();
24+
25+
const memoize = (func: FunctionType): FunctionType => {
26+
return (
27+
ariaAttributes?: Partial<QwikUiAriaAttributesKebab>
28+
): Partial<AriaAttributes> => {
29+
const key = JSON.stringify(ariaAttributes);
30+
if (!cacheMap.has(key) || !ariaAttributes) {
31+
const out = func(ariaAttributes);
32+
cacheMap.set(key, out);
33+
return out;
34+
} else {
35+
return cacheMap.get(key) || {};
36+
}
37+
};
38+
};
39+
2340
export const useAriaAttributes = (
2441
ariaAttributes?: Partial<QwikUiAriaAttributesKebab>
2542
): Partial<AriaAttributes> => {
26-
const memoize = (func: FunctionType): FunctionType => {
27-
let cache:
28-
| { in: string | undefined; out: Partial<AriaAttributes> }
29-
| undefined;
30-
return (
31-
ariaAttributes?: Partial<QwikUiAriaAttributesKebab>
32-
): Partial<AriaAttributes> => {
33-
if (!cache || !ariaAttributes) {
34-
const out = func(ariaAttributes);
35-
cache = {
36-
in: ariaAttributes ? JSON.stringify(ariaAttributes) : undefined,
37-
out,
38-
};
39-
return out;
40-
} else {
41-
const newCacheInValue = JSON.stringify(ariaAttributes);
42-
if (cache.in === newCacheInValue) {
43-
return cache.out;
44-
}
45-
cache = { in: newCacheInValue, out: func(ariaAttributes) };
46-
return cache.out;
47-
}
48-
};
49-
};
5043
const process = (
5144
ariaAttributes?: Partial<QwikUiAriaAttributesKebab>
5245
): Partial<AriaAttributes> => {

pnpm-lock.yaml

Lines changed: 18 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)