Skip to content
This repository was archived by the owner on May 4, 2023. It is now read-only.

Commit 819649a

Browse files
chore: made some reusable components
1 parent be84609 commit 819649a

File tree

10 files changed

+117
-0
lines changed

10 files changed

+117
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { Flex, Text } from '@chakra-ui/react';
2+
import { Avatar } from '@codiga/components';
3+
import { PublicUser } from '../../types/userTypes';
4+
import { getAvatarUrl } from '../../utils/userUtils';
5+
import UserLink from '../UserLink';
6+
7+
type AvatarAndNameProps = {
8+
owner?: PublicUser;
9+
};
10+
11+
export default function AvatarAndName({ owner = {} }: AvatarAndNameProps) {
12+
return (
13+
<Flex alignItems="center" gap="space_8">
14+
<Avatar
15+
size="xs"
16+
name={owner?.displayName || 'Anonymous'}
17+
src={getAvatarUrl({ id: owner?.id })}
18+
/>
19+
<Text
20+
size="xs"
21+
noOfLines={1}
22+
maxW="300px"
23+
display="inline-block"
24+
whiteSpace="nowrap"
25+
>
26+
<UserLink owner={owner} />
27+
</Text>
28+
</Flex>
29+
);
30+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from './AvatarAndName';
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { IconButton } from '@chakra-ui/react';
2+
import { ChevronLeftIcon } from '@codiga/components';
3+
import { useNavigate } from 'react-router-dom';
4+
5+
export default function BackButton() {
6+
const navigate = useNavigate();
7+
8+
return (
9+
<IconButton
10+
variant="ghost"
11+
onClick={() => navigate(-1)}
12+
h="28px"
13+
minW="28px"
14+
fontSize="12px"
15+
icon={<ChevronLeftIcon />}
16+
aria-label="go back"
17+
/>
18+
);
19+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from './BackButton';
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Flex, Text } from '@chakra-ui/react';
2+
3+
type FormattedDateProps = {
4+
timestamp: number;
5+
};
6+
7+
export default function FormattedDate({ timestamp }: FormattedDateProps) {
8+
return (
9+
<Flex alignItems="center" gap="space_8">
10+
<Text size="xs" noOfLines={1}>
11+
{new Date(timestamp).toDateString()}
12+
</Text>
13+
</Flex>
14+
);
15+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from './FormattedDate';
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { Flex, Text } from '@chakra-ui/react';
2+
import { LockIcon } from '@codiga/components';
3+
import VotesCurrent from '../VotesCurrent';
4+
5+
type PrivacyAndNotesProps = {
6+
isPublic?: boolean;
7+
upvotes?: number;
8+
downvotes?: number;
9+
};
10+
11+
export default function PrivacyAndVotes({
12+
isPublic = true,
13+
upvotes = 0,
14+
downvotes = 0,
15+
}: PrivacyAndNotesProps) {
16+
return (
17+
<Flex alignItems="center" gap="space_8">
18+
<Text
19+
size="xs"
20+
noOfLines={1}
21+
gridGap="space_4"
22+
d="flex"
23+
alignItems="center"
24+
>
25+
<LockIcon open={!!isPublic} />
26+
{isPublic ? 'Public' : 'Private'}
27+
</Text>
28+
<VotesCurrent upvotes={upvotes} downvotes={downvotes} />
29+
</Flex>
30+
);
31+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from './PrivacyAndVotes';

src/renderer/components/Uses/Uses.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { Flex, Text } from '@chakra-ui/react';
2+
import { CodeIcon } from '@codiga/components';
3+
4+
type UsesProps = {
5+
count?: number;
6+
};
7+
8+
export default function Uses({ count = 0 }: UsesProps) {
9+
return (
10+
<Flex alignItems="center" gap="space_8">
11+
<CodeIcon />
12+
<Text size="xs" noOfLines={1}>
13+
{count}
14+
</Text>
15+
</Flex>
16+
);
17+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from './Uses';

0 commit comments

Comments
 (0)