Skip to content

Instantly share code, notes, and snippets.

@bberg11
Last active June 12, 2017 19:44
Show Gist options
  • Save bberg11/7efce053e82b19a6db280683c4272c14 to your computer and use it in GitHub Desktop.
Save bberg11/7efce053e82b19a6db280683c4272c14 to your computer and use it in GitHub Desktop.
FUX Meeting June 12, 2017

James Avery Create Your Own

https://marvelapp.com/fd6610g/screen/26718172

This features calls for a very app (native) like experience. In order to acheive this, we'd be using drawers and dialogs extensively. Out of the box, these modules are not robust enough for a feature like this. The following are changes made to those two pieces of functionality in order to get us closer to an app-like experience

Changes to drawers

Remove On Close

Add an option to destory (remove from the DOM) on close. Why do this?

https://stash.tools.weblinc.com/projects/NS/repos/jamesavery/commits/376b8e864fc173f2684b69bed14a236ddca05d30

  • CSS Transitions were not working on "re-opened" drawers. This may have been a simple CSS issue, but I couldn't come up with a solution, so I added this.
  • Additionally, and more importantly, there were contexts which required the drawer to be rebuilt with new content

Add a data-attribute to a dialog-button

= button_tag 'Search', type: 'button', data: { drawer_button: { edge: 'bottom', content: '#search' }.to_json, remove_drawer_on_close: true }

Modifiers

No code changes needed. Simply add more modifiers to the edge data-attribute key. Whatever the value of that key will be appended to the drawer's class attribute.

= button_tag 'Search', type: 'button', data: { drawer_button: { edge: 'bottom drawer--search drawer--bottom', content: '#search' }.to_json }

Prevent Page Scrolling

This has been requested a number of times on builds. When you get to the bottom of a scrollable drawer, the page behind the drawer will keep scrolling. This negates that by toggling a class on the body. Class is then used as a new stylesheet under "trumps"

https://stash.tools.weblinc.com/projects/NS/repos/jamesavery/browse/app/assets/stylesheets/weblinc/store_front/trumps/_prevent_scroll.scss?at=refs%2Fheads%2Fqa

Changes to dialogs

Dialog Presets

https://stash.tools.weblinc.com/projects/NS/repos/jamesavery/commits/cdc0e4c9dda07e4064eba663121daeb545d98ee2

Out of the box, the dialogButtons module does a great job of determining where the content of a dialog is coming from (promise, template, the DOM, etc) before firing it off to the actual dialog module. However, if you want the dialog to be built with custom options, you must place them in the dom, and it's not immediately clear where exactly they should go and how they should be labeled.

This led to a new module that essentially wraps the dialogButtons module.

https://stash.tools.weblinc.com/projects/NS/repos/jamesavery/browse/app/assets/javascripts/weblinc/store_front/modules/dialog_presets.js?at=refs%2Fheads%2Ffeature%2FJAISOW-629-cyo-designer

data: { dialog_preset: 'assemblageExitConfirmationOptions' }

https://stash.tools.weblinc.com/projects/NS/repos/jamesavery/browse/app/assets/javascripts/weblinc/store_front/jamesavery_config.js.erb?at=refs%2Fheads%2Ffeature%2FJAISOW-629-cyo-designer#93

Full Screen Dialogs

https://stash.tools.weblinc.com/projects/NS/repos/jamesavery/commits/4357d04ecf98cdd5c11b9d1f1ae80cd4911b3481

Dialog Styling

https://stash.tools.weblinc.com/projects/NS/repos/jamesavery/commits/bc27fab9a53dffc25462d250a292035df5d0c8e3

Using CSS provides a more reliable way to center the dialog than the inline styles applied by jQuery

Adding show: true, hide: true to the jQuery UI dialog options is low hanging fruit to add some animations to your dialogs

Passing Custom Dialog Options To Loading Dialogs

https://stash.tools.weblinc.com/projects/NS/repos/jamesavery/browse/app/assets/javascripts/weblinc/store_front/modules/dialog.js?at=refs%2Fheads%2Ffeature%2FJAISOW-629-cyo-designer#60,241,243

Out of the box, the loading dialog does not receive any custom dialog options passed to your dialog. The promise module utilizes an options parameter, but nothing is passed to it from dialog.js. This change makes it so the loading dialog will look and behave the same as your eventual dialog. This was particularly useful for the full screen dialogs

Loading Screens / Skeleton Screens

https://stash.tools.weblinc.com/projects/NS/repos/jamesavery/commits/98dcc423957a81744a5f2b4f64014c31bdf3a3fc

To stick with the app/native feel, the promise module was updated to accept a template for the loading dialog. Using configs, this allows us to have the loading dialog mimic the layout of the eventual content of the dialog, giving user immediate feedback

Prevent Page Scrolling

Same as for drawers, resues the .prevent-scrol trump on the body element

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment