Skip to content

Commit 3af7f21

Browse files
Merge pull request #1 from topcoder-platform/develop
Initial commit with new code
2 parents 41534b5 + 5e91a32 commit 3af7f21

File tree

96 files changed

+10110
-31723
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+10110
-31723
lines changed

.babelrc

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
{
2-
"presets": ["@babel/preset-env", "@babel/preset-react"]
2+
"presets": [
3+
"@babel/preset-env",
4+
"@babel/preset-react"
5+
],
6+
"plugins": [
7+
"@babel/plugin-proposal-export-default-from"
8+
]
39
}

.eslintrc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": ["standard", "standard-react"],
3+
"parser": "babel-eslint"
4+
}

.gitignore

+4-59
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,7 @@
1-
# Logs
2-
logs
3-
*.log
4-
npm-debug.log*
5-
yarn-debug.log*
6-
yarn-error.log*
7-
8-
# Runtime data
9-
pids
10-
*.pid
11-
*.seed
12-
*.pid.lock
13-
14-
# Directory for instrumented libs generated by jscoverage/JSCover
15-
lib-cov
16-
17-
# Coverage directory used by tools like istanbul
18-
coverage
19-
20-
# nyc test coverage
21-
.nyc_output
22-
23-
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
24-
.grunt
25-
26-
# Bower dependency directory (https://bower.io/)
27-
bower_components
28-
29-
# node-waf configuration
30-
.lock-wscript
31-
32-
# Compiled binary addons (https://nodejs.org/api/addons.html)
33-
build/Release
34-
35-
# Dependency directories
36-
node_modules/
371
dist/
38-
jspm_packages/
39-
40-
# TypeScript v1 declaration files
41-
typings/
42-
43-
# Optional npm cache directory
44-
.npm
45-
46-
# Optional eslint cache
47-
.eslintcache
48-
49-
# Optional REPL history
50-
.node_repl_history
51-
52-
# Output of 'npm pack'
53-
*.tgz
54-
55-
# Yarn Integrity file
56-
.yarn-integrity
2+
node_modules/
573

58-
# dotenv environment variables file
59-
.env
4+
/*/
5+
!/src
606

61-
# next.js build output
62-
.next
7+
/index.js

.npmignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
node_modules/
2+
/src/
3+
4+
.*
5+
6+
build.js
7+
package-lock.json
8+
webpack.config.*

README.md

+31-15
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,38 @@
1-
# Topcoder - Navigation Component
1+
# Topcoder Navigation React
22

3-
## Install dependencies
3+
## Demo
44

5-
Run `npm install` to install the dependencies
5+
### Build the components
66

7-
## Build module
7+
Enter `navigation-component` and run:
88

9-
To build the module, run `npm run build`
9+
- `npm install`
10+
- `npm run build:lib`
1011

11-
## Usage
12+
### Run the demo
1213

13-
```shell
14-
# Go to other project which depends on the community-nav-prototype, config its package.json so
15-
# that the 'community-nav-prototype' points to the local foler path of community-nav-prototype:
16-
#
17-
# "dependencies": {
18-
# "community-nav-prototype": "<local-path-to-community-nav-prototype>",
19-
# ......
20-
# }
21-
#
14+
Run the following in the `navigation-component-demo` folder:
15+
16+
- `yarn`
17+
- `yarn start`
18+
19+
### Troubleshooting
20+
21+
If you encounter invalid hook call error while running the demo, then:
22+
23+
- delete navigation-component-demo/node_modules/navigation-component/node_modules/react
24+
- delete navigation-component-demo/node_modules/navigation-component/node_modules/react-dom
25+
26+
and try again.
27+
28+
## Getting Started
29+
30+
### Install
31+
32+
```
33+
npm i -D navigation-component
2234
```
35+
36+
### Assets
37+
38+
Copy `dist/font` and `dist/img` to web server root folder. You can put them nested in sub folder, but be sure to update `$font-path` and `$img-path` SASS variables in the `src/assets/sass/_global/_variables.scss`.

build.js

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
const fs = require('fs')
2+
const path = require('path')
3+
const rf = require('rimraf')
4+
const colors = require('colors/safe')
5+
const webpack = require('webpack')
6+
const baseConfig = require('./webpack.config.lib')
7+
8+
const srcDir = path.resolve(__dirname, 'src')
9+
const componentsDir = path.resolve(__dirname, 'src/components')
10+
11+
const files = fs.readdirSync(componentsDir)
12+
13+
const components = []
14+
15+
files.forEach(file => {
16+
const name = file.replace(path.extname(file), '')
17+
const config = Object.assign({}, baseConfig)
18+
config.entry = path.join(componentsDir, file)
19+
config.output.path = path.join(__dirname, name)
20+
config.output.filename = 'index.js'
21+
process.env.NODE_ENV === 'production' && rf.sync(config.output.path)
22+
webpack(config, handleError)
23+
components.push(name)
24+
})
25+
26+
const config = Object.assign({}, baseConfig)
27+
config.entry = path.join(srcDir, 'index.js')
28+
config.output.path = __dirname
29+
config.output.filename = 'index.js'
30+
components.forEach(comp => {
31+
config.externals[`./components/${comp}`] = `./${comp}`
32+
})
33+
webpack(config, handleError)
34+
35+
function handleError (err, stats) {
36+
if (err) {
37+
console.error(colors.red(err.stack || err))
38+
if (err.details) {
39+
console.error(colors.red(err.details))
40+
}
41+
}
42+
const info = stats.toJson()
43+
if (stats.hasErrors()) {
44+
info.errors.forEach(err => {
45+
console.error(colors.red(err))
46+
})
47+
}
48+
if (stats.hasWarnings()) {
49+
info.warnings.forEach(warn => {
50+
console.warn(colors.orange(warn))
51+
})
52+
}
53+
}

example/.gitignore

-23
This file was deleted.

example/README.md

-21
This file was deleted.

0 commit comments

Comments
 (0)