Skip to content

Commit 945203e

Browse files
authored
added UX improvements (#1405)
1 parent cd2122d commit 945203e

File tree

8 files changed

+45
-24
lines changed

8 files changed

+45
-24
lines changed

src/components/ParserOpenRPC/CollapseBox/CollapseBox.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const CollapseBox = ({ children, isInitCollapsed = false }: CollapseBoxPr
2525
{collapsed ? "Show child attributes" : "Hide child attributes"}
2626
<div className={clsx(styles.collapseIcon, !collapsed && styles.collapsedIconView)}></div>
2727
</button>
28-
<Collapsible lazy collapsed={collapsed}>{children}</Collapsible>
28+
<Collapsible animation={{ duration: 100, easing: "ease-in" }} lazy={false} collapsed={collapsed}>{children}</Collapsible>
2929
</div>
3030
);
3131
};

src/components/ParserOpenRPC/CollapseBox/styles.module.css

+5-4
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
padding: 12px 22px;
2323
margin-bottom: 1px;
2424
cursor: pointer;
25-
transition-property: 'border-color', 'background-color';
26-
transition-duration: .2s;
27-
transition-timing-function: ease;
25+
/*transition-property: 'border-color', 'background-color';*/
26+
/*transition-duration: .2s;*/
27+
/*transition-timing-function: ease;*/
2828
}
2929

3030
.collapseIcon {
@@ -34,7 +34,7 @@
3434
border-top: 2px solid #0376C9;
3535
border-right: 2px solid #0376C9;
3636
transform: rotate(45deg);
37-
transition: transform .2s ease;
37+
/*transition: transform .2s ease;*/
3838
}
3939

4040
.collapseBtn:hover {
@@ -61,6 +61,7 @@
6161
border-color: transparent;
6262
width: 100%;
6363
border-radius: 0;
64+
border-bottom: 1px solid #848C96;
6465
}
6566

6667
.collapsedBtnView:hover {

src/components/ParserOpenRPC/DetailsBox/styles.module.css

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@
1919
}
2020

2121
.paramItemWrapper {
22-
border-top: 1px solid #848C96;
2322
padding: 0 1rem;
2423
}
2524

25+
.paramItemWrapper:not(:first-child) {
26+
border-top: 1px solid #848C96;
27+
}
28+
2629
.borderTopLine {
2730
border-top: 1px solid #848C96;
2831
}

src/components/ParserOpenRPC/InteractiveBox/styles.module.css

+3-5
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@
6969
cursor: pointer;
7070
}
7171
.tableLabelIconError {
72-
width: 11px;
72+
position: absolute;
73+
left: 4px;
74+
width: 13px;
7375
height: 11px;
74-
margin-left: 8px;
7576
background: url("/img/icons/error-icon.svg") no-repeat 50% 50%;
7677
}
7778
.tableColumnIcon {
@@ -112,9 +113,6 @@
112113
.deleteIconCentered {
113114
top: 50%;
114115
}
115-
.deleteIconComplex {
116-
top: 27px;
117-
}
118116
.dropdown {
119117
display: flex;
120118
align-items: center;

src/components/ParserOpenRPC/InteractiveBox/templates/ArrayFieldTemplate.tsx

+17-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useContext, useState } from "react";
1+
import React, { useContext, useEffect, useState } from "react";
22
import { useCollapsible, Collapsible } from "@docusaurus/theme-common";
33
import { ArrayFieldTemplateProps } from "@rjsf/utils";
44
import { BaseInputTemplate } from "@site/src/components/ParserOpenRPC/InteractiveBox/templates/BaseInputTemplate";
@@ -13,7 +13,9 @@ export const ArrayFieldTemplate = ({ items, canAdd, onAddClick, title, schema, f
1313
const itemsType = schema?.items?.type;
1414
const isSimpleArray = itemsType === "string" || itemsType === "boolean" || itemsType === "number" || itemsType === "integer";
1515
const addComplexArray = () => {
16-
onAddClick();
16+
if(formData?.length === 0) {
17+
onAddClick();
18+
}
1719
setDrawerLabel(title);
1820
setIsDrawerContentFixed(true);
1921
setIsComplexArrayEditView(true);
@@ -26,6 +28,12 @@ export const ArrayFieldTemplate = ({ items, canAdd, onAddClick, title, schema, f
2628
}
2729
}
2830

31+
useEffect(() => {
32+
if (!isComplexTypeView) {
33+
setIsComplexArrayEditView(false);
34+
}
35+
}, [isComplexTypeView])
36+
2937
return (
3038
<div>
3139
<div className={styles.tableRow}>
@@ -60,14 +68,14 @@ export const ArrayFieldTemplate = ({ items, canAdd, onAddClick, title, schema, f
6068
<div className={styles.tableComplexType}>
6169
{items.map(({ children, index, onDropIndexClick, hasRemove }) => (
6270
<div className={styles.tableComplexTypeItem} key={index}>
71+
{hasRemove ?
72+
<button className={clsx(styles.tableButton, styles.tableButtonAddNewArray)} onClick={onDropIndexClick(index)}>
73+
<img src="/img/icons/minus-icon.svg" alt={`Add ${title}`} width="16px" height="16px" />
74+
<span className={styles.tableButtonAddArrayItemName}>Remove {title}</span>
75+
</button> :
76+
null
77+
}
6378
{children}
64-
{hasRemove && (
65-
<span
66-
onClick={onDropIndexClick(index)}
67-
className={clsx(styles.deleteIcon, styles.deleteIconComplex)}
68-
>
69-
</span>
70-
)}
7179
</div>
7280
))}
7381
{canAdd ?

src/components/ParserOpenRPC/InteractiveBox/templates/BaseInputTemplate.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const BaseInputTemplate = ({
2727
const [inputValue, setInputValue] = useState(isNumber ? 0 : "");
2828

2929
const { isFormReseted } = formContext;
30-
const hasErrors = rawErrors?.length > 0 && !hideError;
30+
const hasErrors = rawErrors?.length > 0 && !hideError && value !== "";
3131
const debouncedOnChange = useCallback(debounce((e, isInputNumber = false) => {
3232
onChange(isInputNumber ? e : e?.target?.value);
3333
}, 300), []);
@@ -54,13 +54,13 @@ export const BaseInputTemplate = ({
5454
<div className={styles.tableColumn}>
5555
<label className={clsx(styles.tableColumnParam, isFocused && styles.tableColumnParamFocused, hasErrors && styles.tableColumnParamError)}>
5656
<span>{name}{required && "*"}</span>
57-
{hasErrors && !isNumber ? <span className={styles.tableLabelIconError} /> : null}
5857
</label>
5958
</div>
6059
)}
6160
<div className={!isArray ? styles.tableColumn : ""}>
62-
<Tooltip message={hasErrors ? rawErrors[0] : ""} disabled={!rawErrors}>
61+
<Tooltip message={hasErrors ? rawErrors[0] : ""} disabled={!hasErrors}>
6362
<div className={styles.tableValueRow}>
63+
{hasErrors && !isNumber ? <span className={styles.tableLabelIconError} /> : null}
6464
<input
6565
id={id}
6666
value={inputValue}

src/css/custom.css

+9-1
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,10 @@ button:hover {
320320
border-top-color: rgba(20, 22, 24, 1);
321321
}
322322

323+
[data-theme="light"] .tippy-popper[x-placement^=bottom] [x-arrow] {
324+
border-bottom-color: rgba(20, 22, 24, 1);
325+
}
326+
323327
[data-theme="dark"] .tippy-tooltip {
324328
background-color: rgba(255, 255, 255, 1);
325329
color: rgba(20, 22, 24, 1);
@@ -329,8 +333,12 @@ button:hover {
329333
border-top-color: rgba(255, 255, 255, 1);
330334
}
331335

336+
[data-theme="dark"] .tippy-popper[x-placement^=bottom] [x-arrow] {
337+
border-bottom-color: rgba(255, 255, 255, 1);
338+
}
339+
332340
@media (max-width: 1200px) {
333-
.navbar__item {
341+
.navbar__item, .navbar__link {
334342
font-size: 14px;
335343
}
336344
}

static/img/icons/minus-icon.svg

+3
Loading

0 commit comments

Comments
 (0)