Skip to content

Commit f3cbda9

Browse files
Muhammad Faraz  MaqsoodMuhammad Faraz  Maqsood
authored andcommitted
refactor: move inline styling class-based styles
1 parent f2dfd8c commit f3cbda9

File tree

6 files changed

+69
-50
lines changed

6 files changed

+69
-50
lines changed

src/CourseTeamManagement/CoursesTable.jsx

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -266,14 +266,6 @@ export default function CoursesTable({
266266
data-testid={`role-dropdown-${courseId}`}
267267
variant="outline-primary"
268268
disabled={isDisabled}
269-
style={{
270-
display: 'flex',
271-
alignItems: 'center',
272-
justifyContent: 'space-between',
273-
padding: '2px 8px',
274-
width: '95px',
275-
borderRadius: '6px',
276-
}}
277269
>
278270
<span>{title}</span>
279271
<ArrowDropDown className="ml-2" />
@@ -326,7 +318,7 @@ export default function CoursesTable({
326318
checked={allChecked}
327319
onChange={handleHeaderCheckboxChange}
328320
aria-label="Select all rows"
329-
style={{ marginLeft: 8 }}
321+
className="ml-2"
330322
/>
331323
);
332324
// eslint-disable-next-line react/no-unstable-nested-components
@@ -336,7 +328,7 @@ export default function CoursesTable({
336328
checked={!!checkedRows[row.original.course_id]}
337329
onChange={() => handleCheckboxChange(row.original.course_id)}
338330
aria-label={`Select row for ${row.original.course_name}`}
339-
style={{ marginLeft: 8 }}
331+
className="ml-2"
340332
/>
341333
);
342334
const sortableHeader = (id, label) => (
@@ -426,7 +418,7 @@ export default function CoursesTable({
426418
getRowId={(row) => row.course_id}
427419
>
428420
<DataTable.TableControlBar />
429-
<div style={{ height: 450, overflow: 'auto' }}>
421+
<div className="course-team-table-content-size">
430422
{sortedAndFilteredData.length > 0 && <DataTable.Table />}
431423
{sortedAndFilteredData.length === 0 && (
432424
<div className="pgn__data-table-empty">{intl.formatMessage(messages.noResultsFoundForTable)}</div>
@@ -439,7 +431,7 @@ export default function CoursesTable({
439431
onClick={() => setShowModal(true)}
440432
disabled={!isSaveBtnEnabled}
441433
variant="danger"
442-
style={{ width: '8%' }}
434+
className="save-changes-btn"
443435
data-testid="save-course-changes"
444436
>
445437
{intl.formatMessage(messages.saveButtonLabel)}

src/CourseTeamManagement/OrgDropdownWithSearch.jsx

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,14 @@ const OrgDropdownWithSearch = ({ org, setOrg, orgFilterChoices }) => {
2626
}, []);
2727

2828
return (
29-
<div ref={dropdownRef} style={{ position: 'relative' }} className="ml-2">
29+
<div ref={dropdownRef} className="course-team-table-org-filter ml-2">
3030
<Button
3131
variant="outline-primary"
3232
className="w-100 text-start d-flex justify-content-between align-items-center"
3333
onClick={() => setIsOpen((prev) => !prev)}
3434
data-testid="org-dropdown-toggle"
3535
>
36-
<span
37-
style={{
38-
whiteSpace: 'nowrap',
39-
overflow: 'hidden',
40-
textOverflow: 'ellipsis',
41-
marginRight: 8,
42-
}}
43-
>
36+
<span className="course-team-table-org-filter-btn">
4437
{org
4538
? orgFilterChoices.find((c) => c.value === org)?.name
4639
: intl.formatMessage(messages.allOrgsFilterLabel)}
@@ -49,17 +42,7 @@ const OrgDropdownWithSearch = ({ org, setOrg, orgFilterChoices }) => {
4942
</Button>
5043

5144
{isOpen && (
52-
<div
53-
className="border rounded-sm bg-white"
54-
style={{
55-
position: 'absolute',
56-
top: '50px',
57-
zIndex: 1000,
58-
width: '250%',
59-
maxHeight: 250,
60-
overflowY: 'auto',
61-
}}
62-
>
45+
<div className="border rounded-sm bg-white course-team-table-org-filter-menu-container">
6346
<Form.Control
6447
type="text"
6548
placeholder={intl.formatMessage(messages.searchPlaceholder)}

src/CourseTeamManagement/SortableHeader.jsx

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ArrowDropDown, ArrowDropUpDown } from '@openedx/paragon/icons';
1+
import { ArrowDropDown, ArrowDropUpDown, ArrowDropUp } from '@openedx/paragon/icons';
22
import { useIntl } from '@edx/frontend-platform/i18n';
33
import PropTypes from 'prop-types';
44

@@ -10,7 +10,7 @@ const SortableHeader = ({
1010
}) => {
1111
const intl = useIntl();
1212
const isSorted = sortBy[0]?.id === id;
13-
const isDesc = sortBy[0]?.desc;
13+
const isAscending = sortBy[0]?.desc;
1414

1515
const handleClick = () => {
1616
setSortBy((prev) => {
@@ -26,22 +26,15 @@ const SortableHeader = ({
2626

2727
let SortIcon = <ArrowDropUpDown data-testid={`sort-icon-${id}`} onClick={handleClick} />;
2828
if (isSorted) {
29-
if (isDesc) {
30-
SortIcon = <ArrowDropDown onClick={handleClick} style={{ transform: 'rotate(180deg)' }} />;
29+
if (isAscending) {
30+
SortIcon = <ArrowDropUp onClick={handleClick} />;
3131
} else {
3232
SortIcon = <ArrowDropDown data-testid={`ascending-sort-icon-${id}`} onClick={handleClick} />;
3333
}
3434
}
3535

3636
return (
37-
<div
38-
style={{
39-
cursor: 'pointer',
40-
display: 'flex',
41-
alignItems: 'center',
42-
gap: 4,
43-
}}
44-
>
37+
<div className="sorted-header">
4538
{intl.formatMessage(label)}
4639
{SortIcon}
4740
</div>

src/CourseTeamManagement/TableActions.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const TableActions = ({
5050
(
5151
<span className="d-flex align-items-center">
5252
{intl.formatMessage(statusLabelMessage)}
53-
<Icon style={{ marginLeft: 8 }} src={ArrowDropDown} />
53+
<Icon className="ml-2" src={ArrowDropDown} />
5454
</span>
5555
)
5656
}
@@ -87,7 +87,7 @@ const TableActions = ({
8787
(
8888
<span className="d-flex align-items-center">
8989
{intl.formatMessage(messages.statusActionsFilterLabel)}
90-
<Icon style={{ marginLeft: 8 }} src={ArrowDropDown} />
90+
<Icon className="ml-2" src={ArrowDropDown} />
9191
</span>
9292
)
9393
}

src/CourseTeamManagement/index.scss

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@
3131
justify-content: center;
3232
height: 50vh;
3333
color: '#003057';
34+
35+
h3 {
36+
font-weight: 600;
37+
margin-bottom: 8px
38+
}
39+
40+
p {
41+
color: #495057;
42+
font-size: 18px;
43+
text-align: center;
44+
}
3445
}
3546

3647
.course-team-management-courses-table {
@@ -117,6 +128,42 @@
117128
.pgn__data-table-empty {
118129
margin-left: 8px;
119130
}
131+
132+
.save-changes-btn {
133+
width: 96px;
134+
}
135+
136+
.course-team-table-org-filter {
137+
position: relative;
138+
139+
.course-team-table-org-filter-btn {
140+
white-space: nowrap;
141+
overflow: 'hidden';
142+
text-overflow: 'ellipsis';
143+
margin-right: 8px;
144+
}
145+
146+
.course-team-table-org-filter-menu-container {
147+
position: absolute;
148+
top: 50px;
149+
z-index: 1000;
150+
width: 320px;
151+
max-height: 250px;
152+
overflow-y: auto;
153+
}
154+
}
155+
}
156+
157+
.sorted-header {
158+
cursor: pointer;
159+
display: flex;
160+
align-items: center;
161+
gap: 4px,
162+
}
163+
164+
.course-team-table-content-size {
165+
overflow: auto;
166+
height: 450px;
120167
}
121168

122169
.custom-table-actions-container {
@@ -145,6 +192,12 @@
145192
height: 32px;
146193
border: 1px solid var(--Light-200, #F3F1ED);
147194
border-color: var(--Light-200, #F3F1ED);
195+
display: flex;
196+
align-items: center;
197+
justify-content: space-between;
198+
padding: 2px 8px;
199+
width: 95px;
200+
border-radius: 6px;
148201
}
149202

150203
.course-team-management-role-col-dropdown::after {

src/users/UserPage.jsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,8 @@ export default function UserPage({
202202
{loading && <PageLoading srMessage="Loading" />}
203203
{showNoUserSelectedDescription && (
204204
<div className="course-team-management-no-user-selected">
205-
<h3 style={{ fontWeight: 600, marginBottom: 8 }}>{intl.formatMessage(messages.noUserSelected)}</h3>
206-
<p style={{ color: '#495057', fontSize: 18, textAlign: 'center' }}>
207-
{intl.formatMessage(messages.noUserSelectedDescription)}
208-
</p>
205+
<h3>{intl.formatMessage(messages.noUserSelected)}</h3>
206+
<p>{intl.formatMessage(messages.noUserSelectedDescription)}</p>
209207
</div>
210208
)}
211209
{isOnCourseTeamPage && !loading && data?.user && userCourses.length > 0

0 commit comments

Comments
 (0)