How to use @freesewing/utils - 10 common examples

To help you get started, we’ve selected a few @freesewing/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github freesewing / freesewing / packages / components / src / DraftConfigurator / PatternOptionMillimeter / index.js View on Github external
const update = (name, newValue, evt) => {
    newValue = roundMm(newValue, props.units);
    // Sometimes, when sliding, the rapid succession of updates
    // causes a weird timing issue to result in a value that is NaN.
    // If that's the case, just ignore this update and keep the
    // previous one instead
    if (!isNaN(newValue)) {
      setValue(newValue);
      if (evt.type !== "mousemove") props.updateValue(props.name, newValue);
    } else {
      if (evt.type !== "mousemove") props.updateValue(props.name, value);
    }
  };
github freesewing / freesewing / packages / components / src / DraftConfigurator / DraftSettingMargin / index.js View on Github external
const update = (name, newValue, evt) => {
    newValue = roundMm(newValue)
    // Sometimes, when sliding, the rapid succession of updates
    // causes a weird timing issue to result in a value that is NaN.
    // If that's the case, just ignore this update and keep the
    // previous one instead
    if (!isNaN(newValue)) {
      setValue(newValue)
      if (evt.type !== 'mousemove') props.updateValue('margin', newValue)
    } else {
      props.updateValue('margin', value)
    }
  }
github freesewing / freesewing / packages / components / src / DraftConfigurator / DraftSettingSa / index.js View on Github external
const updateCustom = (name, newValue, evt) => {
    newValue = roundMm(newValue)
    // Sometimes, when sliding, the rapid succession of updates
    // causes a weird timing issue to result in a value that is NaN.
    // If that's the case, just ignore this update and keep the
    // previous one instead
    if (!isNaN(newValue)) {
      setSaValue(newValue)
      setCustomValue(newValue)
      if (evt.type !== 'mousemove') props.updateValue('sa', newValue)
    } else {
      props.updateValue('sa', customValue)
    }
  }
github freesewing / freesewing / packages / components / src / Workbench / index.js View on Github external
const saveMeasurements = data => {
    storage.set(props.config.name + "-measurements", data);
    props.updateGist(data, "settings", "measurements");
  };
  const updateMeasurement = (name, val) => {
github freesewing / freesewing / packages / components / src / Workbench / index.js View on Github external
const saveDisplay = d => {
    setDisplay(d);
    storage.set(props.config.name + "-display", d);
  };
  const getMeasurements = () =>
github freesewing / freesewing / packages / components / src / DraftConfigurator / OptionGroup / index.js View on Github external
const renderOption = (name, sub = false) => {
    let option = props.config.options[name]
    let type = optionType(option)
    let stringKey = `options.${props.config.name}.${name}.`
    let extraProps = {
      name,
      dflt: optionDefault(name, props.config.options[name], props.recipe),
      patternDflt: optionDefault(name, props.config.options[name]),
      units: props.units,
      updateValue: props.updateValue,
      raiseEvent: props.raiseEvent,
      title: ,
      desc: ,
      intl: props.intl,
      pattern: props.config.name,
      key: name,
      noDocs: props.noDocs
    }
    if (
      typeof props.gist !== 'undefined' &&
      typeof props.gist.settings !== 'undefined' &&
      typeof props.gist.settings.options !== 'undefined' &&
      typeof props.gist.settings.options[name] !== 'undefined'
    )
github freesewing / freesewing / packages / components / src / DraftConfigurator / OptionGroup / index.js View on Github external
const renderOption = (name, sub = false) => {
    let option = props.config.options[name]
    let type = optionType(option)
    let stringKey = `options.${props.config.name}.${name}.`
    let extraProps = {
      name,
      dflt: optionDefault(name, props.config.options[name], props.recipe),
      patternDflt: optionDefault(name, props.config.options[name]),
      units: props.units,
      updateValue: props.updateValue,
      raiseEvent: props.raiseEvent,
      title: ,
      desc: ,
      intl: props.intl,
      pattern: props.config.name,
      key: name,
      noDocs: props.noDocs
    }
    if (
      typeof props.gist !== 'undefined' &&
      typeof props.gist.settings !== 'undefined' &&
      typeof props.gist.settings.options !== 'undefined' &&
      typeof props.gist.settings.options[name] !== 'undefined'
github freesewing / freesewing / packages / components / src / withGist / index.js View on Github external
setGist(gist) {
      this.setState({ gist });
      if (settings.store) storage.set(this.state.gist.name || "gist", gist);
    }
github freesewing / freesewing / packages / components / src / withGist / index.js View on Github external
updateGist(value, l1 = false, l2 = false, l3 = false) {
      if (!l1) return;
      let gist = this.state.gist;

      if (l2 && typeof gist[l1] === "undefined") gist[l1] = {};
      if (l3 && typeof gist[l1][l2] === "undefined") gist[l1][l2] = {};

      if (l3) gist[l1][l2][l3] = value;
      else if (l2) gist[l1][l2] = value;
      else gist[l1] = value;
      this.setState({ gist });
      if (settings.store) storage.set(this.state.gist.name || "gist", gist);
    }