Skip to content

Commit

Permalink
fix dummy data generator
Browse files Browse the repository at this point in the history
  • Loading branch information
gskorokhod committed Jul 23, 2024
1 parent fe62875 commit 3ea98be
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/lib/components/elements/skill/skill-badge.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
class="flex flex-row items-center justify-start w-max h-fit gap-2 pr-3 px-2 py-1 rounded-full outline-none outline-offset-0 transition-all hover:outline-accent-foreground {monochrome && 'bg-accent text-accent-foreground'}"
style={(skill.icon.color && !monochrome) ? `background-color: ${color_hex}; color: ${text_color_hex}` : ""}>
<Icon icon={skill.icon} variant="monochrome"
class="h-5 w-5 rounded-full bg-transparent" />
class="h-5 w-5 rounded-full bg-transparent opacity-70" />
{capitalize(skill.name)}
</div>
{/if}
Expand Down
1 change: 0 additions & 1 deletion src/lib/components/elements/task/task-card.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

<div class="group/task-card w-full p-2 flex flex-col bg-accent border-0 border-l-4 border-l-accent-foreground">
<h3 class="ml-1 mb-2 font-semibold text-lg inline-flex flex-row justify-start items-center gap-2">
<Icon icon={task.icon} variant="monochrome" class="text-muted-foreground" />
{capitalize(task.name)}
</h3>

Expand Down
13 changes: 7 additions & 6 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,15 @@ export function sampleOne<T>(arr: T[]): T {
export function sample<T>(arr: T[], n: number, unique: boolean = true): T[] {
const ans: T[] = [];

for (let i = 0; i < n; i++) {
let el: T = sampleOne(arr);
if (n >= arr.length) return arr;

while (!unique || !ans.includes(el)) {
el = sampleOne(arr);
for (let i = 0; i < n; i++) {
if (unique) {
const remaining: T[] = arr.filter((e) => !ans.includes(e));
ans.push(sampleOne(remaining));
} else {
ans.push(sampleOne(arr));
}

ans.push(el);
}

return ans;
Expand Down

0 comments on commit 3ea98be

Please sign in to comment.