示例#1
0
const Signs = ({ images, signs }) => {
  const { cards, tag, page, pages } = signs,
        total = pages * page.size

  const select = compose(filter(byTag(tag)), map(get(images))),
        limit  = compose(take(total), select)

  return p('div.signs', [
    p('nav.tags.row', tags(images).map(name =>
      p('div.tag', {
        class: { active: tag === name },
        on: { click: [ setTag, name ] }
      }, name)
    )),

    p('div.content', [
      p('div.page', { key: tag, style: paged }, [
        p('div.cards.row', limit(cards).map(Card('/signs'))),

        p('button.more', {
          class: { hidden: total >= select(cards).length },
          on: { click: showMore }
        }, 'Show more'),

        Footer()
      ])
    ])
  ])
}
const getResultItemElt = (searchString, encodeText) => ({ name, content, isEndOfSubsection }) => {
  const highlightText = wrapTextWithClass(CLASSNAMES.HIGHLIGHT);
  const highlightSearchString = compose(highlightText, encodeText)(searchString);
  const getResultItemEltFormattedInnerHTML =
    getResultItemEltInnerHTML(compose(highlightSearchString, encodeText));

  return createDivElt({
    className: getResultItemEltClassName(isEndOfSubsection),
    innerHTML: getResultItemEltFormattedInnerHTML(name, content),
  });
};
示例#3
0
export default (reducer, initialValue) => {
    const actions = compose(reduce((acc, name) => acc.set(name, holdSubject()), new Map()), keys)(reducer);
    const patterns = reduce((acc, [key, {observer, stream}]) => acc.concat(stream, reducer[key]), [], actions);

    const initialStream = cond([
        [compose(is(Function), prop('then')), fromPromise],
        [compose(is(Function), prop('observe')), identity],
        [isArrayLike, from],
        [T, of]
    ])(initialValue);

    return {
        getStream: () => initialStream.concatMap(v => update(v, patterns)),
        dispatch: (actionName, ...payload) => actions.get(actionName).observer.next(payload)
    }
};
示例#4
0
文件: xhr.js 项目: act-framework/act
export const get = (url) => (next, error) => {
  const builder = compose(
    openGet(url),
    load(next, error)
  )
  return sendRequest(builder)
}
示例#5
0
文件: xhr.js 项目: act-framework/act
export const getJSON = (url) => (next, error = () => {}) => {
  const builder = compose(
    openGet(url),
    loadJSON(next, error)
  )
  return sendRequest(builder)
}
示例#6
0
  return all(item => {
    const itemAsString = item.toString();
    const itemBeginsWith = compose(
      equals(0),
      indexOf(__, itemAsString)
    );

    return any(itemBeginsWith, prefixList);
  }, valArray);
示例#7
0
module.exports = ({ sockets }) =>
  h('div.sockets', [
    h('div.messages', {
      redux: { create: connect, destroy: disconnect }
    }, listToArray(sockets.messages).map(msg =>
      h('div.message', msg.body)
    )),

    h('form.form', {
      on: {
        submit: compose(reset, send, K(sockets.body), preventDefault)
      }
    }, [
      h('input.input.body', {
        on: { input: compose(body, trim, targetVal) },
        props: { value: sockets.body }
      }),
      h('button.btn.send', {
        attrs: { disabled: !sockets.body }
      }, 'Send')
    ])
  ])
示例#8
0
文件: xhr.js 项目: act-framework/act
export const post = (url, body = {}) => (next, error) => {
  const builder = compose(
    (request) => {
      if (typeof body === 'object') {
        body = JSON.stringify(body)
        request.setRequestHeader('Content-Type', 'application/json')
      }
      return body
    },
    openPost(url),
    loadJSON(next, error)
  )
  return sendRequest(builder)
}
示例#9
0
exports.view = update => model =>
  h(`div.${css.container}`, [
    h('style', css.toString()),

    h(`input.${css.input}`, {
      attrs: {
        autofocus: true,
        placeholder: 'Text to reverse'
      },
      on: { input: compose(update, Msg.Change, targetValue) }
    }),

    h(`span.${css.arrow}`, '<=>'),

    h(`input.${css.input}`, {
      attrs: {
        disabled: true,
        placeholder: 'Reversed result',
        value: reverse(model.content)
      }
    })
  ])
示例#10
0
            <div className={classes.num}><div className={classNames("total", classes.circle)}> </div>
              {this.props.groupSelected.size} members
            </div>
          </div>}
        </div>

        {this.state.requestOpen && <Modal
          fadeOut={!this.state.requestOpen}
        >
          <RequestFriend close={this.toggleRequest} showToast={this.props.showToast} />
        </Modal>}
      </div>
    );
  }
}

export const mapStateToProps = (state) => {
  return {
    pageTitle: state.page.title || {},
    notifications: getUnseenRequests(state),
    pendingRequests: getRequests(state),
    groupSelected: getGroupInfo(state),
    user: state.users.currentUser || {}
  };
};


const ftheme = injectSheet(styles);
const fRedux = connect(mapStateToProps, actionCreators);
export default compose(withRouter, fRedux, ftheme)(UserHeader);
示例#11
0
            requests={this.props.requests}
            classes={classes} pendingOpen={this.state.pendingOpen} togglePending={this.togglePending} />
        </div>
        {this.state.requestOpen && <Modal
          fadeOut={!this.state.requestOpen}
        >
          <AddRoom close={this.toggleRequest} showToast={this.props.showToast} />
        </Modal>}
      </div>
    );
  }
}

export const mapStateToProps = (state) => {
  return {
    users: state.friends,
    friends: getAllFriends(state),
    unreadMessages: getUnreadMessages(state),
    selectedChat: getSelectedChat(state),
    requests: getRequests(state),
    currentUser: state.users.currentUser || {},
    groups: Object.values(state.groups) || [],
    groupList: state.groups || {}
  };
};


const ftheme = injectSheet(styles);
const fRedux = connect(mapStateToProps, actionCreators);
export default compose(withRouter, fRedux, ftheme)(GroupList);
示例#12
0
import compose from 'ramda/src/compose';
import merge from 'ramda/src/merge';

const defaults = merge({
  bubbles: true,
  cancelable: true,
  eventPhase: 2,
});

const createEvent = (options = {}) => new Event('precompare', options);

export default compose(
  createEvent,
  defaults,
);
示例#13
0
import fromValue from 'main/signals/sources/fromValue'
import compose from 'ramda/src/compose'
import map from 'ramda/src/map'
import filter from 'ramda/src/filter'
import transduce from 'main/signals/processes/transduce'

const number = fromValue()

const xform = compose(map((x) => x + 1), filter((x) => x > 10))
const subscriber = transduce(xform, number, (x) => console.log('>>', x))
window.subscriber = subscriber
示例#14
0
              <div className={classes.commentActions}>
                <div className={classes.loloji}></div>
                <Icon fontProps={{icon: "paperclip"}} className={classes.icon} />
              </div>
            </div>
            <div className={classes.sendWrapper} onClick={this.sendChat}>
              <Icon fontProps={{icon: "paper-plane"}} className={classes.icon} />
            </div>
          </div>
        </div>
      </div>
    );
  }
}

export const mapStateToProps = (state) => {
  return {
    pageTitle: state.page.title || {},
    messages: getSelectedChatBoard(state),
    user: state.users.currentUser || {},
    groups: state.groups,
    users: state.friends || {},
    selectedChat: getSelectedChat(state),
  };
};


const ftheme = injectSheet(styles);
const fRedux = connect(mapStateToProps, actionCreators);
export default compose(withRouter, fRedux, injectIntl, ftheme)(ChatBoard);
示例#15
0
文件: index.js 项目: yjxf8285/test
export const journey = (canvas) => (datasource) => {
  const { 
    stage: { 
      rowNumber: row, 
      columnNumber: column 
    }, 
    mode = MODE.NORMAL,
    nodes = [], 
    lines = [],
    scale = 1,
    currentXIndex = -1,
  } = datasource;

  const findMaxValue = compose(
    reduce(max, 0),
    filter(i => i != 0),
    map(({ props: { number } }) => number),
  );
  const maxValue = findMaxValue(lines);

  const stage = new JourneyStage(canvas, ROW_LIMIT(row), COLUMN_LIMIT(column), scale);

  lines.forEach(n => {
    const props = n.props;
    const newProps = {
      ...props,
      maxValue,
    };

    let line = null;
    if (mode === MODE.PRE_COMPARE) {
      line = new CompareLine(newProps);
    } else {
      line = new Line(newProps);
    }

    stage.addChild(line);
  });

  nodes.forEach((n, index) => {
    let node = null;
    if (mode === MODE.PRE_COMPARE) {
      node = new CompareNode({
        ...n.props,
        canChecked: n.props.xIndex === currentXIndex,
      });
    } else {
      node = new Node({
        ...n.props,
        canClicked: !(mode === MODE.RESULT),
      });
    }

    stage.addChild(node);
  });

  stage.render();

  if (process.env.NODE_ENV === 'development') {
    const moment = require('moment');
    console.info('update', moment().format('YYYY-MM-DD HH:mm:ss a'));
  }

  return () => stage.unMount();
};
示例#16
0
const T        = require('ramda/src/T')
const take     = require('ramda/src/take')
const values   = require('ramda/src/values')
const uniq     = require('ramda/src/uniq')

const Card      = require('./card')
const { get }   = require('../lib/util')
const Footer    = require('./footer')
const Layout    = require('./layout')
const { paged } = require('../lib/animations')
const { setTag, showMore } = require('../ducks/signs')

const byTag = name =>
  name === 'all' ? T : compose(contains(name), prop('tags'))

const tags = compose(sortBy(I), uniq, append('all'), flatten, pluck('tags'), values)

const Signs = ({ images, signs }) => {
  const { cards, tag, page, pages } = signs,
        total = pages * page.size

  const select = compose(filter(byTag(tag)), map(get(images))),
        limit  = compose(take(total), select)

  return p('div.signs', [
    p('nav.tags.row', tags(images).map(name =>
      p('div.tag', {
        class: { active: tag === name },
        on: { click: [ setTag, name ] }
      }, name)
    )),
示例#17
0
exports.debug = label => tap(compose(debug(label), stringify))
示例#18
0
    window.removeEventListener("resize", this.updateDimensions);
  }

  updateDimensions() {
    // https://stackoverflow.com/questions/19014250/reactjs-rerender-on-browser-resize
    const {offset} = this.props;

    let documentElement = document.documentElement;
    let body = document.getElementsByTagName('body')[0];
    let height = window.innerHeight || documentElement.clientHeight || body.clientHeight;
    this.setState({height: height + (offset || 0)});
  }
  render() {
    const {classes, name, className, children} = this.props;
    const {height} = this.state;

    return (
      <div
        className={`${classes.browserView} ${className}`}
        data-sn={name || "browser-view"}
        style={{height: height}}
      >
        {children}
      </div>
    );
  }
}

const ftheme = injectSheet(styles);
export default compose(ftheme)(StatefulBrowserView);
示例#19
0
const connect = dispatch =>
  socket.onmessage = compose(dispatch, insertMessage, JSON.parse, prop('data'))
示例#20
0
const byTag = name =>
  name === 'all' ? T : compose(contains(name), prop('tags'))
  <span class=${CLASSNAMES.ITEM_TITLE}>${textFormatter(name)}</span>
  <pre class=${CLASSNAMES.ITEM_CONTENT}>${textFormatter(content)}</pre>
`);
const getResultItemElt = (searchString, encodeText) => ({ name, content, isEndOfSubsection }) => {
  const highlightText = wrapTextWithClass(CLASSNAMES.HIGHLIGHT);
  const highlightSearchString = compose(highlightText, encodeText)(searchString);
  const getResultItemEltFormattedInnerHTML =
    getResultItemEltInnerHTML(compose(highlightSearchString, encodeText));

  return createDivElt({
    className: getResultItemEltClassName(isEndOfSubsection),
    innerHTML: getResultItemEltFormattedInnerHTML(name, content),
  });
};

const getResultSectionEltId = compose(toLowerCase, replaceWithHyphens(' '));
export default encodeText => (items, searchString) => {
  const mainElt = getDOMNode(`.${CLASSNAMES.MAIN}`);
  const setMainEltValue = setDOMNodeValue(mainElt);
  const appendChildToMainElt = appendChildToDOMNode(mainElt);

  setMainEltValue('');

  if (!items || !items.length) {
    appendChildToMainElt(getNoResultsElt());
    return;
  }

  const getFormattedResultItemElt = getResultItemElt(searchString, encodeText);
  items.forEach((item) => {
    const sectionId = getResultSectionEltId(item.section);