Skip to content

Commit f557486

Browse files
Addressed the linting errors in your JSX files related to accessibility (#165)
* Addressed the linting errors in your JSX files related to accessibility * Looking of a node in the canvas added. and truncation of node and edges label added english label trunced after 8 characters and korean after 6 characters
1 parent 194ff0e commit f557486

File tree

7 files changed

+37
-908
lines changed

7 files changed

+37
-908
lines changed

frontend/src/components/contents/presentations/Editor.jsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ const Editor = ({
160160
size="lg"
161161
/>
162162
</button> */}
163-
<button className={command ? 'btn show-eraser' : 'btn hide-eraser'} type="button" id="eraser" onDoubleClick={() => clearCommand()}>
163+
<button className={command ? 'btn show-eraser' : 'btn hide-eraser'} type="button" id="eraser" onDoubleClick={() => clearCommand()} aria-label="Clear Command">
164164
<FontAwesomeIcon
165165
icon={faTimesCircle}
166166
size="1x"
@@ -171,6 +171,7 @@ const Editor = ({
171171
type="button"
172172
onClick={() => onClick()}
173173
title="Run Query"
174+
aria-label="Run Query"
174175
>
175176
<IconPlay />
176177
</button>
@@ -190,6 +191,7 @@ const Editor = ({
190191
} */
191192
}}
192193
title={(isActive) ? 'Hide' : 'Show'}
194+
aria-label="toggleMenu"
193195
>
194196
<SideBarToggle isActive={isActive} />
195197
</button>
@@ -198,6 +200,7 @@ const Editor = ({
198200
type="button"
199201
onClick={() => setLabel()}
200202
title="Run Query"
203+
aria-label="Run Query"
201204
>
202205
<FontAwesomeIcon
203206
icon={isLabel ? faToggleOn : faToggleOff}

frontend/src/components/cypherresult/presentations/CypherResultCytoscape.jsx

+9-2
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,15 @@ const CypherResultCytoscape = forwardRef((props, ref) => {
9494
setLegendData(addedLegendData);
9595
props.setChartLegend(addedLegendData);
9696
};
97-
98-
const changeColorOnCytoscapeElements = (elementType, label, color) => {
97+
const truncateLabel = (label) => {
98+
const maxLenEnglish = 8;
99+
const maxLenKorean = 6;
100+
const koreanCharRegex = /[\u3131-\uD79D]/ugi;
101+
const maxLength = koreanCharRegex.test(label) ? maxLenKorean : maxLenEnglish;
102+
return label.length > maxLength ? `${label.substring(0, maxLength)}...` : label;
103+
};
104+
const changeColorOnCytoscapeElements = (elementType, originalLabel, color) => {
105+
const label = truncateLabel(originalLabel);
99106
const colorObject = Array.isArray(color) ? {
100107
color: color[0],
101108
borderColor: color[1],

frontend/src/components/cytoscape/CypherResultCytoscapeChart.jsx

+13
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import {
3535
faLockOpen,
3636
faProjectDiagram,
3737
faTrash,
38+
faThumbtack,
3839
} from '@fortawesome/free-solid-svg-icons';
3940
import uuid from 'react-uuid';
4041
import cxtmenu from '../../lib/cytoscape-cxtmenu';
@@ -243,6 +244,18 @@ const CypherResultCytoscapeCharts = ({
243244
dispatch(addElementHistory(ele.id()));
244245
},
245246
},
247+
{
248+
content: ReactDOMServer.renderToString(
249+
<FontAwesomeIcon icon={faThumbtack} size="lg" />,
250+
),
251+
select(ele) {
252+
if (!ele.locked()) {
253+
ele.lock();
254+
} else {
255+
ele.unlock();
256+
}
257+
},
258+
},
246259
{
247260
content: ReactDOMServer.renderToString(<IconFilter size="lg" />),
248261
select(ele) {

frontend/src/components/cytoscape/CypherResultCytoscapeFooter.jsx

+6
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ const CypherResultCytoscapeFooter = ({
9494
type="button"
9595
className="frame-head-button btn btn-link px-3"
9696
onClick={() => setFooterExpanded(!footerExpanded)}
97+
aria-label="Set Footer Expanded"
9798
>
9899
<FontAwesomeIcon
99100
icon={footerExpanded ? faAngleUp : faAngleDown}
@@ -170,6 +171,7 @@ const CypherResultCytoscapeFooter = ({
170171
type="button"
171172
className={`btn sizeSelector node ${footerData.data.size >= nodeSize ? ' selectedSize ' : ''}`}
172173
style={{ width: `${size}px`, height: `${size}px` }}
174+
aria-label="Update NodeLabel Size"
173175
>
174176
&nbsp;
175177
</button>
@@ -186,6 +188,7 @@ const CypherResultCytoscapeFooter = ({
186188
type="button"
187189
className={`btn sizeSelector edge ${footerData.data.size >= edgeSize ? ' selectedSize ' : ''}`}
188190
style={{ width: `${size + 18}px`, height: `${size}px` }}
191+
aria-label="Update Edge Label Size"
189192
>
190193
&nbsp;
191194
</button>
@@ -212,6 +215,7 @@ const CypherResultCytoscapeFooter = ({
212215
type="button"
213216
className={`btn colorSelector ${footerData.data.backgroundColor === color.color ? ' selectedColor ' : ''}`}
214217
style={{ backgroundColor: color.color }}
218+
aria-label="Update Label Color"
215219
>
216220
&nbsp;
217221
</button>
@@ -227,6 +231,7 @@ const CypherResultCytoscapeFooter = ({
227231
type="button"
228232
className={`btn colorSelector ${footerData.data.backgroundColor === color.color ? ' selectedColor ' : ''}`}
229233
style={{ backgroundColor: color.color }}
234+
aria-label="Update Label Color"
230235
>
231236
&nbsp;
232237
</button>
@@ -293,6 +298,7 @@ const CypherResultCytoscapeFooter = ({
293298
type="button"
294299
className="frame-head-button btn btn-link px-3"
295300
onClick={() => setFooterExpanded(!footerExpanded)}
301+
aria-label="Set Footer Expanded"
296302
>
297303
<FontAwesomeIcon
298304
icon={footerExpanded ? faAngleUp : faAngleDown}

frontend/src/components/cytoscape/CypherResultCytoscapeLegend.jsx

+2
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ class CypherResultCytoscapeLegend extends Component {
181181
type="button"
182182
className="frame-head-button btn btn-link px-3"
183183
onClick={() => this.setState({ nodeLegendExpanded: !nodeLegendExpanded })}
184+
aria-label="Node Legend"
184185
>
185186
<FontAwesomeIcon
186187
icon={nodeLegendExpanded ? faAngleUp : faAngleDown}
@@ -196,6 +197,7 @@ class CypherResultCytoscapeLegend extends Component {
196197
type="button"
197198
className="frame-head-button btn btn-link px-3"
198199
onClick={() => this.setState({ edgeLegendExpanded: !edgeLegendExpanded })}
200+
aria-label="Edge Legend"
199201
>
200202
<FontAwesomeIcon
201203
icon={edgeLegendExpanded ? faAngleUp : faAngleDown}

frontend/src/components/sidebar/presentations/SidebarHome.jsx

+2
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ const SidebarHome = ({
430430
className="frame-head-button refresh_button btn btn-link"
431431
type="button"
432432
onClick={() => refreshSidebarHome()}
433+
aria-label="Refresh Button"
433434
>
434435
<FontAwesomeIcon
435436
icon={faRedo}
@@ -456,6 +457,7 @@ const SidebarHome = ({
456457
return false;
457458
},
458459
})}
460+
aria-label="Close Button"
459461
>
460462
<FontAwesomeIcon
461463
icon={faTimes}

0 commit comments

Comments
 (0)