-
Notifications
You must be signed in to change notification settings - Fork 6.8k
refactor: export component animations for reuse #8971
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
Conversation
If we are exporting them all publically perhaps we should "namespace" them? We could put all of the definitions inside of respective objects for animations. I worry about polluting the exported namespace. For example: export const ExpansionPanelAnimations = {
indicatorRotate: AnimationTriggerMetadata = trigger('indicatorRotate', [
state('collapsed', style({transform: 'rotate(0deg)'})),
state('expanded', style({transform: 'rotate(180deg)'})),
transition('expanded <=> collapsed',
animate(EXPANSION_PANEL_ANIMATION_TIMING)),
]),
expansionHeaderHeight: AnimationTriggerMetadata = trigger('expansionHeight', [
state('collapsed', style({
height: '{{collapsedHeight}}',
}), {
params: {collapsedHeight: '48px'},
}),
state('expanded', style({
height: '{{expandedHeight}}'
}), {
params: {expandedHeight: '64px'}
}),
transition('expanded <=> collapsed',
animate(EXPANSION_PANEL_ANIMATION_TIMING)),
]),
bodyExpansion: AnimationTriggerMetadata = trigger('bodyExpansion', [
state('collapsed', style({height: '0px', visibility: 'hidden'})),
state('expanded', style({height: '*', visibility: 'visible'})),
transition('expanded <=> collapsed',
animate(EXPANSION_PANEL_ANIMATION_TIMING)),
])
} |
Good point @josephperrott, I was hoping that this would come up during the review since I'm not a fan of just exporting them as plain variables either. Switching them over to namespaces. |
50258cf
to
c7d715b
Compare
src/lib/dialog/dialog-animations.ts
Outdated
/** | ||
* Animations used by MatDialog. | ||
*/ | ||
export namespace MatDialogAnimations { |
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.
We can't use typescript namespaces; they're forbidden inside google (has to do with interop with Closure-style javascript)
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.
In this case what would be the proper way to namespace them? Should we have a MatDialogAnimations
class with static properties or just an object with some properties on it? The static class has the advantage of allowing us to make the properties readonly.
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 would just do an object that we can use typescript to make immutable
c7d715b
to
0752958
Compare
Refactored it based on our discussion @jelbourn. Note that I'm not a fan of having to add the typings to all of the constants, but it seems like the simplest way of ensuring that the properties are immutable. Initially I was going for something like |
* Enables a tslint rule that will prevent us from using namespaces. Based on the discussion in angular#8971. * Bumps to the latest stylelint version.
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.
LGTM
src/lib/dialog/dialog-animations.ts
Outdated
} = { | ||
/** | ||
* Animation that slides the dialog in and out of view and fades the opacity. | ||
*/ |
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.
nit: can condense these comments to a single line
Exports all of the component animations so they can be reused by consumers. Fixes angular#8904.
0752958
to
66ee1cf
Compare
* Enables a tslint rule that will prevent us from using namespaces. Based on the discussion in angular#8971. * Bumps to the latest stylelint version.
* Enables a tslint rule that will prevent us from using namespaces. Based on the discussion in angular#8971. * Bumps to the latest stylelint version.
Changing this to minor release since it adds new APIs |
Exports all of the component animations so they can be reused by consumers. Fixes #8904.
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Exports all of the component animations so they can be reused by consumers.
Fixes #8904.