git ssb

0+

mixmix / patch-profile



Branch:
mix committed 1.0.4Latest: 1322a6b on 1/24/2018, 2:49:07 AM
📄.gitignore
📄README.md
📁about
📄index.js
📄package-lock.json
📄package.json
📁styles
README.md

Patch-profile

A module for editing your (or other people's) profiles in patch-* family apps. Edits names or images.

You'll need to understand depject (a module for a different way of managing dependency injection), and for hte example below, depnest - a lazy way to write nested objects quickly.

Example

const nest = require('depnest')
const { h } = require('mutant')

exports.gives = nest('app.page.userEdit')

exports.needs = nest({
  'about.page.edit': 'first',
  'history.sync.push': 'first',
})

exports.create = (api) => {
  return nest('app.page.userEdit', userEdit)

  function userEdit (location) {
    // location is an object { feed, page: 'userEdit' } 

    const options = { feed: location.feed }
    const callback = (err, didEdit) => {
      if (err) throw new Error ('Error editing profile', err) 

      if (didEdit) console.log('Profile updated!')
      // go back to the users profile
      api.history.sync.push({ page: 'userShow', feed })
    }

    return h('Page -userEdit', {}, [
      h('div.container', [
        api.about.page.edit(options, callback)
      ])
    ])
  }
}

API

about.page.edit

(options=object, callback=function)

Where target is of the form { feed='@....', labels=object }

labels (optional) can be used to over-ride labels for translations: { name, image, cancel, save }
callback (optional) will be called after a user confirms or cancels changes. It has signature (err, didEdit=boolean), where didEdit == true if an edit was published.

styles.mcss

Patch-profile exports basic mcss styles. See Patchbay for examples of how this can be integrated into an app.

Built with git-ssb-web