Giter VIP home page Giter VIP logo

roll20-snippets's People

Contributors

jklingen92 avatar kurohyou avatar riernar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

roll20-snippets's Issues

Add object methods to attributeProxy

The common object methods like Object.keys() do not return useful information for the attributeProxy. Methods should be added to the proxy to replicate these methods so that they return the attribute information stored in the proxy.

Removed triggers fail to work

let typePrefix = eventName.startsWith('clicked:') ?
'act_' :
event.removedInfo ?
'fieldset_' :
'attr_';
let cascName = `${typePrefix}${eventName.replace(/clicked:/,'')}`;

In this bit, the removed eventName ends up being removed:repeating_section, which makes it search for fieldset_removed:repeating_section, so along with removing clicked:, removed: also needs to be removed, and then things can properly listen to repeater items being removed.

      let typePrefix = 'attr_';
      if (eventName.startsWith('clicked:')) {
        typePrefix = 'act_';
        eventName = eventName.replace('clicked:', '');
      } else if (event.removedInfo) {
        typePrefix = 'fieldset_';
        eventName = eventName.replace('remove:', '');
      }
      return casc[`${typePrefix}${eventName}`];

Modularize Pug Mixins

The pug Mixins are currently only split between two files (_htmlelements.pug and _rolltemplate_mixins.pug). These should be modularized more to make it easier to work on discrete sets of mixins.

Proposed mixin modules:

  • _attrHolders.pug: to hold the basic input/textarea/select mixins
  • _buttons.pug: to hold the various button mixins
  • _fieldsets.pug: to hold the fieldset mixins
  • _functions.pug: to hold the helper functions
  • _script.pug: to hold the various script mixins
  • Modules for each complicated construction (e.g. a _headedTextarea.pug and _adaptive.pug for the headed textarea construction and adaptiveInput/adaptiveTextarea mixins respectively

Multiple copies of the same code

Its a bit difficult to navigate the code on this repository because there are several different versions of the code, corresponding to the different blog posts. There are a few things that you could do keep them separate without creating so many redundancies:

  1. You could give them separate branches. This would require users who wanted to get one or the other to understand how to checkout different branches. You would be able to push fixes to earlier versions and propogate those changes to later versions by rebasing (although that would be a bit of a hassle.

  2. You could tag them at each release point. This would allow you to keep the history nice and do some development on them. It would be easy to share the links to each release as well.

  3. You could compress the whole repository as a certain point and then upload it as Blog_Post_1_release.zip or whatever. This would make it really easy for people to download the release that they want, but it would be impossible to maintain a specific release, unless you combined this strategy with one of the above.

K-scaffold SCSS Framework

Create SCSS files for some of the basic layouts that the more complex mixins are intended to work with.

  • input-label (and it's variations
  • headed textarea
  • collapse and collapse-containers
  • The modified fieldsets
  • Fill left construct

[k-Scaffold] `+roller` doesn't work if `name` contains `"roll`"

When using the +roller mixin, if the provided name contains the string "roll" somewhere, the roll button no longer works (it doesn't trigger the abilitiy).

Without "roll"

+roller({name:'testrl')

generated HTML

<button class="roller" name="roll_testrl" value="@{testrl_action}" title="%{testrl}" type="roll">
</button>
<button name="act_testrl-action" hidden="" type="action" title="%{testrl-action}">
</button>
<input name="attr_testrl_action" type="hidden" title="@{testrl_action}"/>

With "roll"

+roller({name:'testroll')
<button class="roller" name="roll_testroll" value="@{testaction}" title="%{testroll}" type="roll">
</button>
<button name="act_testaction" hidden="" type="action" title="%{testaction}">
</button>
<input name="attr_testaction" type="hidden" title="@{testaction}"/>

Move Select/Option mixin combination to a nested mixin construction

Based on the work done with the tabs construction, the select/options combination of mixins would become more easily readable if turned into a group of nested mixins. This should also then allow us to move the trigger for selects to the select itself instead of the options.

accessSheet function sends incorrect arguments to `getAllAttrs`

getAllAttrs({event,callback:(attributes,sections,casc)=>{

The call passes in event to getAllAttrs which doesn't take an event value.

//accessSheet
const accessSheet = function(event){
  debug({funcs:Object.keys(funcs)});
  debug({event});
  getAllAttrs({event,callback:(attributes,sections,casc)=>{
    let trigger = attributes.getCascObj(event,casc);
    attributes.processChange({event,trigger,attributes,sections,casc});
  }});
};
//getAllAttrs
const getAllAttrs = function({props=baseGet,sectionDetails=repeatingSectionDetails,callback}){
  getSections(sectionDetails,(repeats,sections)=>{
    getAttrs([...props,...repeats],(values)=>{
      const attributes = createAttrProxy(values);
      orderSections(attributes,sections);
      const casc = expandCascade(cascades,sections,attributes);
      callback(attributes,sections,casc);
    })
  });
};

Pipeline to include Javascript function triggers

I've been reading the blog posts and combing through the code, working to build out my own sheet. It's been very challenging to understand what the pipelines are here, namely, how does the javascript actually get attached and to where. Roll20 seems to have a lot of poorly documented requirements (i.e. apparently all JS must be organized into on sheetworker, or something).

My biggest question is what are triggers and how do they work? It looks like there are a number of different types of triggers (affects, calculation, listeners, etc). Are those documented anywhere? There's some code in here that "registers" functions to kFuncs, although that's not listed in the README anywhere as a necessary step. Does the code that handles triggers look for those triggers in kFuncs? The return statement for kFuncs is in a different file from the initialization, which makes it very hard to read.

Here's my main pug file:

// system.pug
include scaffold/_kpug.pug

mixin spec-block(name)
    .spec
    // Displays modifier
    +span({
      name: `${name}_mod`, 
      title:`@{${name}_mod}`,
      value: 0,
      trigger: {calculation: "calculateSpecMod"}
    }) 
    // Base input
    +number({
      name, 
      class: "base-input",
      value: 10,
      trigger: {affects: [`${name}_mod`]}
    })

main
  .sheet
    .specs
      for spec in constants.specs 
        +spec-block(spec)

+kscript
  include javascript/specs.js

and

// javascript/specs.js

 function calculateSpecMod(spec) {
  console.log("hello world")
  return Math.floor((spec - 10) / 2)
}

I haven't been able to see any console output anywhere or values change based on updating anything. I've also been unable to see any of the hefty js that kscript generates show up in the actual character sheet sandbox, despite it being visible in the HTML files. It's like its being stripped from the file when its uploaded.

UPDATE: It appears that the kscript code is crashind that's likely the cause of the problem. I've downloaded the most recent scaffold code from week 4 (see issue #15). I put in a PR for a bug that seems to only exist in older versions of the code (#14 , and again #15), but I'm still seeing an error message in the console when loading the kscript:
SyntaxError: unexpected token: identifier

Add check to ensure kscript has not already been run when using mixins

The problem

Currently, if a user puts their kscript call at the start of their html (or anywhere but the end), much of the JS functionality of the scaffold is lost without any notice to the user that this is an issue.

Desired Behavior

  • Add a global variable that the kscript mixin sets to true when it is invoked.
  • Add a check to the base input, button, textarea, span, img, and div mixins to check for this variable and throw an error if it is already truthy.

accessSheet.js inconsistent `sheet_version` vs `version`

Line 9 has attributes.sheet_version and line 20 has attributes.version. I think that likely no version updates will be applied due to this.

    if(!attributes.sheet_version){
      Object.entries(initialSetups).forEach(([funcName,handler])=>{
        if(typeof funcs[funcName] === 'function'){
          debug(`running ${funcName}`);
          funcs[funcName]({attributes,sections,casc});
        }else{
          debug(`!!!Warning!!! no function named ${funcName} found. Initial sheet setup not performed.`);
        }
      });
    }else{
      Object.entries(updateHandlers).forEach(([ver,handler])=>{
        if(attributes.version < +ver){
          handler({attributes,sections,casc});
        }
      });
    }

[Suggestion] Repo dedicated to k-scaffold

I propose to dedicate this repository to k-scaffold, by renaming it to k-scaffold and changing the layout.

Rational

The current layout of the repo makes it harder-than-needed to install or add k-scaffold into a project. Other than k-scaffold, this repository containes two snippets parseRepeatName and fill-left elements, which are already part of k-scaffold.
Making this repo k-scaffold dedicated would make k-scaffold installation easy though a git clone --depth 1 or git submodule add.

Propose changes

  • Rename the repo to k-scaffold
  • Refactor the repo to the following layout:
.
├── docs/ # documentation folder
├──tutorial/ # Folder holding the tutorial code and posts
├── src/ # source for k-scaffold
│   ├── buttons/ # a part of k-scaffold, isolated in a folder
│   │   └── _buttons.pug
│   ├── helpers/ # a part of k-scaffold that need .pug, .js and .scss to worl
│   │   ├── helpers.js
│   │   └── _helpers.pug
│   │   └── _helpers.scss
│   └── tabs/  # a part of k-scaffold that need .pug, .js and .scss to worl
│       ├── tabs.js
│       ├── _tabs.pug
│       └── _tabs.scss
├── _kpug.pug # root file to import in a project using k-scaffold
├── _k.scss # root file to import in a project using k-scaffold
├── LICENSE
├── README.md
└── template/ # template character sheet for creating new project
    ├── prepros.config
    ├── sheet.json
    ├── system.html
    ├── system.pug
    └── translation.json

Installation would be achieved through

git submodule add <repo url>

and allow updating the underlying version of k-scaffold. Submodules also prevent staging k-scaffold files as part of the sheet's repo: git will go get the k-scaffold repo itself and put it in a folder.

EDIT: Added Tutorial folder to grid outline.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.