Skip to content
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

Add some guidance on JS usage in patterns #167

Merged
merged 1 commit into from
Jan 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ The Visual Framework address three major needs:
- 🚫 `button {}`
- 🚫🙊🙉 `div.button {}`
- 🖕 This necessarily requires a bit more class writing, but it ensures the Visual Framework won't break existing code.
- BYOJS: Bring your own JavaScript. We've included only a minimal amount of JS in patterns and it's fully optional (just remove the JavaScript selectors). So if you'd rather use Angular or Bootstrap for your tabs, the Visual Framework won't get in the way.
- BYOJS: Bring your own JavaScript. We've included only a minimal amount of JS in patterns and it's fully optional (just remove [the JavaScript selectors](https://github.com/visual-framework/vf-core/issues/115#issuecomment-455524131); i.e. `data-vf-js-tabs`). So if you'd rather use Angular or Bootstrap for your tabs, the Visual Framework won't get in the way.
1. 🌕🌜 Use a little or a lot:
- A lot: The framework (and [child theme template](https://github.com/khawkins98/vf-child-playground)) will generate a monolithic `styles.css` and `script.js` that can be easily included, a la Bootstrap.
- A little: Instead you can include `.scss` partials or per-pattern `.css` and `.js` files. You can do this through making a [child theme](https://github.com/khawkins98/vf-child-playground) or [npm installs](https://www.npmjs.com/org/visual-framework).
Expand Down
30 changes: 30 additions & 0 deletions tools/component-generator/templates/_component.js
Original file line number Diff line number Diff line change
@@ -1 +1,31 @@
// <%= componentName %>

// Don't need JS?
// Feel free to delete this file.

/*
* A note on the Visual Framework and JavaScript:
* The VF is primairly a CSS framework so we've included only a minimal amount
* of JS in patterns and it's fully optional (just remove the JavaScript selectors
* i.e. `data-vf-js-tabs`). So if you'd rather use Angular or Bootstrap for your
* tabs, the Visual Framework won't get in the way.
*
* When querying the DOM for elements that should be acted on:
* 🚫 Don't: const tabs = document.querySelectorAll('.vf-tabs');
* ✅ Do: const tabs = document.querySelectorAll('[data-vf-js-tabs]');
*
* This allows users who would prefer not to have this JS engange on an element
* to drop `data-vf-js-PATTERN` and still maintain CSS styling.
*/

/**
* The global function for this pattern
* @example vfPatternName(firstPassedVar)
* @param {string} [firstPassedVar] - An option to be passed
*/
function vfPatternName(firstPassedVar) {
firstPassedVar = firstPassedVar || 'defaultVal';

}

vfPatternName();