Skip to content

Commit 7bcf46c

Browse files
committed
feat: add null states
1 parent e328a70 commit 7bcf46c

File tree

3 files changed

+33
-11
lines changed

3 files changed

+33
-11
lines changed

client/components/story/story-description.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,19 @@ const DescripTitle = styled.div`
1515
line-height: 1.31;
1616
`;
1717

18-
const DescripBody = styled.div`
18+
interface BodyProps {
19+
noDescrip?: boolean;
20+
}
21+
22+
const DescripBody = styled.div<BodyProps>`
1923
color: ${colors.warmGrey};
2024
font-size: ${fontSizes.large};
2125
margin-bottom: 18px;
2226
white-space: pre-wrap;
2327
font-style: normal;
2428
line-height: 1.33;
2529
margin-bottom: 32px;
30+
opacity: ${props => (props.noDescrip ? '0.5' : '1')};
2631
`;
2732

2833
export const Divider = () => (
@@ -31,16 +36,21 @@ export const Divider = () => (
3136
</svg>
3237
);
3338

34-
interface BodyProps {
39+
interface DescripProps {
3540
title: string;
3641
text: string;
3742
}
3843

39-
const Description = ({ title, text }: BodyProps) => {
44+
const Description = ({ title, text }: DescripProps) => {
4045
return (
4146
<DescripWrapper>
4247
<DescripTitle>{title}</DescripTitle>
43-
<DescripBody>{text}</DescripBody>
48+
{text !== null && text !== '' ? (
49+
<DescripBody>{text}</DescripBody>
50+
) : (
51+
<DescripBody noDescrip>There's no description for this story yet.</DescripBody>
52+
)}
53+
4454
<Divider />
4555
</DescripWrapper>
4656
);

client/components/story/story-tasks.tsx

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@ import styled from 'styled-components';
33
import { colors, fontSizes, spacing } from '~lib/theme';
44
import { Task as TaskType } from '~components/projects/types';
55

6-
const TaskTitle = styled.div`
6+
interface TitleProps {
7+
noTasks?: boolean;
8+
}
9+
10+
const TaskTitle = styled.div<TitleProps>`
711
font-size: ${fontSizes.large};
812
color: ${colors.warmGrey};
913
margin-bottom: 20px;
14+
opacity: ${props => (props.noTasks ? '0.5' : '1')};
1015
`;
1116

1217
interface TaskDescripProps {
@@ -41,12 +46,18 @@ interface TasksProps {
4146
const Tasks = ({ tasks }: TasksProps) => {
4247
return (
4348
<TaskWrapper>
44-
<TaskTitle>Tasks</TaskTitle>
45-
<ul>
46-
{tasks.map(task => (
47-
<TaskDescrip completed={task.complete}>{task.description}</TaskDescrip>
48-
))}
49-
</ul>
49+
{tasks.length !== 0 ? (
50+
<>
51+
<TaskTitle>Tasks</TaskTitle>
52+
<TaskList>
53+
{tasks.map(task => (
54+
<TaskDescrip completed={task.complete}>{task.description}</TaskDescrip>
55+
))}
56+
</TaskList>
57+
</>
58+
) : (
59+
<TaskTitle noTasks>No tasks</TaskTitle>
60+
)}
5061
</TaskWrapper>
5162
);
5263
};

client/components/story/story.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const Story = ({ data }: StoryProps) => {
3232
const { id, name, description, storyType, comments, tasks, labels, estimate } = data;
3333
return (
3434
<>
35+
{console.log(labels)}
3536
<StoryWrapper>
3637
<Details id={id} type={storyType} labels={labels} />
3738
<Description title={name} text={description} />

0 commit comments

Comments
 (0)