Refactor a lot of styling to achieve using Queryable in Protocol component

This commit is contained in:
M. Mert Yildiran 2021-11-29 11:46:03 +03:00
parent a0a4452bf0
commit 2a93f365f5
No known key found for this signature in database
GPG Key ID: D42ADB236521BF7A
8 changed files with 31 additions and 18 deletions

View File

@ -39,13 +39,13 @@ const EntryTitle: React.FC<any> = ({protocol, data, bodySize, elapsedTime, updat
const response = data.response; const response = data.response;
const bodySizeChild = <div const bodySizeChild = <div
style={{margin: "0 18px", opacity: 0.5}} style={{opacity: 0.5}}
> >
{formatSize(bodySize)} {formatSize(bodySize)}
</div>; </div>;
const elapsedTimeChild = <div const elapsedTimeChild = <div
style={{marginRight: 18, opacity: 0.5}} style={{opacity: 0.5}}
> >
{Math.round(elapsedTime)}ms {Math.round(elapsedTime)}ms
</div>; </div>;
@ -57,6 +57,7 @@ const EntryTitle: React.FC<any> = ({protocol, data, bodySize, elapsedTime, updat
{response && <Queryable {response && <Queryable
query={`response.bodySize == ${bodySize}`} query={`response.bodySize == ${bodySize}`}
updateQuery={updateQuery} updateQuery={updateQuery}
style={{margin: "0 18px"}}
displayIconOnMouseOver={true} displayIconOnMouseOver={true}
> >
{bodySizeChild} {bodySizeChild}
@ -64,6 +65,7 @@ const EntryTitle: React.FC<any> = ({protocol, data, bodySize, elapsedTime, updat
{response && <Queryable {response && <Queryable
query={`elapsedTime >= ${elapsedTime}`} query={`elapsedTime >= ${elapsedTime}`}
updateQuery={updateQuery} updateQuery={updateQuery}
style={{marginRight: 18}}
displayIconOnMouseOver={true} displayIconOnMouseOver={true}
> >
{elapsedTimeChild} {elapsedTimeChild}

View File

@ -6,20 +6,15 @@
min-height: 46px min-height: 46px
max-height: 46px max-height: 46px
align-items: center align-items: center
padding: 0 8px
border-radius: 4px border-radius: 4px
cursor: pointer cursor: pointer
border: solid 1px transparent margin-left: -1px
margin-right: 10px
&:not(:first-child)
margin-top: 10px
&:hover &:hover
border: solid 1px lighten(#4253a5, 20%) border: solid 1px lighten(#4253a5, 20%)
.rowSelected .rowSelected
border: 1px $blue-color solid border: 1px $blue-color solid
margin-right: 3px
.ruleSuccessRow .ruleSuccessRow
background: #E8FFF1 background: #E8FFF1

View File

@ -21,7 +21,7 @@ const useLayoutStyles = makeStyles(() => ({
padding: "12px 24px", padding: "12px 24px",
borderRadius: 4, borderRadius: 4,
marginTop: 15, marginTop: 15,
background: variables.headerBackgoundColor, background: variables.headerBackgroundColor,
}, },
viewer: { viewer: {

View File

@ -1,5 +1,7 @@
import React from "react"; import React from "react";
import styles from './style/Protocol.module.sass'; import styles from './style/Protocol.module.sass';
import Queryable from "./Queryable";
import variables from '../../variables.module.scss';
export interface ProtocolInterface { export interface ProtocolInterface {
name: string name: string
@ -36,7 +38,7 @@ const Protocol: React.FC<ProtocolProps> = ({protocol, horizontal, updateQuery})
</span> </span>
</a> </a>
} else { } else {
return <span const child = <span
className={`${styles.base} ${styles.vertical}`} className={`${styles.base} ${styles.vertical}`}
style={{ style={{
backgroundColor: protocol.backgroundColor, backgroundColor: protocol.backgroundColor,
@ -44,12 +46,22 @@ const Protocol: React.FC<ProtocolProps> = ({protocol, horizontal, updateQuery})
fontSize: protocol.fontSize, fontSize: protocol.fontSize,
}} }}
title={protocol.longName} title={protocol.longName}
onClick={() => {
updateQuery(protocol.macro)
}}
> >
{protocol.abbr} {protocol.abbr}
</span> </span>;
return <Queryable
query={protocol.macro}
updateQuery={updateQuery}
displayIconOnMouseOver={true}
flipped={true}
style={{
backgroundColor: variables.dataBackgroundColor,
}}
iconStyle={{marginRight: "28px"}}
>
{child}
</Queryable>
} }
}; };

View File

@ -7,13 +7,14 @@ interface Props {
query: string, query: string,
updateQuery: any, updateQuery: any,
style?: object, style?: object,
iconStyle?: object,
className?: string, className?: string,
useTooltip?: boolean, useTooltip?: boolean,
displayIconOnMouseOver?: boolean, displayIconOnMouseOver?: boolean,
flipped?: boolean, flipped?: boolean,
} }
const Queryable: React.FC<Props> = ({query, updateQuery, style, className, useTooltip= true, displayIconOnMouseOver = false, flipped = false, children}) => { const Queryable: React.FC<Props> = ({query, updateQuery, style, iconStyle, className, useTooltip= true, displayIconOnMouseOver = false, flipped = false, children}) => {
const [showAddedNotification, setAdded] = useState(false); const [showAddedNotification, setAdded] = useState(false);
const [showTooltip, setShowTooltip] = useState(false); const [showTooltip, setShowTooltip] = useState(false);
@ -37,6 +38,7 @@ const Queryable: React.FC<Props> = ({query, updateQuery, style, className, useTo
<span <span
className={`Queryable-Icon`} className={`Queryable-Icon`}
title={`Add "${query}" to the filter`} title={`Add "${query}" to the filter`}
style={iconStyle}
> >
<AddCircleIcon fontSize="small" color="inherit"></AddCircleIcon> <AddCircleIcon fontSize="small" color="inherit"></AddCircleIcon>
{showAddedNotification && <span className={'Queryable-AddNotifier'}>Added</span>} {showAddedNotification && <span className={'Queryable-AddNotifier'}>Added</span>}

View File

@ -7,6 +7,7 @@
padding: .5rem 0 padding: .5rem 0
border-bottom: 1px solid #BCC6DD border-bottom: 1px solid #BCC6DD
margin-right: 20px margin-right: 20px
margin-left: 24px
.filterLabel .filterLabel
color: #8f9bb2 color: #8f9bb2

View File

@ -68,7 +68,7 @@
display: flex display: flex
flex-grow: 1 flex-grow: 1
overflow: hidden overflow: hidden
padding-left: 24px // padding-left: 24px
flex-direction: column flex-direction: column
.TrafficPage-DetailContainer .TrafficPage-DetailContainer

View File

@ -11,7 +11,8 @@ $blue-gray: #494677;
:export { :export {
mainBackgroundColor: $main-background-color; mainBackgroundColor: $main-background-color;
headerBackgoundColor: $header-background-color; headerBackgroundColor: $header-background-color;
dataBackgroundColor: $data-background-color;
fontColor: $font-color; fontColor: $font-color;
secondaryFontColor: $secondary-font-color; secondaryFontColor: $secondary-font-color;
blueColor: $blue-color; blueColor: $blue-color;