Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter entries by language type in onefetch.dev #1227

Merged
merged 12 commits into from
Dec 11, 2023

Conversation

o2sh
Copy link
Owner

@o2sh o2sh commented Dec 10, 2023

related to #1208

Implementing a simple filtering option to make language type information more accessible to users.

@spenserblack, I'm not particularly skilled in UI/UX (or Svelte) 😅 . Feel free to be honest and share your thoughts 🙏

@o2sh o2sh added the feat label Dec 10, 2023
@o2sh o2sh requested a review from spenserblack December 10, 2023 14:28
@o2sh o2sh changed the title Filter by language type in onefetch.dev Filter entries by language type in onefetch.dev Dec 10, 2023
Copy link
Collaborator

@spenserblack spenserblack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just some nitpicks mostly.

The one big thing that I'm wondering is if if makes sense to have "programming" and "markup" be checked by default. This could help hint to what onefetch's defaults are. Perhaps a "reset to default" button could help illustrate this? Though that's a bit of overkill for 4 checkboxes 😆

I see you've written the checkboxes to be dynamic by utilizing a Set<string> instead of hard-coding. But, to set default checked values, I think you can't get around doing a little bit of hard-coding. But, given how infrequently the language types are likely to change, I think it's OK to do a bit of hard-coding 🙂

docs/vercel/src/Index.svelte Outdated Show resolved Hide resolved
Comment on lines 85 to 101
<div class="title">
<h3>Languages <small>({$filteredLanguages.length})</small></h3>
<button class="filter-button" on:click={() => (menuOpen = !menuOpen)}
>Filter by type</button>
</div>

<div class:show={!menuOpen} class="checkbox-group">
{#each languageTypes as type}
<label for={type}>
<input
id={type}
type="checkbox"
value={type}
bind:group={$filter.checkboxes} />
{type}
</label>
{/each}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH I wonder if the filters really need to be shown/hidden, since they don't take up much space.

Copy link
Owner Author

@o2sh o2sh Dec 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's now shown by default.

Comment on lines 25 to 37
const filter = writable({
checkboxes: [] as string[],
});

const filteredLanguages = derived(filter, ($filter) => {
let filtered: Language[] = languages;
if ($filter.checkboxes.length > 0) {
filtered = filtered.filter((d: Language) =>
$filter.checkboxes.includes(d.type)
);
}
return filtered;
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm more of a Vue person than a Svelte person, but in Vue I would've probably bound the checkbox values to a { [key: string]: boolean } instead of a string[]. Then the filtered languages could be languages.filter(({ type }) => $filter.checkboxes[type]).

Copy link
Owner Author

@o2sh o2sh Dec 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I do this I won't be able to use the bind:group on the input element easily. I'm also not familiar with Svelte.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, OK, no worries. This definitely isn't a blocker for me.

@o2sh
Copy link
Owner Author

o2sh commented Dec 11, 2023

Hi @spenserblack, thanks a lot for the review 👍

The one big thing that I'm wondering is if if makes sense to have "programming" and "markup" be checked by default. This could help hint to what onefetch's defaults are.

I see your point but I'm just not sure if we should restrict the default output of onefetch.dev based on constraints specific to the binary 🤔

@o2sh o2sh requested a review from spenserblack December 11, 2023 10:01
@o2sh o2sh merged commit 92e6590 into main Dec 11, 2023
2 checks passed
@o2sh o2sh deleted the feat/vercel-filter-by-language-type branch December 11, 2023 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants