-
Notifications
You must be signed in to change notification settings - Fork 65
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
SlidePanel #18
SlidePanel #18
Conversation
Codecov Report@@ Coverage Diff @@
## master #18 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 2 3 +1
Lines 26 105 +79
Branches 13 44 +31
=====================================
+ Hits 26 105 +79
Continue to review full report at Codecov.
|
|
||
export interface SlidePanelFactory extends WidgetFactory<SlidePanel, SlidePanelProperties> { }; | ||
|
||
let content: HTMLElement; |
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.
Do these not have to be stored in a weakmap keyed by the instance? Otherwise having multiple instances will mess with the values.
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.
You're right. Do you have an example of how that would look?
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.
Something like this I'd imagine.
interface InternalState {
content: any;
}
const internalStateMap = new Weakmap<SlidePanel, InternalState>();
// and something like this in the initialise
initialize(instance) {
internalStateMap.set(instance, initialValues):
}
Can we add a custom element wrapper by default for all our components? There are instructions on the readme. |
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.
A few comments/questions
package.json
Outdated
"@dojo/compose": "2.0.0-beta.21", | ||
"@dojo/core": "2.0.0-alpha.20", | ||
"@dojo/has": "2.0.0-alpha.7", | ||
"@dojo/i18n": "2.0.0-alpha.5", | ||
"@dojo/shim": "2.0.0-beta.8", | ||
"@dojo/widget-core": "^2.0.0-alpha.23", |
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 are trying to work with pinned dependencies at the moment.
import * as animations from '../../styles/animations.css'; | ||
import themeable, { ThemeableMixin } from '@dojo/widget-core/mixins/themeable'; | ||
|
||
export interface SlidePanelProperties extends WidgetProperties { |
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.
let's add some jsdoc for the properties (and other exported APIs)
} = this.properties; | ||
|
||
// Current pointer position | ||
let currentX = event.type === 'touchmove' ? event.changedTouches[0].screenX : event.pageX; |
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.
presume these can both be const
?
onRequestClose && onRequestClose(); | ||
} | ||
// If the underlay was clicked | ||
else if (delta > -5 && delta < 5 && (<HTMLElement> event.target).classList.contains(css.underlay)) { |
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 think we might have a type somewhere for this (I'll see if I can find it)
const classes: {[key: string]: any} = {}; | ||
const styles: {[key: string]: any} = {}; | ||
|
||
classes[css.content] = true; |
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 think that we should be using the this.class(
function as it effectively manages the creation of any required false
classes, so for this example you could just have an array of classNames that you want to be set and then spread them this.classes(...classesToSet).get()
?
const classes = [css.content];
if (open && !state.wasOpen) {
classes.push(css.slideIn);
}
else if (!open && state.wasOpen) {
classes.push(css.slideOut);
if (state.transform !== 0) {
styles['transform'] = `translateX(${ align === 'left' ? '-' : '' }${ state.transform }%)`;
}
}
const content = v('div', {
key: 'content',
classes: this.classes(...classes).get(),
styles,
afterCreate: this.afterCreate
}, this.children);
@agubler: Ready for another review when you get a chance. Want to make sure my JSDoc looks ok, I was a little confused what to document for returned factory functions. |
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.
couple small questions?
* @property {Function?} onCloseClick Event handler for when the close button is clicked | ||
* @property {Function?} onUnderlayClick Event handler for when a click occurs outside the dialog | ||
*/ | ||
export type Dialog = Widget<DialogProperties> & ThemeableMixin & { |
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.
these are mandatory really? as you implement them as the author?
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.
Fixed.
* @property {Function?} afterCreate Called after the panel is rendered as DOM | ||
* @property {Function?} onTransitionEnd Event handler for when the panel finishes any animation | ||
*/ | ||
export type SlidePanel = Widget<SlidePanelProperties> & ThemeableMixin & { |
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.
pretty much same comment, they are all implemented below so can remove the ?
?
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.
Fixed.
}; | ||
|
||
export type SlidePanel = Widget<SlidePanelProperties> & ThemeableMixin & { | ||
onSwipeStart?(event: MouseEvent & TouchEvent): void; |
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.
Should these be optional? They're all implemented and part of the widget so it feels like they should not.
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.
Fixed.
Ready for another look. |
}, | ||
{ | ||
attributeName: 'modal', | ||
value: value => Boolean(value) |
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.
These Boolean conversions aren't working quite right. Boolean('false')
and Boolean('0')
return true
.
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 custom element wrappers look good 👍 I created a little test page with a slide panel and was able to interact with it as a custom element.
Party on. |
Type: feature
The following has been addressed in the PR:
Description:
This PR introduces a SlidePanel component, updates the existing Dialog component to the new widget API, and adds custom element wrappers for each. It also adds accessibility features to the Dialog based on suggestions from @smhigley. Focus accessibility was omitted until we work through a focus manager.
Initial SlidePanel API:
Resolves #2, Resolves #12, Resolves #17