VulcanJS / Vulcan-Starter

VulcanJS starter repo. Use as a base for your own VulcanJS projects.
MIT License
127 stars 88 forks source link

Help wanted: update starter packages for new ui-bootstrap package #50

Open SachaG opened 6 years ago

SachaG commented 6 years ago

Goal: remove all dependencies on react-bootstrap from Starter repo

The example packages currently rely a lot on Bootstrap in the form of dependencies on react-bootstrap. But we can now get rid of this dependency by replacing all Bootstrap components with their equivalent Vulcan component.

In other words, <Button/> imported from react-bootstrap becomes <Components.Button/>; which in turn can call a Bootstrap, Material, Semantic, etc. component according to which UI package is currently active.

You can see all currently available components here.

TODO:

SachaG commented 6 years ago

Since the dropdown component is probably the most complex to port, here is an example from zenshome.jp:

const UsersMenuItem = ({ showItem, name, isAdmin = false }) => showItem && (
  <div>
    <FormattedMessage id={`nav.${name}`} />
    {isAdmin && (
      <span className="users-menu-admin-marker">
        <FormattedMessage id="nav.admin_marker" />
      </span>
    )}
  </div>
);
const menuItems = [
  {
    name: 'account',
    to: '/account',
  },
  {
    name: 'users',
    to: '/admin/users',
    isAdmin: true,
  },
  {
    name: 'bookings',
    to: '/admin/bookings',
    isAdmin: true,
  },
  {
    name: 'rooms',
    to: '/admin/rooms',
    isAdmin: true,
  },
  {
    name: 'reviews',
    to: '/admin/reviews',
    isAdmin: true,
  },
  {
    name: 'neighborhoods',
    to: '/admin/neighborhoods',
    isAdmin: true,
  },
];
<Components.Dropdown
      variant="default"
      id="user-dropdown"
      trigger={
        <div className="dropdown-toggle-inner">
          <Components.Avatar size="small" user={currentUser} link={false} />
          <div className="users-menu-name">
            {Users.getDisplayName(currentUser)}
          </div>
        </div>
      }
      pullRight
      menuItems={[
        // menu items
        ...menuItems.map((item, index) => ({
          to: item.to,
          component: <UsersMenuItem {...item} key={index} index={index} showItem={showItem(item, currentUser)}/>,
        })),
        // log out
        {
          component: <FormattedMessage id="users.log_out" />,
          itemProps: {
            onClick: () => Meteor.logout(() => client.resetStore()),
          },
        },
      ]}
    />
SachaG commented 6 years ago

Oh and feel free to also submit PRs back to the core repo to improve the ui-bootstrap package.

SachaG commented 6 years ago

I'll probably work on this myself since there are no takers. Also a good chance to review/clean up the Forum code generally.

kabalin commented 6 years ago

I was going to take it. In fact I have done it partly.

SachaG commented 6 years ago

Oh in that case please do! I haven't actually started on this :)

kabalin commented 6 years ago

@SachaG yep, will do in that case, it is a good excercise for me :)

JstnEdr commented 6 years ago

There was an error coming up for many of the starter packages that were missing an import in the package.json file. I've added 'vulcan:ui-bootstrap@1.10.0' to all the starter package files and will submit a pull request.