<commit_before>import React from 'react';
import PropTypes from 'prop-types';
import { withRouter, Link } from 'olymp-router';
import { withAuth } from 'olymp-auth';
import { createComponent } from 'olymp-fela';
import { Button } from 'antd';

// todo: withAuth auslagern!

export default type => WrappedComponent => {
  const CreateButton = withRouter(
    createComponent(
      () => ({
        position: 'absolute',
        left: '50%',
        bottom: 1,
        transform: 'translate(-50%, 50%)',
        zIndex: 2,
      }),
      ({ className, pathname, query }) =>
        <Link
          to={{
            pathname,
            query: { ...query, [`@${type}`]: 'new', modal: null },
          }}
          className={className}
        >
          <Button type="primary" shape="circle" icon="plus" />
        </Link>,
      p => Object.keys(p)
    )
  );

  return withAuth(
    createComponent(
      ({ theme }) => ({
        position: 'relative',
        '> a:last-of-type': {
          display: 'none',
        },
        onHover: {
          onAfter: {
            position: 'absolute',
            bottom: 0,
            left: 0,
            width: '100%',
            height: 2,
            content: '""',
            borderTop: `2px solid ${theme.color}`,
            zIndex: 1,
          },
          '> a:last-of-type': {
            display: 'block',
          },
        },
      }),
      ({ className, auth, ...p }) =>
        auth && auth.user
          ? <div className={className}>
              <WrappedComponent {...p} />
              <CreateButton />
            </div>
          : <WrappedComponent {...p} />,
      p => Object.keys(p)
    )
  );
};<commit_msg>with-create second "+"<commit_after>import React from 'react';
import PropTypes from 'prop-types';
import { withRouter, Link } from 'olymp-router';
import { withAuth } from 'olymp-auth';
import { createComponent } from 'olymp-fela';
import { Button } from 'antd';

// todo: withAuth auslagern!

export default type => WrappedComponent => {
  const CreateButton = withRouter(
    createComponent(
      ({ top }) => ({
        position: 'absolute',
        left: '50%',
        top: top && 1,
        bottom: !top && 1,
        transform: top ? 'translate(-50%, -50%)' : 'translate(-50%, 50%)',
        zIndex: 2,
      }),
      ({ className, pathname, query }) =>
        <Link
          to={{
            pathname,
            query: { ...query, [`@${type}`]: 'new', modal: null },
          }}
          className={className}
        >
          <Button type="primary" shape="circle" icon="plus" />
        </Link>,
      p => Object.keys(p)
    )
  );

  return withAuth(
    createComponent(
      ({ theme }) => ({
        position: 'relative',
        '> a:last-of-type': {
          display: 'none',
        },
        onHover: {
          onBefore: {
            position: 'absolute',
            top: 0,
            left: 0,
            width: '100%',
            height: 2,
            content: '""',
            borderTop: `2px solid ${theme.color}`,
            zIndex: 1,
          },
          onAfter: {
            position: 'absolute',
            bottom: 0,
            left: 0,
            width: '100%',
            height: 2,
            content: '""',
            borderTop: `2px solid ${theme.color}`,
            zIndex: 1,
          },
          '> a:last-of-type': {
            display: 'block',
          },
        },
      }),
      ({ className, auth, ...p }) =>
        auth && auth.user
          ? <div className={className}>
              <CreateButton top />
              <WrappedComponent {...p} />
              <CreateButton />
            </div>
          : <WrappedComponent {...p} />,
      p => Object.keys(p)
    )
  );
};
{'fraction_non_alphanumeric': 0.1653815474607817, 'fraction_numerical': 0.011964902951342728, 'mean_word_length': 1.4668852459016393, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 40, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3824854', 'n_tokens_mistral': 1128, 'n_tokens_neox': 1088, 'n_words': 256}