Skip to content

Commit 0144992

Browse files
committed
fix: speed test latency
1 parent 355b906 commit 0144992

File tree

4 files changed

+19
-18
lines changed

4 files changed

+19
-18
lines changed

src/pages/Index/components/MenuTile.tsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ import { jsx } from '@emotion/core'
33
import styled from '@emotion/styled/macro'
44
import css from '@emotion/css/macro'
55
import { Card, Heading } from '@sumup/circuit-ui'
6-
import tw, { TwStyle } from 'twin.macro'
6+
import tw from 'twin.macro'
77
import React, { MouseEventHandler } from 'react'
88

99
interface MenuTileProps {
10-
style?: TwStyle
1110
onClick?: MouseEventHandler
1211
link?: string
1312
}
@@ -20,14 +19,20 @@ const MenuTile: React.FC<MenuTileProps> = (props) => {
2019
}
2120

2221
return (
23-
<div onClick={handleClick} css={[props.onClick && tw`cursor-pointer`]}>
22+
<div
23+
onClick={handleClick}
24+
css={[
25+
props.onClick &&
26+
tw`cursor-pointer transform transition-transform duration-100 active:scale-95`,
27+
]}>
2428
<Card
2529
css={[
2630
css`
31+
user-select: none;
2732
min-height: 8rem;
2833
`,
29-
tw`p-4 border-none shadow-sm`,
30-
props.style || tw`bg-gray-100`,
34+
tw`p-4 border-none shadow-sm bg-gray-100 transition-colors duration-150 ease-in-out`,
35+
props.onClick && tw`hover:bg-gray-200 active:bg-gray-200`,
3136
]}>
3237
{props.children}
3338
</Card>
@@ -37,12 +42,9 @@ const MenuTile: React.FC<MenuTileProps> = (props) => {
3742

3843
export const MenuTileContent = styled.div``
3944

40-
export const MenuTileTitle: React.FC<{ style?: TwStyle; title: string }> = ({
41-
style,
42-
title,
43-
}) => {
45+
export const MenuTileTitle: React.FC<{ title: string }> = ({ title }) => {
4446
return (
45-
<Heading size={'mega'} noMargin css={style || tw`text-gray-800`}>
47+
<Heading size={'mega'} noMargin tw="text-gray-800">
4648
{title}
4749
</Heading>
4850
)

src/pages/Index/index.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,7 @@ const Page: React.FC = () => {
184184
{item.component ? (
185185
item.component
186186
) : (
187-
<MenuTile
188-
style={item.tintColor}
189-
onClick={() => openLink(item.link)}>
187+
<MenuTile onClick={() => openLink(item.link)}>
190188
<MenuTileTitle title={t(`home.${item.title}`)} />
191189

192190
{item.subTitle && (

src/pages/Index/menu.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/** @jsx jsx */
22
import { jsx } from '@emotion/core'
33
import React from 'react'
4-
import tw, { TwStyle } from 'twin.macro'
54
import gte from 'semver/functions/gte'
65

76
import { Profile } from '../../types'
@@ -12,8 +11,6 @@ export interface MenuItem {
1211
title: string
1312
subTitle?: string
1413
link?: string
15-
tintColor?: TwStyle
16-
textColor?: TwStyle
1714
component?: JSX.Element
1815
isEnabled?: (
1916
platform: Profile['platform'] | void,

src/pages/Policies/components/PolicyGroup.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,19 @@ const PolicyGroup: React.FC<PolicyGroupProps> = ({
102102
Object.keys(testResult).forEach((key) => {
103103
const result = testResult[key]
104104

105-
latencies[key] = result.receive ?? -1
105+
latencies[key] = result.receive
106+
? Number(result.receive.toFixed(0))
107+
: -1
106108
})
107109
setSelection((res as UrlTestPolicyTestResult).winner)
108110
} else {
109111
const testResult = res as SelectPolicyTestResult
110112
Object.keys(testResult).forEach((key) => {
111113
const result = testResult[key]
112114

113-
latencies[key] = result.receive ?? -1
115+
latencies[key] = result.receive
116+
? Number(result.receive.toFixed(0))
117+
: -1
114118
})
115119
}
116120

0 commit comments

Comments
 (0)