Skip to content

Commit 30f1c37

Browse files
committed
Merge branch 'frontend-use-message-component-for-status'
2 parents 302123e + b8899a1 commit 30f1c37

File tree

25 files changed

+251
-166
lines changed

25 files changed

+251
-166
lines changed

frontends/web/src/api/banners.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
*/
1616

1717
import { apiGet } from '@/utils/request';
18-
import { statusType } from '@/components/status/status';
1918
import { subscribeEndpoint, TUnsubscribe } from './subscribe';
19+
import type { TMessageTypes } from '@/utils/types';
2020

2121
export type TBannerInfo = {
2222
id: string;
@@ -26,7 +26,7 @@ export type TBannerInfo = {
2626
text?: string;
2727
};
2828
dismissible?: boolean;
29-
type?: statusType;
29+
type?: TMessageTypes;
3030
}
3131

3232
export const getBanner = (msgKey: string): Promise<TBannerInfo> => {

frontends/web/src/app.module.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.appContent {
2+
display: flex;
3+
flex: 1;
4+
flex-direction: column;
5+
height: 100vh;
6+
min-width: 0;
7+
/* mobile viewport bug fix */
8+
max-height: -webkit-fill-available;
9+
}
10+
11+
@media (max-width: 900px) {
12+
.appContent {
13+
position: absolute;
14+
width: 100%;
15+
}
16+
}

frontends/web/src/app.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,15 @@ import { notifyUser } from './api/system';
3232
import { ConnectedApp } from './connected';
3333
import { Alert } from './components/alert/Alert';
3434
import { Aopp } from './components/aopp/aopp';
35-
import { Banner } from './components/banner/banner';
3635
import { Confirm } from './components/confirm/Confirm';
3736
import { KeystoreConnectPrompt } from './components/keystoreconnectprompt';
38-
import { MobileDataWarning } from './components/mobiledatawarning';
3937
import { Sidebar } from './components/sidebar/sidebar';
40-
import { Update } from './components/update/update';
4138
import { RouterWatcher } from './utils/route';
4239
import { Darkmode } from './components/darkmode/darkmode';
4340
import { AuthRequired } from './components/auth/authrequired';
4441
import { WCSigningRequest } from './components/wallet-connect/incoming-signing-request';
4542
import { Providers } from './contexts/providers';
43+
import styles from './app.module.css';
4644

4745
export const App = () => {
4846
const { t } = useTranslation();
@@ -160,11 +158,7 @@ export const App = () => {
160158
deviceIDs={deviceIDs}
161159
devices={devices}
162160
/>
163-
<div className="appContent flex flex-column flex-1" style={{ minWidth: 0 }}>
164-
<Update />
165-
<Banner msgKey="bitbox01" />
166-
<Banner msgKey="bitbox02" />
167-
<MobileDataWarning />
161+
<div className={styles.appContent}>
168162
<WCSigningRequest />
169163
<Aopp />
170164
<KeystoreConnectPrompt />

frontends/web/src/components/banner/banner.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ export const Banner = ({ msgKey }: TBannerProps) => {
4848
<Status
4949
dismissible={banner.dismissible ? `banner-${msgKey}-${banner.id}` : ''}
5050
type={banner.type ? banner.type : 'warning'}>
51-
{ message[i18n.resolvedLanguage] || message[(i18n.options.fallbackLng as string[])[0]] }
51+
{message[i18n.resolvedLanguage] || message[(i18n.options.fallbackLng as string[])[0]]}
5252
&nbsp;
53-
{ link && (
53+
{link && (
5454
<A href={link.href} className={style.link}>
55-
{ link.text || t('clickHere') }
55+
{link.text || t('clickHere')}
5656
</A>
5757
)}
5858
</Status>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
.contentWrapper {
2+
margin: auto;
3+
max-width: var(--content-width);
4+
padding: 0 var(--space-default);
5+
width: 100%;
6+
}
7+
8+
.contentWrapper > div:first-child {
9+
margin-top: var(--space-half);
10+
}
11+
12+
.contentWrapper > div {
13+
margin-bottom: var(--space-half);
14+
}
15+
16+
.contentWrapper div:last-child {
17+
margin-bottom: 0;
18+
}
19+
20+
@media (max-width: 768px) {
21+
.contentWrapper {
22+
padding: 0 var(--space-half);
23+
}
24+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* Copyright 2023 Shift Crypto AG
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { ReactNode } from 'react';
18+
import style from './contentwrapper.module.css';
19+
20+
type TProps = {
21+
className?: string
22+
children: ReactNode
23+
}
24+
25+
export const ContentWrapper = (({ className = '', children }: TProps) => {
26+
return (
27+
<div className={`${className} ${style.contentWrapper}`}>{children}</div>
28+
);
29+
});
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* Copyright 2024 Shift Crypto AG
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
18+
import { Banner } from '@/components/banner/banner';
19+
import { MobileDataWarning } from '@/components/mobiledatawarning';
20+
import { Update } from '@/components/update/update';
21+
22+
export const GlobalBanners = () => {
23+
return (
24+
<>
25+
<Update />
26+
<Banner msgKey="bitbox01" />
27+
<Banner msgKey="bitbox02" />
28+
<MobileDataWarning />
29+
</>
30+
31+
);
32+
};

frontends/web/src/components/message/message.module.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
.content {
1616
padding-top: 2px;
17+
width: 100%;
1718
}
1819

1920
.message .title {
@@ -32,7 +33,7 @@
3233
}
3334

3435
.message img {
35-
margin-right: 12px;
36+
margin-right: 4px;
3637
max-width: 30px;
3738
}
3839

frontends/web/src/components/message/message.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
import { ReactNode } from 'react';
1919
import { StatusInfo, StatusSuccess, StatusWarning, StatusError } from '@/components/icon';
20+
import { TMessageTypes } from '@/utils/types';
2021
import styles from './message.module.css';
2122

22-
type TMessageTypes = 'success' | 'info' | 'warning' | 'error';
2323
type TMessageIconProps = { type: TMessageTypes };
2424

2525
const MessageIcon = ({ type }: TMessageIconProps) => {
@@ -50,6 +50,7 @@ type MessageProps = {
5050
small?: boolean;
5151
title?: string;
5252
type?: TMessageTypes;
53+
noIcon?: boolean;
5354
children: ReactNode;
5455
}
5556

@@ -58,14 +59,15 @@ export const Message = ({
5859
small,
5960
title,
6061
type = 'info',
62+
noIcon = false,
6163
children,
6264
}: MessageProps) => {
6365
if (hidden) {
6466
return null;
6567
}
6668
return (
6769
<div className={`${styles[type]} ${small ? styles.small : ''}`}>
68-
<MessageIcon type={type} />
70+
{!noIcon && <MessageIcon type={type} />}
6971
<div className={styles.content}>
7072
{title && (
7173
<h2 className={`subTitle ${styles.title}`}>{title}</h2>
Lines changed: 12 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,23 @@
1+
.content {
2+
margin-right: var(--space-eight);
3+
}
4+
15
.container {
2-
margin: 0 auto;
3-
position: relative;
4-
padding: calc(var(--space-default) * 1.5);
6+
align-items: flex-start;
7+
display: flex;
58
width: 100%;
69
}
710
.container.withCloseBtn {
811
padding-right: 60px;
912
}
1013

11-
:global(.padded) .container {
12-
max-width: var(--content-width);
13-
}
14-
15-
.status {
16-
font-size: var(--size-subheader);
17-
max-width: 800px;
18-
text-align: left;
19-
}
20-
21-
.success {
22-
background-color: var(--color-success);
23-
}
24-
25-
.warning {
26-
background-color: var(--color-warning);
27-
}
28-
29-
.info {
30-
background-color: var(--color-info);
31-
}
32-
33-
.success,
34-
.warning,
35-
.info,
36-
.success label, /* also force label elements to use color white */
37-
.warning label,
38-
.info label {
39-
color: var(--color-alt);
40-
}
41-
42-
.close-success {
43-
background: var(--color-darkgreen);
44-
}
45-
46-
.close-warning {
47-
background: var(--color-swissred);
48-
}
49-
50-
.close-info {
51-
background: var(--color-darkblue);
52-
}
53-
54-
.close {
14+
.closeButton {
15+
background-color: transparent;
5516
border: none;
56-
line-height: .5;
57-
padding: var(--space-half);
58-
position: absolute;
59-
top: 0;
60-
right: 0;
61-
}
62-
63-
.close svg {
64-
width: 18px;
65-
height: 18px;
66-
}
67-
68-
.withCloseBtn .status::before {
69-
content: "";
70-
float: right;
71-
height: 18px;
72-
padding-bottom: 2px;
73-
padding-left: var(--space-default);
74-
width: 18px;
17+
margin-left: auto;
7518
}
7619

77-
@media (max-width: 1199px) {
78-
.container {
79-
padding: calc(var(--space-half) * 1.5);
80-
}
20+
.closeButton img {
21+
width: 16px;
22+
height: 16px;
8123
}

0 commit comments

Comments
 (0)