Skip to content

Commit febc63e

Browse files
committed
fix(in-app-menu): fix app crash in production
1 parent b3c05c8 commit febc63e

File tree

7 files changed

+149
-138
lines changed

7 files changed

+149
-138
lines changed

src/plugins/in-app-menu/renderer.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { createSignal } from 'solid-js';
22
import { render } from 'solid-js/web';
3+
import { extractCss } from 'solid-styled-components';
34

45
import { TitleBar } from './renderer/TitleBar';
56
import { defaultInAppMenuConfig, InAppMenuConfig } from './constants';

src/plugins/in-app-menu/renderer/IconButton.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { JSX } from 'solid-js';
22
import { css } from 'solid-styled-components';
33

4-
const iconButton = css`
4+
import { cache } from '@/providers/decorators';
5+
6+
const iconButton = cache(() => css`
57
background: transparent;
68
79
width: 24px;
@@ -28,12 +30,12 @@ const iconButton = css`
2830
&:active {
2931
scale: 0.9;
3032
}
31-
`;
33+
`);
3234

3335
type CollapseIconButtonProps = JSX.HTMLAttributes<HTMLButtonElement>;
3436
export const IconButton = (props: CollapseIconButtonProps) => {
3537
return (
36-
<button {...props} class={iconButton}>
38+
<button {...props} class={iconButton()}>
3739
{props.children}
3840
</button>
3941
);

src/plugins/in-app-menu/renderer/MenuButton.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { JSX, splitProps } from 'solid-js';
22
import { css } from 'solid-styled-components';
3+
import { cache } from '@/providers/decorators';
34

4-
const menuStyle = css`
5+
const menuStyle = cache(() => css`
56
-webkit-app-region: none;
67
78
display: flex;
@@ -25,7 +26,7 @@ const menuStyle = css`
2526
&[data-selected="true"] {
2627
background-color: rgba(255, 255, 255, 0.2);
2728
}
28-
`;
29+
`);
2930

3031
export type MenuButtonProps = JSX.HTMLAttributes<HTMLLIElement> & {
3132
text?: string;
@@ -35,7 +36,7 @@ export const MenuButton = (props: MenuButtonProps) => {
3536
const [local, leftProps] = splitProps(props, ['text']);
3637

3738
return (
38-
<li {...leftProps} class={menuStyle} data-selected={props.selected}>
39+
<li {...leftProps} class={menuStyle()} data-selected={props.selected}>
3940
{local.text}
4041
</li>
4142
);

src/plugins/in-app-menu/renderer/Panel.tsx

+10-9
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import { css } from 'solid-styled-components';
44
import { Transition } from 'solid-transition-group';
55
import { autoUpdate, flip, offset, OffsetOptions, size } from '@floating-ui/dom';
66
import { useFloating } from 'solid-floating-ui';
7+
import { cache } from '@/providers/decorators';
78

8-
const panelStyle = css`
9+
const panelStyle = cache(() => css`
910
position: fixed;
1011
top: var(--offset-y, 0);
1112
left: var(--offset-x, 0);
@@ -32,9 +33,9 @@ const panelStyle = css`
3233
0 2px 8px rgba(0, 0, 0, 0.2);
3334
3435
transform-origin: var(--origin-x, 50%) var(--origin-y, 50%);
35-
`;
36+
`);
3637

37-
const animationStyle = {
38+
const animationStyle = cache(() => ({
3839
enter: css`
3940
opacity: 0;
4041
transform: scale(0.9);
@@ -49,7 +50,7 @@ const animationStyle = {
4950
exitActive: css`
5051
transition: opacity 0.225s cubic-bezier(0.32, 0, 0.67, 0), transform 0.225s cubic-bezier(0.32, 0, 0.67, 0);
5152
`,
52-
};
53+
}));
5354

5455
export type Placement =
5556
'top'
@@ -122,16 +123,16 @@ export const Panel = (props: PanelProps) => {
122123
<Portal>
123124
<Transition
124125
appear
125-
enterClass={animationStyle.enter}
126-
enterActiveClass={animationStyle.enterActive}
127-
exitToClass={animationStyle.exitTo}
128-
exitActiveClass={animationStyle.exitActive}
126+
enterClass={animationStyle().enter}
127+
enterActiveClass={animationStyle().enterActive}
128+
exitToClass={animationStyle().exitTo}
129+
exitActiveClass={animationStyle().exitActive}
129130
>
130131
<Show when={local.open}>
131132
<ul
132133
{...leftProps}
133134
ref={setPanel}
134-
class={panelStyle}
135+
class={panelStyle()}
135136
style={{
136137
'--offset-x': `${position.x}px`,
137138
'--offset-y': `${position.y}px`,

0 commit comments

Comments
 (0)