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

Add initial forms components #299

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from
Open

Conversation

tomas-sucena
Copy link

As discussed in the previous sprint, @Lauranea and I started developing form components. So far, we have:

Component Developed by Screenshot
Picture Input @Lauranea image
Radio Buttons @tomas-sucena (me) image

We've also added a new folder - forms/ - inside src/components/ to store these and all future forms components.

Please feel free to modify our code to your liking. Since we're just starting out, we'd appreciate any feedback we could get. 😄

Review checklist

  • Contains enough appropriate tests
  • Behavior is as expected
  • Clean, well-structured code

@MRita443 MRita443 self-requested a review November 27, 2024 16:41
@MRita443 MRita443 marked this pull request as ready for review December 4, 2024 12:22
Copy link
Collaborator

@MRita443 MRita443 left a comment

Choose a reason for hiding this comment

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

Great job! left some suggestions more about organization and edge cases, it's looking good tho

src/lib/components/forms/picture-input.stories.ts Outdated Show resolved Hide resolved
src/lib/components/forms/radio-buttons.stories.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd change this to be in the same storybook folder as the rest, for example in Atoms/Forms/Label Input

let reader = new FileReader();
reader.readAsDataURL(image);
reader.onload = (e) => {
avatar = e.target.result;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
avatar = e.target.result;
if (e.target?.result) {
avatar = e.target.result.toString();
}

My IDE nagged me about this because e.target might be null in error cases ;p

Comment on lines 29 to 33
on:keydown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
fileinput.click();
}
}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

These bindings are not working for me, are they for you?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is missing Storybook stories, if you need any help let me know!

Comment on lines +4 to +11
$: () => {
if (files) {
console.log(files);
for (const file of files) {
console.log(`${file.name}: ${file.size} bytes`);
}
}
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't forget to remove when you're done :)

{#if files}
{#each Array.from(files) as file}
<div class="rounded-lg bg-taupe-200 px-4 py-2 text-rose-950">
<p>{file.name}</p>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm it would be useful if each file could have a little X to remove just that file, would that be doable?

for="file-upload"
class="muted-red cursor-pointer rounded-lg px-4 py-2 text-white hover:bg-red-600"
>
Selecionar ficheiro
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be an input to the component so that we can place whatever text here!

<div class="flex items-center space-x-4">
<label
for="file-upload"
class="muted-red cursor-pointer rounded-lg px-4 py-2 text-white hover:bg-red-600"
Copy link
Collaborator

Choose a reason for hiding this comment

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

The button differs a bit currently from the mockups:
image
We should add the red background color to the button and maybe make that color a bit darker on hover?

Copy link

codecov bot commented Dec 6, 2024

Codecov Report

Attention: Patch coverage is 12.33766% with 135 lines in your changes missing coverage. Please review.

Project coverage is 11.45%. Comparing base (0af8cb5) to head (0e020cb).
Report is 66 commits behind head on develop.

Files with missing lines Patch % Lines
src/lib/components/forms/picture-input.svelte 16.98% 43 Missing and 1 partial ⚠️
src/lib/components/forms/files-input.svelte 0.00% 30 Missing and 1 partial ⚠️
src/lib/components/forms/radio-buttons.svelte 34.48% 18 Missing and 1 partial ⚠️
src/lib/components/forms/picture-input.stories.ts 0.00% 17 Missing and 1 partial ⚠️
src/lib/components/forms/radio-buttons.stories.ts 0.00% 17 Missing and 1 partial ⚠️
src/lib/components/icons/icons.ts 0.00% 3 Missing ⚠️
src/lib/components/forms/label-input.stories.ts 0.00% 1 Missing ⚠️
src/routes/(app)/contacts/+page.svelte 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           develop     #299       +/-   ##
============================================
+ Coverage     0.86%   11.45%   +10.59%     
============================================
  Files           51       64       +13     
  Lines         1857     2409      +552     
  Branches        53      143       +90     
============================================
+ Hits            16      276      +260     
- Misses        1792     2075      +283     
- Partials        49       58        +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tomas-sucena
Copy link
Author

@MRita443 Found an even better way to style selected labels on the RadioButton component. It requires neither a complex selector like the one I originally proposed nor JavaScript overhead like in your suggested change.

image

What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants