Skip to content

Commit

Permalink
fix: align styles & remove unnecessary name prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
felixmosh committed Mar 11, 2024
1 parent 3a0867d commit a98367a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 31 deletions.
31 changes: 19 additions & 12 deletions packages/ui/src/components/JobCard/JobCard.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
border-radius: 0.25rem;
padding: 1em;
display: flex;
flex-direction: column;
max-height: 500px;
}

Expand All @@ -26,22 +27,18 @@
border-bottom: 1px solid #e2e8f0;
}

.attempts {
margin-left: '0.5rem'
}

.title h4,
.title h5,
.sideInfo span {
font-size: 1.44rem;
font-size: 1.2rem;
font-weight: 300;
color: #4a5568;
line-height: 1;
}

.title h4 span {
margin-left: 1.5rem;
.title h5 span {
margin-left: 1rem;
color: #a0aec0;
font-size: 0.694em;
font-size: 0.833em;
}

.header {
Expand All @@ -51,6 +48,12 @@
align-items: center;
}

.header h4 {
font-size: 1.2rem;
font-weight: 300;
color: #4a5568;
}

.details {
display: flex;
margin-top: 1rem;
Expand All @@ -77,7 +80,7 @@
}

.collapseBtn {
padding: 0.15rem;
padding: 0.25rem 0.5rem;
}

.content {
Expand All @@ -93,6 +96,10 @@
}

.jobLink {
color: #4a5568;
font-size: large;
color: inherit;
text-decoration: none;
}

.jobLink:hover {
text-decoration: underline;
}
38 changes: 21 additions & 17 deletions packages/ui/src/components/JobCard/JobCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,28 @@ export const JobCard = ({

const [localCollapse, setLocalCollapse] = React.useState<boolean>();

const isExpandedCard = !jobUrl || (localCollapse || !collapseJob);

const JobTitle = <h4 title={`#${job.id}`}>#{job.id}</h4>;
const isExpandedCard = !jobUrl || localCollapse || !collapseJob;
const showCollapseExpandBtn = collapseJob && jobUrl;
const JobTitle = (
<h4>
{/^\d+$/.test(`${job.id}`) ? '#' : ''}
{job.id}
</h4>
);

return (
<Card className={s.card}>
<Collapsible.Root style={{ width: '100%' }} open={isExpandedCard}>
<Collapsible.Root asChild={true} open={isExpandedCard}>
<Card className={s.card}>
<div className={s.header}>
{jobUrl ? (
<Link className={s.jobLink} to={jobUrl}>
{JobTitle}
</Link>
) : JobTitle}
) : (
JobTitle
)}

{jobUrl && (
{showCollapseExpandBtn && (
<Button className={s.collapseBtn} onClick={() => setLocalCollapse(!isExpandedCard)}>
{isExpandedCard ? <ArrowUpIcon /> : <ArrowDownIcon />}
</Button>
Expand All @@ -74,13 +81,8 @@ export const JobCard = ({
<div className={s.contentWrapper}>
<div className={s.title}>
<h5>
{t('JOB.NAME')}: {job.name}
{job.attempts > 1 && (
<span className={s.attempts}>
- {t('JOB.ATTEMPTS', { attempts: job.attempts })}
</span>
)}

{job.name}
{job.attempts > 1 && <span>{t('JOB.ATTEMPTS', { attempts: job.attempts })}</span>}
{!!job.opts?.repeat?.count && (
<span>
{t(`JOB.REPEAT${!!job.opts?.repeat?.limit ? '_WITH_LIMIT' : ''}`, {
Expand All @@ -103,7 +105,9 @@ export const JobCard = ({
<Progress
percentage={job.progress}
status={
job.isFailed && !greenStatuses.includes(status as any) ? STATUSES.failed : status
job.isFailed && !greenStatuses.includes(status as any)
? STATUSES.failed
: status
}
className={s.progress}
/>
Expand All @@ -112,7 +116,7 @@ export const JobCard = ({
</div>
</div>
</Collapsible.Content>
</Collapsible.Root>
</Card>
</Card>
</Collapsible.Root>
);
};
1 change: 0 additions & 1 deletion packages/ui/src/static/locales/en-US/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"JOBS_COUNT": "{{count}} Jobs"
},
"JOB": {
"NAME": "Name",
"NOT_FOUND": "Job Not found",
"STATUS": "Status: {{status}}",
"ADDED_AT": "Added at",
Expand Down
1 change: 0 additions & 1 deletion packages/ui/src/static/locales/pt-BR/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"JOBS_COUNT": "{{count}} Tarefas"
},
"JOB": {
"NAME": "Nome",
"NOT_FOUND": "Tarefa não encontrada",
"STATUS": "Status: {{status}}",
"ADDED_AT": "Adicionado em",
Expand Down

0 comments on commit a98367a

Please sign in to comment.