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

Refactor upload component and add styled upload component #3035

Merged
merged 9 commits into from
Apr 24, 2024

Conversation

Ifechukwu001
Copy link
Contributor

@Ifechukwu001 Ifechukwu001 commented Apr 8, 2024

Description

These changes add default styling to the upload component - It follows the same pattern as the form component, where the root method call accesses the unstyled component.

Some default styles were commented so as not to break a previous test in the rendering of forms (With permission, I'd like to refactor the test).

Closes #2967

All Submissions:

  • [ ✅ ] Have you followed the guidelines stated in CONTRIBUTING.md file?
  • [ ✅ ] Have you checked to ensure there aren't any other open Pull Requests for the desired change?

Type of change

  • [ ✅ ] New feature (non-breaking change which adds functionality)
  • [ ✅ ] This change requires a documentation update

New Feature Submission:

  • [ ✅ ] Does your submission pass the tests?
  • [ ✅ ] Have you linted your code locally prior to submission?

Changes To Core Features:

  • [ ✅ ] Have you added an explanation of what your changes do and why you'd like us to include them?
  • [ ✅ ] Have you written new tests for your core changes, as applicable?
  • [ ✅ ] Have you successfully ran tests with your changes locally?

"""
# Set default props.
props.setdefault("border", "1px dashed black")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The commented styles break a previous form render test.

Copy link
Collaborator

@Lendemor Lendemor Apr 8, 2024

Choose a reason for hiding this comment

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

We should probably fix the test then, go ahead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The tests have been fixed. and I added some for the styled case.

Copy link
Contributor Author

@Ifechukwu001 Ifechukwu001 left a comment

Choose a reason for hiding this comment

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

Added extra information to the PR

Copy link
Collaborator

@Lendemor Lendemor left a comment

Choose a reason for hiding this comment

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

Can you make it work in dark mode too?

You could use var(--accent-12) instead of black for the color of the border.

@Ifechukwu001
Copy link
Contributor Author

I'll work on that as well

@Ifechukwu001
Copy link
Contributor Author

This is currently how the styled upload works.

image

image

image

image

@Ifechukwu001 Ifechukwu001 requested a review from Lendemor April 9, 2024 13:19
Lendemor
Lendemor previously approved these changes Apr 11, 2024
Lendemor
Lendemor previously approved these changes Apr 13, 2024
Copy link
Contributor

@picklelo picklelo 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! Will do a more thorough review later this week and try to get this in the next release

Copy link
Collaborator

@masenf masenf left a comment

Choose a reason for hiding this comment

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

If we have a separate class StyledUpload, we need to ensure that Upload.is_used gets set, regardless of which flavor of upload is actually used, so that the App mounts the upload endpoints

@Ifechukwu001
Copy link
Contributor Author

I thought that calling the super() class method would set the variable, is there any need to set the is_used variable again?

@Lendemor
Copy link
Collaborator

I thought that calling the super() class method would set the variable, is there any need to set the is_used variable again?

This will only set the is_used in StyledUpload, but the framework enable the upload features when Upload.is_used is true, so it need to be set.

image

Simply adding the line Upload.is_used = True inside the StyledUpload.create is enough to make it work.

@Ifechukwu001
Copy link
Contributor Author

I'm curious, I don't understand how the react component works as I haven't used React before, but If we decide to do super().is_used = True is that the same as Upload.is_used = True?

@Lendemor
Copy link
Collaborator

I'm curious, I don't understand how the react component works as I haven't used React before, but If we decide to do super().is_used = True is that the same as Upload.is_used = True?

In that case it has nothing to do with React, it's purely a python situation, if you try super().is_used = True it will throw an error saying super doesn't have an is_used attribute.

Test with the following example :

class Foo:
    is_used = False

    @classmethod
    def create(cls):
        cls.is_used = True
        return cls()

class Bar:
    is_used = False

    @classmethod
    def create(cls):
        cls.is_used = True
        return super()

Bar.create()

print(Foo.is_used, Bar.is_used)

Copy link
Contributor

@picklelo picklelo left a comment

Choose a reason for hiding this comment

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

thanks for adding!

@picklelo picklelo merged commit ce2bd22 into reflex-dev:main Apr 24, 2024
46 checks passed
@Ifechukwu001 Ifechukwu001 deleted the upload-style branch April 25, 2024 07:58
@Lendemor Lendemor mentioned this pull request May 5, 2024
11 tasks
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.

[REF-2427] rx.upload should be styled by default
4 participants