1.1.3 • Published 8 years ago

local-admin v1.1.3

Weekly downloads
-
License
ISC
Repository
bitbucket
Last release
8 years ago

✨ React with ant.design Admin Components ✨''

Prerequisite

  • Add local npm registry
    • npm set registry http://188.166.184.174:4873
    • npm adduser --registry http://188.166.184.174:4873
  • SCSS webpack loader
    • npm install --save-dev sass-loader node-sass
    • Add to your webpack module loaders
      {
        test: /\.scss$/,
        loaders: [
          'style',
          'css?modules&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]',
          'resolve-url',
          'sass'
      }
  • LESS webpack loader
    • npm install --save-dev less less-loader
    • Add to your webpack module loaders
      {
        test: /\.less$/,
        loader: ExtractTextPlugin.extract('style-loader', 'css-loader!less-loader')
      }
    • Import less file to your main app
      import 'antd/dist/antd.less'

Installation

  • npm install --save local-admin This will get package from local npm registry

Components

BREADCRUMB

API

PropertyTypeRequired
pathPath Arraytrue

Path Array

[
  {
    name: 'Home',
    path: '/'
  },
  {
    name: 'User',
    path: '/users'
  },
  {
    name: 'John Cena',
    path: '/users/JohnCena1988'
  }
]

CONTAINER

Example

<Container
Sidebar={Sidebar}
Header={Header}>
{this.props.chilrden}
</Container>

API

PropertyTypeRequired
SidebarSidebar Componentfalse
HeaderHeader Componentfalse

CROPPER

This is simple cropping image build on top of react-cropper

API

PropertyDescriptionTypeRequired
widthWidth of cropper previewNumberOptional
heightHeight of cropper previewNumberOptional
handleCropHandle cropping image return preview blob url and blob file(preview, file) =>Required

Cropper will calculate ratio from width and height default is square

HEADER

API

PropertyTypeRequiredDefault
logoImgstring or imagefalseplaceholder
logoPosition'center' or 'left'false'left'
menuMenu Objecttrue
userUser Objecttrue{}

User Object

PropertyTypeRequiredDefault
usernamestringfalsenull
first_namestringfalsenull
last_namestringfalsenull
imgstringfalseplaceholder

User can add more Property this for example only

  • Example
  {
    username: 'Jonh Cean 1988',
    first_name: 'Jonh',
    last_name: 'Cena',
    img: 'http://files.gamebanana.com/img/ico/sprays/5627f56c99b3a.png'
  }

Menu Object

Menu object is an array that contains menu context wrap by Menu from antd package

  • Example
[
  <Menu key="nav">
    <Menu.Item key="home">
      <Link to='/'>
        HOME
      </Link>
    </Menu.Item>
    <Menu.Item key="alert">
      <div onClick={() => alert('You can see me!')}>
        Alert
      </div>
    </Menu.Item>
  </Menu>
];

SIDEBAR

Example

<Sidebar menu={sidebarMenu} location={this.props.location} />

API

PropertyTypeRequired
menuMenu Objecttrue
locationlocation Objecttrue

Menu Object

Menu object is an array of object contain simple path and name

  • Example
const sidebarMenu = [
  {
    path: '/',
    name: 'Home'
  },
  {
    path: '/users',
    name: 'User'
  },
  {
    path: '/projects',
    name: 'Project'
  },
  {
    name: 'Setting',
    subMenu: [
      {
        path: '/user',
        name: 'User'
      }
    ]
  }
]
  • generate as

alt text

TABLE

API

PropertyTypeRequired
columnsArray of column objectRequire
dataarrayOptional
isLoadingBooleanOptional
emptyviewOptional

Column Object

PropertyDescriptionTypeRequired
titleHeader titleStringRequire
dataIndexData field to map withStringRequire
keyData field keyStringRequire
renderRender to the shape you want(text, record) => (...)Optional
sorterSort data in the table(a, b) => (...)Optional
  • Example

[
    {
      title: 'Name',
      dataIndex: 'name',
      key: 'name',
    },
    {
      title: 'Age',
      dataIndex: 'age',
      key: 'age',
      sorter: (a, b) => b.age - a.age, // return boolean
    }
]

Utility

handleChange

This will setState for your component

import { handleChange } from 'local-admin/lib/Utility'
constructor(props) {
  super(props)
  this.handleChange = handleChange.bind(this)
}

Reference

1.1.3

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago