-
Notifications
You must be signed in to change notification settings - Fork 2
Support SSR without error #1
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
Open
flobacher
wants to merge
3
commits into
Nicell:master
Choose a base branch
from
Lean-Coders:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| export enum SSRMode { | ||
| Static = 'STATIC', | ||
| Rehydrate = 'REHYDRATE', | ||
| } | ||
|
|
||
| export class NiceAnimConfig { | ||
|
|
||
| public fallbackCssClass: string; | ||
|
|
||
| public ssrMode: SSRMode; | ||
|
|
||
| public get ssrCssClass(): string { | ||
| if (this.ssrMode === SSRMode.Static) { | ||
| return ''; | ||
| } else if (this.ssrMode === SSRMode.Rehydrate) { | ||
| return 'nice-anim'; | ||
| } | ||
| } | ||
|
|
||
|
|
||
| private static instance: NiceAnimConfig = null; | ||
|
|
||
| private constructor() { | ||
| this.ssrMode = SSRMode.Rehydrate; | ||
| this.fallbackCssClass = ''; | ||
| } | ||
|
|
||
| static getInstance() { | ||
| if (!NiceAnimConfig.instance) { | ||
| NiceAnimConfig.instance = new NiceAnimConfig(); | ||
| } | ||
| return NiceAnimConfig.instance; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| export * from './components'; | ||
| export * from './components/nice-anim/nice-anim-config' |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of adding a new property, it may be better to just apply the "slide-{direction}" class if this.hasIOSupport is false. That way everything will still animate in the way it was originally intended, just not on intersection.
This could maybe even be extended to just a helper method instead of having it in two places in the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the thing is.. there are 2 different use cases...
one: u rehydrate a ssr app.. this way, the element should be opacity 0 after the ssr, so that there is no flickering
two: ssr only... the element should be visible straight away, or like with your improved version, slide in instantly.. whats your take on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey since it was late for me already I was a bit quick .. so first of all.. thank you for your great component and for sharing it!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The question is, can we tell if it's a SSR only or a rehydration...? If we could, then handling all three situations will work great. Otherwise, we may have some issues. I'm not sure if there's a solid way to check the difference, especially if people use this component without StencilJS.
Also, requiring a property every time may be a pain for people doing SSR. Possibly a global setting could work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know of a way to tell this..
when ssring with stencil there is a prop, but I intentionally did not use this so it works with all wc-setups..
I think the standard use-case is rehydration... its also what stencil does.. thats why I left the
.nice-animas default class.. pure ssr only setups would have to set afallbackCSSClass=""on all the<nice-anim>instances... I think thats ok, since its not the main use case...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@flobacher I'm looking at this soon. I'll need to test out the configuration to get a feel for how it works. Would be super helpful if you could explain the way you implemented the configuration and why? It looks nice, I'd just like to hear the reasoning behind it. I still have lots to learn :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^ An example code piece of usage would be great.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will try to provide this asap.. I already used/tested it in a project where I use nice-anim =)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Were you able to get that example? I do understand what this does now. Does the class persist between each NiceAnim and updates to it in plain TS? I'm unable to test this right now, but probably will tonight. Also I'm wondering if
Build.isBrowserwill error on something that isn't Stencil.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@flobacher I'd like to get this merged. So I'm still unsure on if the configuration persists between all NiceAnim instances, and if having
Build.isBrowserwill error on a non-Stencil site. Once I have those figured out I'll be merging this finally 😄