Skip to content

Commit

Permalink
Code clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
s1lva committed Oct 10, 2024
1 parent 9b7686e commit 793f541
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 28 deletions.
31 changes: 3 additions & 28 deletions src/lib/components/PublicProfile.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,11 @@
import { ThumbsUp } from 'lucide-svelte'; // For praises
import { Progress } from '$lib/components/ui/progress';
import { Button } from '$lib/components/ui/button';
// Define the type for userData
interface UserData {
links: { title: string; url: string }[];
skills: { title: string; level: string }[];
repoCount: number;
contributionsCount: number;
pfp: string;
praises: number;
username: string;
}
import type { PublicProfile } from '$lib/types/PublicProfile';
import { getProgressValue } from '$lib/utils/getProgressValue';
// Accept userData as a prop
export let userData: UserData;
// Function to convert skill level (string) into percentage for progress bar
const getProgressValue = (level: string): number => {
const levels: { [key: string]: number } = {
'1': 20,
'2': 40,
'3': 60,
'4': 80,
'5': 100
};
return levels[level] || 0;
};
export let userData: PublicProfile;
</script>

<!-- Main Profile Content -->
Expand Down Expand Up @@ -158,7 +137,3 @@
</div>
</main>
</div>

<style>
/* Additional styling if needed */
</style>
9 changes: 9 additions & 0 deletions src/lib/types/PublicProfile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export interface PublicProfile {
links: { title: string; url: string }[];
skills: { title: string; level: string }[];
repoCount: number;
contributionsCount: number;
pfp: string | null;
praises: number;
username: string;
}
11 changes: 11 additions & 0 deletions src/lib/utils/getProgressValue.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Function to convert skill level (string) into percentage for progress bar
export const getProgressValue = (level: string): number => {
const levels: { [key: string]: number } = {
'1': 20,
'2': 40,
'3': 60,
'4': 80,
'5': 100
};
return levels[level] || 0;
};

0 comments on commit 793f541

Please sign in to comment.