Skip to content

Commit ff58c80

Browse files
committed
Refactor UI components for improved styling and layout consistency
- Removed help text from priority rules in PrioritiesSchema.js for a cleaner UI. - Adjusted margins and font sizes in RJSFFormFieldAdapter.jsx and associated SCSS for better spacing and readability. - Reduced padding and margin values across various components to enhance layout uniformity.
1 parent 339bd01 commit ff58c80

4 files changed

Lines changed: 115 additions & 97 deletions

File tree

src/components/AdminPane/Manage/ManageChallenges/EditChallenge/Schemas/PrioritiesSchema.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -371,29 +371,16 @@ export const uiSchema = (intl, user, challengeData, extraErrors, options = {}) =
371371
highPriorityRules: {
372372
ruleGroup: priorityRuleGroupUISchema(isCollapsed),
373373
"ui:collapsed": isCollapsed,
374-
"ui:help": intl.formatMessage({
375-
id: "Admin.EditChallenge.priority.highPriorityRules.help",
376-
defaultMessage: "High priority rules take precedence over all other rules and boundaries.",
377-
}),
378374
},
379375
mediumPriorityBounds: priorityBoundsConfig,
380376
mediumPriorityRules: {
381377
ruleGroup: priorityRuleGroupUISchema(isCollapsed),
382378
"ui:collapsed": isCollapsed,
383-
"ui:help": intl.formatMessage({
384-
id: "Admin.EditChallenge.priority.mediumPriorityRules.help",
385-
defaultMessage:
386-
"Medium priority rules take precedence over low priority rules and boundaries.",
387-
}),
388379
},
389380
lowPriorityBounds: priorityBoundsConfig,
390381
lowPriorityRules: {
391382
ruleGroup: priorityRuleGroupUISchema(isCollapsed),
392383
"ui:collapsed": isCollapsed,
393-
"ui:help": intl.formatMessage({
394-
id: "Admin.EditChallenge.priority.lowPriorityRules.help",
395-
defaultMessage: "Low priority rules have the lowest precedence.",
396-
}),
397384
},
398385
};
399386
};
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.custom-priority-bounds {
2+
input[type="number"] {
3+
background-color: rgba(0, 0, 0, 0.1);
4+
border: 1px solid rgba(255, 255, 255, 0.1);
5+
border-radius: 3px;
6+
color: #fff;
7+
font-size: 0.8rem;
8+
height: 1.5rem;
9+
10+
&:focus {
11+
outline: none;
12+
border-color: rgba(255, 255, 255, 0.3);
13+
}
14+
}
15+
}

src/components/Custom/RJSFFormFieldAdapter/RJSFFormFieldAdapter.jsx

Lines changed: 50 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,12 @@ export const PriorityBoundsFieldAdapter = (props) => {
6666
};
6767

6868
return (
69-
<div className="array-field">
69+
<div className="array-field" style={{ marginBottom: "0.5rem" }}>
7070
{props.schema.title && (
71-
<label className="mr-text-mango mr-text-md mr-uppercase mr-mb-2">
71+
<label
72+
className="mr-text-mango mr-text-sm mr-uppercase"
73+
style={{ marginBottom: "0.25rem", display: "block" }}
74+
>
7275
{props.schema.title}
7376
</label>
7477
)}
@@ -91,6 +94,7 @@ export const CustomArrayFieldTemplate = (props) => {
9194
<div
9295
key={element.index}
9396
className={classNames("array-field__item", props.uiSchema?.items?.classNames)}
97+
style={{ marginBottom: "0.25rem" }}
9498
>
9599
<div className={classNames({ inline: props.uiSchema?.items?.["ui:options"]?.inline })}>
96100
{element.children}
@@ -104,7 +108,7 @@ export const CustomArrayFieldTemplate = (props) => {
104108
>
105109
{deleteLabel || (
106110
<span className="icon is-danger">
107-
<SvgSymbol sym="trash-icon" viewBox="0 0 20 20" className="mr-w-5 mr-h-5" />
111+
<SvgSymbol sym="trash-icon" viewBox="0 0 20 20" className="mr-w-4 mr-h-4" />
108112
</span>
109113
)}
110114
</button>
@@ -114,12 +118,19 @@ export const CustomArrayFieldTemplate = (props) => {
114118
));
115119

116120
return (
117-
<div className="array-field">
118-
{props.title && <label className="control-label">{props.title}</label>}
119-
{itemFields}
121+
<div className="array-field" style={{ marginBottom: "0.5rem" }}>
122+
{props.title && (
123+
<label className="control-label mr-text-sm" style={{ marginBottom: "0.25rem" }}>
124+
{props.title}
125+
</label>
126+
)}
127+
<div style={{ marginBottom: "0.25rem" }}>{itemFields}</div>
120128
{props.canAdd && (
121-
<div className="array-field__block-controls">
122-
<button className="mr-button mr-button--small" onClick={props.onAddClick}>
129+
<div className="array-field__block-controls" style={{ marginTop: "0.25rem" }}>
130+
<button
131+
className="mr-button mr-button--small mr-py-1 mr-px-2 mr-text-sm"
132+
onClick={props.onAddClick}
133+
>
123134
{addLabel}
124135
</button>
125136
</div>
@@ -132,31 +143,31 @@ export const CustomFieldTemplate = function (props) {
132143
const { classNames, children, description, uiSchema, errors } = props;
133144
const isCollapsed = uiSchema?.["ui:collapsed"] ?? false;
134145
return (
135-
<div className={classNames}>
146+
<div className={classNames} style={{ marginBottom: "0.5rem" }}>
136147
{uiSchema?.["ui:groupHeader"] && (
137-
<div className="mr-flex mr-justify-end mr-text-teal mr-text-lg mr-pt-4 mr-my-4 mr-border-t mr-border-teal-40">
148+
<div className="mr-flex mr-justify-end mr-text-teal mr-text-sm mr-pt-2 mr-my-1 mr-border-t mr-border-teal-40">
138149
<span>{uiSchema["ui:groupHeader"]}</span>
139150
{uiSchema?.["ui:toggleCollapsed"] && (
140151
<button type="button" onClick={() => uiSchema["ui:toggleCollapsed"]()}>
141152
<SvgSymbol
142153
sym={isCollapsed ? "icon-cheveron-right" : "icon-cheveron-down"}
143154
viewBox="0 0 20 20"
144-
className="mr-fill-green-lighter mr-w-6 mr-h-6 mr-ml-2"
155+
className="mr-fill-green-lighter mr-w-4 mr-h-4 mr-ml-1"
145156
/>
146157
</button>
147158
)}
148159
</div>
149160
)}
150161
{uiSchema?.["ui:fieldGroupHeader"] && uiSchema["ui:toggleCollapsed"] && (
151162
<div
152-
className="mr-flex mr-text-mango mr-uppercase mr-text-md mr-mb-2 mr-cursor-pointer"
163+
className="mr-flex mr-text-mango mr-uppercase mr-text-sm mr-mb-0.5 mr-cursor-pointer"
153164
onClick={() => uiSchema["ui:toggleCollapsed"]()}
154165
>
155166
<span>{uiSchema["ui:fieldGroupHeader"]}</span>
156167
<SvgSymbol
157168
sym={isCollapsed ? "icon-cheveron-right" : "icon-cheveron-down"}
158169
viewBox="0 0 20 20"
159-
className="mr-fill-green-lighter mr-w-6 mr-h-6 mr-ml-2"
170+
className="mr-fill-green-lighter mr-w-4 mr-h-4 mr-ml-1"
160171
/>
161172
</div>
162173
)}
@@ -206,16 +217,16 @@ export const CustomSelectWidget = function (props) {
206217

207218
export const CustomCheckboxField = function (props) {
208219
return (
209-
<div className="mr-space-y-4">
210-
<p className="mr-text-mango mr-text-md mr-uppercase">
220+
<div className="mr-space-y-2">
221+
<p className="mr-text-mango mr-text-sm mr-uppercase">
211222
{props.schema.title}
212223
{props.required && <span className="mr-text-red-light mr-ml-1">*</span>}
213224
</p>
214-
<div className="mr-bg-blue-firefly-75 mr-pt-4 mr-px-4 mr-pb-6 mr-rounded">
225+
<div className="mr-bg-blue-firefly-75 mr-pt-2 mr-px-3 mr-pb-4 mr-rounded">
215226
<MarkdownContent markdown={props.schema.agreementDescription} lightMode={false} />
216-
<div className="mr-items-center mr-flex mr-space-x-2">
227+
<div className="mr-items-center mr-flex mr-space-x-1">
217228
<OriginalCheckboxWidget {...props} label="" />
218-
<p className="mr-text-mango mr-text-sm">
229+
<p className="mr-text-mango mr-text-xs">
219230
<FormattedMessage {...props.schema.checkboxLabel} />
220231
</p>
221232
</div>
@@ -250,21 +261,22 @@ export const ColumnRadioField = function (props) {
250261
<Fragment>
251262
<LabelWithHelp {...props} />
252263
{props.schema.enum.map((option, index) => (
253-
<div key={option} className="mr-flex mr-items-center mr-my-2">
264+
<div key={option} className="mr-flex mr-items-center mr-my-1">
254265
<input
255266
id={props.schema.enumNames ? props.schema.enumNames[index] : props.schema.enum[index]}
256267
type="radio"
257268
name={props.name}
258269
value={option}
259270
checked={props.formData === option}
260-
className="mr-radio mr-mr-2"
271+
className="mr-radio mr-mr-1"
261272
onChange={() => props.onChange(option)}
262273
/>
263274
<label
264275
htmlFor={
265276
props.schema.enumNames ? props.schema.enumNames[index] : props.schema.enum[index]
266277
}
267278
onClick={() => props.onChange(option)}
279+
className="mr-text-sm"
268280
>
269281
<MarkdownContent
270282
compact
@@ -289,11 +301,11 @@ export const MarkdownEditField = (props) => {
289301
return (
290302
<Fragment>
291303
<LabelWithHelp {...props} />
292-
<div className="mr-flex mr-items-center mr-mb-2 mr-leading-tight mr-text-xxs">
304+
<div className="mr-flex mr-items-center mr-mb-1 mr-leading-tight mr-text-xxs">
293305
<button
294306
type="button"
295307
className={classNames(
296-
"mr-pr-2 mr-mr-2 mr-border-r mr-border-green mr-uppercase mr-font-medium",
308+
"mr-pr-1 mr-mr-1 mr-border-r mr-border-green mr-uppercase mr-font-medium",
297309
showingPreview ? "mr-text-green-lighter" : "mr-text-white",
298310
)}
299311
onClick={() => setShowingPreview(false)}
@@ -315,15 +327,15 @@ export const MarkdownEditField = (props) => {
315327
{showingPreview ? (
316328
<Fragment>
317329
{props.uiSchema["ui:previewNote"] && (
318-
<div className="mr-text-sm mr-text-grey-light mr-italic">
330+
<div className="mr-text-xs mr-text-grey-light mr-italic">
319331
{props.uiSchema["ui:previewNote"]}
320332
</div>
321333
)}
322334
<div
323335
className={
324336
props.previewClassName
325337
? props.previewClassName
326-
: "mr-rounded mr-bg-black-15 mr-px-2 mr-py-1 mr-min-h-8"
338+
: "mr-rounded mr-bg-black-15 mr-px-2 mr-py-1 mr-min-h-6"
327339
}
328340
>
329341
<MarkdownContent
@@ -342,7 +354,7 @@ export const MarkdownEditField = (props) => {
342354
</Fragment>
343355
) : (
344356
<textarea
345-
className="form-control mr-font-mono mr-text-sm"
357+
className="form-control mr-font-mono mr-text-xs"
346358
onChange={(e) => props.onChange(e.target.value)}
347359
value={props.formData}
348360
/>
@@ -385,7 +397,7 @@ export const DropzoneTextUpload = ({ id, onChange, readonly, formContext, dropAr
385397

386398
if (readonly && idRequirements) {
387399
return (
388-
<div className="readonly-file mr-text-pink">
400+
<div className="readonly-file mr-text-pink mr-text-xs">
389401
<FormattedMessage {...messages.readOnlyFile} />
390402
</div>
391403
);
@@ -409,7 +421,7 @@ export const DropzoneTextUpload = ({ id, onChange, readonly, formContext, dropAr
409421
if (!fileName.endsWith(".geojson") && !fileName.endsWith(".json")) {
410422
acceptedFiles.pop();
411423
setUploadErrorText(
412-
<span className="mr-mr-4 mr-text-red-light mr-ml-1">
424+
<span className="mr-mr-3 mr-text-red-light mr-ml-1 mr-text-xs">
413425
{idRequirements ? (
414426
<FormattedMessage {...messages.uploadErrorGeoJSON} />
415427
) : (
@@ -421,7 +433,7 @@ export const DropzoneTextUpload = ({ id, onChange, readonly, formContext, dropAr
421433
}
422434
const body =
423435
acceptedFiles.length > 0 ? (
424-
<p>
436+
<p className="mr-text-sm">
425437
{acceptedFiles[0].name}
426438
<input {...getInputProps()} />
427439
</p>
@@ -430,7 +442,7 @@ export const DropzoneTextUpload = ({ id, onChange, readonly, formContext, dropAr
430442
<SvgSymbol
431443
viewBox="0 0 20 20"
432444
sym="upload-icon"
433-
className="mr-fill-current mr-w-3 mr-h-3 mr-mr-4"
445+
className="mr-fill-current mr-w-3 mr-h-3 mr-mr-2"
434446
/>
435447
{uploadErrorText}
436448
{idRequirements ? (
@@ -447,7 +459,7 @@ export const DropzoneTextUpload = ({ id, onChange, readonly, formContext, dropAr
447459
className={
448460
dropAreaClassName
449461
? dropAreaClassName
450-
: "dropzone mr-text-grey-lighter mr-p-4 mr-border-2 mr-rounded mr-mx-auto"
462+
: "dropzone mr-text-grey-lighter mr-p-3 mr-border-2 mr-rounded mr-mx-auto mr-text-xs"
451463
}
452464
{...getRootProps()}
453465
>
@@ -468,7 +480,7 @@ export const MarkdownDescriptionField = ({ id, description }) => {
468480
}
469481

470482
return (
471-
<div id={id} className="mr-text-grey-light mr-my-2">
483+
<div id={id} className="mr-text-grey-light mr-my-1 mr-text-xs">
472484
<MarkdownContent compact markdown={description} lightMode={false} />
473485
</div>
474486
);
@@ -488,15 +500,14 @@ export const LabelWithHelp = (props) => {
488500
const normalizedHelp = rawHelp ? rawHelp : uiSchema["ui:help"];
489501

490502
return (
491-
<div className="mr-mb-2 mr-flex">
503+
<div className="mr-mb-0.5 mr-flex">
492504
<label
493505
htmlFor={id}
494-
className={
495-
control ? "mr-text-base mr-text-mango" : "mr-text-mango mr-text-md mr-uppercase mr-mb-2"
496-
}
506+
className={control ? "mr-text-sm mr-text-mango" : "mr-text-mango mr-text-sm mr-uppercase"}
507+
style={{ marginBottom: "0" }}
497508
>
498509
{normalizedLabel}
499-
{required && <span className="mr-text-red-light mr-ml-1">*</span>}
510+
{required && <span className="mr-text-red-light mr-ml-0.5">*</span>}
500511
</label>
501512
{!_isEmpty(normalizedHelp) && (
502513
<Dropdown
@@ -506,17 +517,17 @@ export const LabelWithHelp = (props) => {
506517
<button
507518
type="button"
508519
onClick={dropdown.toggleDropdownVisible}
509-
className="mr-ml-4 mr-flex"
520+
className="mr-ml-2 mr-flex"
510521
>
511522
<SvgSymbol
512523
sym="info-icon"
513524
viewBox="0 0 20 20"
514-
className="mr-fill-green-lighter mr-w-4 mr-h-4"
525+
className="mr-fill-green-lighter mr-w-3 mr-h-3"
515526
/>
516527
</button>
517528
)}
518529
dropdownContent={() => (
519-
<div className="mr-w-96 mr-max-w-screen60 mr-whitespace-normal">
530+
<div className="mr-w-72 mr-max-w-screen60 mr-whitespace-normal">
520531
<MarkdownContent markdown={normalizedHelp} lightMode={false} />
521532
</div>
522533
)}

0 commit comments

Comments
 (0)