Skip to content

Fader - a component to easily add fade look to other components #847

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

Merged
merged 11 commits into from
Aug 2, 2020

Conversation

M-i-k-e-l
Copy link
Collaborator

Notes about the images:

  1. I've tried at first using the original gradient image and rotating it, I only managed doing it with transform and that required onLayout so I'd know the size of the view, this worked all right on iOS but was slower on Android for some reason - it did not look good enough, so I chose to go with 4 images for the different orientations.
  • The code was much more complex in the older version.
  1. If we merge this, we should deprecate the original gradient image in the next version.

@@ -1,5 +1,18 @@
export const images = {
// TODO: deprecate
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since the gradient image can changed according to many different requirements I think it's better that the user will provide the image instead.
If we want to provide defaults we can keep these images, but keep them as part of the component assets and don't expose them in our Assets

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moved internally

import React, {useCallback} from 'react';
import {
StyleSheet,
// eslint-disable-next-line no-unused-vars
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's impossible to read the code with all the lint comments.
First, there's a way to ignore a block of code with eslint.
Second, because of TS, this lint error won't break the build for now, I know it's annoying to see the red marks but for now ignore them, these things will be fixed/handled all together once we complete the TS migration.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed

/**
* Use to render the fade
*/
renderFader: () => React.ReactNode;
Copy link
Collaborator

Choose a reason for hiding this comment

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

If the whole idea of this HOC is to provide a render function that renders a component based on props. wouldn't it be easier to create a component?
I think it would be a lot simpler if the use can just render a "ScrollFader" component. WDYT?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe if there has to be a single child that has to have onScroll (or has to be a supportedView).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed to Fader, changed the title (but not the branch name :) )

@M-i-k-e-l M-i-k-e-l requested a review from ethanshar July 29, 2020 05:52
@M-i-k-e-l M-i-k-e-l changed the title withScrollFader - allows easily adding a fade to a scroll Fader - a component to easily add fade look to other components Aug 2, 2020
Comment on lines 77 to 79
const isVisible = useCallback(() => {
return props.visible || _.isUndefined(props.visible);
}, [props.visible]);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need the callback?
Can't we check directly props.visible in the render?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moved

Comment on lines 19 to 22
/**
* The location of the fader (the image is different), defaults to Fader.location.RIGHT
*/
location?: FaderLocation;
Copy link
Collaborator

Choose a reason for hiding this comment

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

What do you think of renaming to position? to be more consistent with other components (toast position, badge position, etc..)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed

@@ -0,0 +1,89 @@
import _ from 'lodash';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks great. Very simple and easy to understand the component 👍

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

10x

@M-i-k-e-l M-i-k-e-l requested a review from ethanshar August 2, 2020 12:57
@ethanshar ethanshar merged commit 7204360 into master Aug 2, 2020
@M-i-k-e-l M-i-k-e-l deleted the feat/with-scroll-fader branch September 21, 2020 09:57
@M-i-k-e-l M-i-k-e-l restored the feat/with-scroll-fader branch September 21, 2020 10:00
@M-i-k-e-l M-i-k-e-l deleted the feat/with-scroll-fader branch September 21, 2020 10:00
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.

2 participants