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

JS Proof of Concept #12

Open
TheJaredWilcurt opened this issue Oct 13, 2020 · 0 comments
Open

JS Proof of Concept #12

TheJaredWilcurt opened this issue Oct 13, 2020 · 0 comments
Labels
help wanted Extra attention is needed
Projects

Comments

@TheJaredWilcurt
Copy link
Member

TheJaredWilcurt commented Oct 13, 2020

Need to set up a vanilla JS and Vue.js example using red-perfume to show how it can also be used for JS-based DOM updates.

Likely will need to produce a JSON file and save it to a specified output location. Then have the JS DOM code reference the JSON via a class key to get the atomized responses.

// rp.json
{
  ".cow": [
    "rp__a4",
    "rp__3wx",
    "rp__d7h"
  ]
}
// Vanilla JS
import rp from './rp.json';
const cow = document.getElementById('cow');
cow.classList.add(...rp.cow.split(' '));
// changes <div id="cow" class="moo"></div>
// to <div id="cow" class="moo rp__a4 rp__3wx rp__d7h"></div>
<div class="cow">Instead of this</div>
<div :class="rp.cow">In Vue you'd get the atomized classes this way</div>
<div class="rp__a4 rp__3wx rp__d7h">Which renders as this in the DOM</div>
<!-- More Vue examples -->
<ul>
  <li :class="[ rp.user, rp['user-acount'], rp['p-sm'] ]"></li>
  <li :class="{ isActive: rp.active }">
  <li :class="isOnline ? rp.online : rp.offline">
</ul>
import rp from './rp.json';
// ...
computed: {
  rp: function () {
    const output = {};
    Object.keys(rp).map(function (semanticClassName) {
      output[semanticClassName] = rp[semanticClassName].join(' ');
    });
    return output;
  }
}
@TheJaredWilcurt TheJaredWilcurt added the help wanted Extra attention is needed label Oct 14, 2020
@TheJaredWilcurt TheJaredWilcurt added this to backlog in Red Perfume Oct 14, 2020
@TheJaredWilcurt TheJaredWilcurt moved this from Backlog to Priority in Red Perfume Oct 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
Status: Todo
Red Perfume
  
Priority (prioritized)
Development

No branches or pull requests

1 participant