Skip to content

Commit 07c04b5

Browse files
committed
initial commit
0 parents  commit 07c04b5

15 files changed

+560
-0
lines changed

.eslintignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
test/coverage/
2+
es/
3+
lib/
4+
umd/

.eslintrc

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"node": true,
5+
"es6": true
6+
},
7+
"extends": ["eslint:recommended", "plugin:react/recommended"],
8+
"parser": "babel-eslint",
9+
"parserOptions": {
10+
"sourceType": "module",
11+
"ecmaFeatures": {
12+
"jsx": true,
13+
"arrowFunctions": true,
14+
"blockBindings": true,
15+
"defaultParams": true,
16+
"destructuring": true,
17+
"forOf": true,
18+
"generators": true,
19+
"objectLiteralComputedProperties": true,
20+
"objectLiteralShorthandMethods": true,
21+
"objectLiteralShorthandProperties": true,
22+
"experimentalObjectRestSpread": true,
23+
"restParams": true,
24+
"spread": true,
25+
"templateStrings": true,
26+
"modules": true,
27+
"classes": true
28+
}
29+
},
30+
"plugins": [
31+
"react"
32+
],
33+
"root": true,
34+
"rules": {
35+
"comma-dangle": 0,
36+
"linebreak-style": 0
37+
},
38+
"settings": {
39+
"react": {
40+
"createClass": "createReactClass", // Regex for Component Factory to use,
41+
// default to "createReactClass"
42+
"pragma": "React", // Pragma to use, default to "React"
43+
"version": "16.8", // React version, default to the latest React stable release
44+
"flowVersion": "0.81" // Flow version
45+
},
46+
"propWrapperFunctions": [ "forbidExtraProps" ] // The names of any functions used to wrap the
47+
// propTypes object, e.g. `forbidExtraProps`.
48+
// If this isn't set, any propTypes wrapped in
49+
// a function will be skipped.
50+
}
51+
}

.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# See https://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# dependencies
4+
node_modules
5+
/node_modules
6+
package-lock.json
7+
8+
# testing
9+
/demo/dist
10+
11+
# testing
12+
/coverage
13+
14+
# production
15+
/es
16+
/lib
17+
/umd
18+
19+
# misc
20+
.DS_Store
21+
.idea
22+
23+
npm-debug.log*

CHANGELOG.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
### [@coreui/icons-react](https://coreui.io/) changelog
2+
3+
##### `1.0.0-alpha.0`
4+
- initial version
5+
6+
install:
7+
```bash
8+
npm install @coreui/icons-react
9+
```
10+
11+
import:
12+
```jsx
13+
import { CIcon, CIconRaw } from '@coreui/icons-react';
14+
import { cifAu } from '@coreui/icons';
15+
```
16+
```scss
17+
@import '~@coreui/icons/css/all.css';
18+
```
19+
20+
usage:
21+
```jsx
22+
...
23+
class CoreUIIcons extends Component {
24+
...
25+
render() {
26+
return (
27+
<CIconRaw name='cifAu' size="2xl"/>
28+
<CIcon name="cil-list" size="2xl"/>
29+
)
30+
}
31+
...
32+
```

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 creativeLabs Łukasz Holeczek
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

NWB.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
## Prerequisites
2+
3+
[Node.js](http://nodejs.org/) >= v4 must be installed.
4+
5+
## Installation
6+
7+
- Running `npm install` in the component's root directory will install everything you need for development.
8+
9+
## Demo Development Server
10+
11+
- `npm start` will run a development server with the component's demo app at [http://localhost:3000](http://localhost:3000) with hot module reloading.
12+
13+
## Running Tests
14+
15+
- `npm test` will run the tests once.
16+
17+
- `npm run test:coverage` will run the tests and produce a coverage report in `coverage/`.
18+
19+
- `npm run test:watch` will run the tests on every change.
20+
21+
## Building
22+
23+
- `npm run build` will build the component for publishing to npm and also bundle the demo app.
24+
25+
- `npm run clean` will delete built resources.

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
### [@coreui/icons-react](https://coreui.io/) for [CoreUI for React](https://coreui.io/react/)
2+
3+
[![npm package][npm-badge]][npm]
4+
[![NPM downloads][npm-download]][npm]
5+
6+
[npm-badge]: https://img.shields.io/npm/v/@coreui/icons-react/latest?style=flat-square
7+
[npm]: https://www.npmjs.com/package/@coreui/icons-react
8+
[npm-download]: https://img.shields.io/npm/dm/@coreui/icons-react.svg?style=flat-square
9+
10+
- bootstrapped with [nwb](https://github.com/insin/nwb) toolkit
11+
12+
#### `npm run` scripts
13+
14+
`package.json` is configured with `"scripts"` we can use with `npm run` while developing the project.
15+
16+
Command | Description |
17+
--- | ---
18+
`npm start` | start a development server for the demo app
19+
`npm test` | run tests
20+
`npm run test:coverage` | run tests and produce a code coverage report in `coverage/`
21+
`npm run test:watch` | start a test server and re-run tests on every change
22+
`npm run build` | prepare for publishing to npm
23+
`npm run clean` | delete built resources
24+
25+
#### see also:
26+
- [Developing React Components and Libraries with nwb](https://github.com/insin/nwb/blob/master/docs/guides/ReactComponents.md#developing-react-components-and-libraries-with-nwb)

link.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
npm link ../coreui-pro-react-admin-template/node_modules/react
2+
npm link ../coreui-pro-react-admin-template/node_modules/react-dom
3+
npm link ../coreui-pro-react-admin-template/node_modules/react-router-dom

nwb.config.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = {
2+
type: 'react-component',
3+
npm: {
4+
esModules: true,
5+
umd: {
6+
global: 'CoreUIReact',
7+
externals: {
8+
react: 'React',
9+
'react-dom': 'ReactDom',
10+
'react-router': 'ReactRouter',
11+
'react-router-dom': 'ReactRouterDom',
12+
'@coreui/react' : 'CoreUIReact'
13+
}
14+
}
15+
}
16+
}

package.json

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{
2+
"name": "@coreui/icons-react",
3+
"version": "1.0.0-alpha.0",
4+
"description": "CoreUI Icons React component",
5+
"license": "MIT",
6+
"homepage": "https://coreui.io",
7+
"author": {
8+
"name": "CoreUI",
9+
"url": "https://coreui.io",
10+
"github": "https://github.com/coreui",
11+
"twitter": "https://twitter.com/core_ui"
12+
},
13+
"contributors": [
14+
{
15+
"name": "CoreUI Team",
16+
"url": "https://github.com/orgs/coreui/people"
17+
}
18+
],
19+
"repository": {
20+
"type": "git",
21+
"url": "https://github.com/coreui/coreui-icons-react.git"
22+
},
23+
"bugs": {
24+
"url": "https://github.com/coreui/coreui-icons-react/issues"
25+
},
26+
"main": "lib/index.js",
27+
"module": "es/index.js",
28+
"files": [
29+
"css/",
30+
"es/",
31+
"lib/",
32+
"umd/",
33+
"README.md"
34+
],
35+
"scripts": {
36+
"build": "nwb build-react-component --copy-files --no-demo",
37+
"clean": "nwb clean-module && nwb clean-demo",
38+
"lint": "eslint src",
39+
"link": "npm link @coreui/react"
40+
},
41+
"dependencies": {
42+
"classnames": "^2.2.6",
43+
"core-js": "^3.6.4",
44+
"prop-types": "^15.7.2"
45+
},
46+
"peerDependencies": {
47+
"@coreui/react": "^3.0.0-alpha.1",
48+
"react": "^16.12.0"
49+
},
50+
"devDependencies": {
51+
"@coreui/icons": "^1.0.1",
52+
"babel-eslint": "^10.0.3",
53+
"enzyme": "^3.11.0",
54+
"enzyme-adapter-react-16": "^1.15.2",
55+
"eslint": "^6.8.0",
56+
"eslint-plugin-import": "^2.20.1",
57+
"eslint-plugin-react": "^7.18.3",
58+
"nwb": "^0.23.0",
59+
"react-app-polyfill": "^1.0.6",
60+
"sinon": "^5.1.1"
61+
},
62+
"keywords": [
63+
"coreui",
64+
"coreui-icons",
65+
"coreui-react",
66+
"icons",
67+
"svg",
68+
"svg-icons",
69+
"layout",
70+
"component",
71+
"react"
72+
]
73+
}

src/CIcon.js

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import 'react-app-polyfill/ie11'; // For IE 11 support
2+
import 'react-app-polyfill/stable';
3+
import React from 'react';
4+
import PropTypes from 'prop-types';
5+
import classNames from 'classnames';
6+
import { mapToCssModules } from '@coreui/react';
7+
import CIconRaw from './CIconRaw';
8+
import style from './CIcon.module.css';
9+
10+
//component - CoreUI / CIcon
11+
12+
const CIcon = props=>{
13+
14+
const {
15+
tag: Tag,
16+
className,
17+
cssModule,
18+
//
19+
name,
20+
size,
21+
...attributes
22+
} = props;
23+
24+
//render
25+
26+
let type = 'svg';
27+
28+
if (typeof name == 'object'){
29+
switch(name.type){
30+
case 'class':
31+
type = 'class';
32+
break;
33+
default:
34+
}
35+
}
36+
37+
if (type=='svg'){
38+
return (
39+
<CIconRaw {...attributes} name={name} size={size} className={className} />
40+
);
41+
}
42+
43+
const classes = (classNames(
44+
mapToCssModules(className, Object.assign(style, cssModule)),
45+
type=='name' ? name :
46+
type=='class' ? name.className : null,
47+
size ? 'c-icon-'+size : null
48+
));
49+
50+
return (
51+
<Tag {...attributes} className={classes} />
52+
);
53+
54+
}
55+
56+
CIcon.propTypes = {
57+
tag: PropTypes.string,
58+
className: PropTypes.string,
59+
cssModule: PropTypes.object,
60+
//
61+
name: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
62+
size: PropTypes.string
63+
};
64+
65+
CIcon.defaultProps = {
66+
tag: 'i'
67+
};
68+
69+
export default CIcon;

0 commit comments

Comments
 (0)