Skip to content

Commit d1337d2

Browse files
committed
Modal - use VNode icon and content
1 parent 4e98cab commit d1337d2

File tree

2 files changed

+8
-24
lines changed

2 files changed

+8
-24
lines changed

src/client/lazy-app/Modal/index.tsx

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
1-
import { h, Component } from 'preact';
1+
import { h, Component, VNode, Fragment } from 'preact';
22
import * as style from './style.css';
33
import 'add-css:./style.css';
44
import { linkRef } from 'shared/prerendered-app/util';
5-
import {
6-
InfoIcon,
7-
DiamondStarIcon,
8-
ModalErrorIcon,
9-
} from 'client/lazy-app/icons';
105

116
interface Props {}
127

138
export interface ModalMessage {
14-
type: 'info' | 'error' | 'update';
9+
icon: VNode;
1510
title: string;
16-
content: string;
11+
content: VNode;
1712
}
1813

1914
interface State {
@@ -24,9 +19,9 @@ interface State {
2419
export default class Modal extends Component<Props, State> {
2520
state: State = {
2621
message: {
27-
type: 'info',
22+
icon: <svg></svg>,
2823
title: 'default',
29-
content: 'default',
24+
content: <Fragment></Fragment>,
3025
},
3126
shown: false,
3227
};
@@ -103,15 +98,7 @@ export default class Modal extends Component<Props, State> {
10398
onKeyDown={(e) => this._onKeyDown(e)}
10499
>
105100
<header class={style.header}>
106-
<span class={style.modalTypeIcon}>
107-
{message.type === 'info' ? (
108-
<InfoIcon />
109-
) : message.type === 'error' ? (
110-
<ModalErrorIcon />
111-
) : (
112-
<DiamondStarIcon />
113-
)}
114-
</span>
101+
<span class={style.modalIcon}>{message.icon}</span>
115102
<span class={style.modalTitle}>{message.title}</span>
116103
<button class={style.closeButton} onClick={() => this.hideModal()}>
117104
<svg viewBox="0 0 480 480" fill="currentColor">
@@ -125,10 +112,7 @@ export default class Modal extends Component<Props, State> {
125112
</button>
126113
</header>
127114
<div class={style.contentContainer}>
128-
<article
129-
class={style.content}
130-
dangerouslySetInnerHTML={{ __html: message.content }}
131-
></article>
115+
<article class={style.content}>{message.content}</article>
132116
</div>
133117
<footer class={style.footer}></footer>
134118
</dialog>

src/client/lazy-app/Modal/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ dialog.modal--closing {
107107
white-space: nowrap;
108108
}
109109

110-
.modal-type-icon {
110+
.modal-icon {
111111
display: flex;
112112
justify-content: center;
113113
align-items: center;

0 commit comments

Comments
 (0)