Skip to content

Commit 82be49a

Browse files
authored
Merge pull request #1 from bc-chaz/step-1-app-foundation
feat(common): add app foundation
2 parents da05a48 + 5a8db3b commit 82be49a

File tree

9 files changed

+3356
-0
lines changed

9 files changed

+3356
-0
lines changed

.babelrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"presets": ["next/babel"],
3+
"plugins": [["styled-components", { "ssr": true }]]
4+
}

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# NextJS Sample App
2+
3+
This demo includes all of the files necessary to get started with a basic, hello world app. This app was built using NextJS, BigDesign, Typescript, and React.
4+
5+
## App Installation
6+
7+
To get the app running locally, follow these instructions:
8+
9+
1. [Use Node 10+](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm#checking-your-version-of-npm-and-node-js)
10+
2. Install npm packages
11+
- `npm install`
12+
3. Start your dev environment
13+
- `npm run dev`

next-env.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/// <reference types="next" />
2+
/// <reference types="next/types/global" />

package-lock.json

Lines changed: 3228 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "bc-nextjs-app",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"dev": "next",
8+
"build": "next build",
9+
"start": "next start",
10+
"test": "echo \"Error: no test specified\" && exit 1"
11+
},
12+
"keywords": [],
13+
"author": "",
14+
"license": "ISC",
15+
"dependencies": {
16+
"@bigcommerce/big-design": "^0.27.0",
17+
"next": "^10.0.5",
18+
"react": "^17.0.1",
19+
"react-dom": "^17.0.1",
20+
"styled-components": "^4.4.1"
21+
},
22+
"devDependencies": {
23+
"@types/node": "^14.14.22",
24+
"@types/react": "^17.0.0",
25+
"babel-plugin-styled-components": "^1.12.0",
26+
"typescript": "^4.1.3"
27+
}
28+
}

pages/_app.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { GlobalStyles } from '@bigcommerce/big-design';
2+
import type { AppProps } from 'next/app';
3+
4+
const MyApp = ({ Component, pageProps }: AppProps) => (
5+
<>
6+
<GlobalStyles />
7+
<Component {...pageProps} />
8+
</>
9+
);
10+
11+
export default MyApp;

pages/_document.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Needed for proper operation of styled components/ BigDesign
2+
// https://styled-components.com/docs/advanced#nextjs
3+
import Document, { DocumentContext } from 'next/document';
4+
import { ServerStyleSheet } from 'styled-components';
5+
6+
export default class MyDocument extends Document {
7+
static async getInitialProps(ctx: DocumentContext) {
8+
const sheet = new ServerStyleSheet();
9+
const originalRenderPage = ctx.renderPage;
10+
11+
try {
12+
ctx.renderPage = () =>
13+
originalRenderPage({
14+
enhanceApp: (App) => (props) => sheet.collectStyles(<App {...props} />),
15+
})
16+
17+
const initialProps = await Document.getInitialProps(ctx);
18+
19+
return {
20+
...initialProps,
21+
styles: (
22+
<>
23+
{initialProps.styles}
24+
{sheet.getStyleElement()}
25+
</>
26+
),
27+
};
28+
} finally {
29+
sheet.seal();
30+
}
31+
}
32+
}

pages/index.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Panel, Text } from '@bigcommerce/big-design';
2+
3+
const Index = () => (
4+
<Panel header="Homepage" margin="xxLarge">
5+
<Text>Hello world</Text>
6+
</Panel>
7+
);
8+
9+
export default Index;

tsconfig.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"lib": [
5+
"dom",
6+
"dom.iterable",
7+
"esnext"
8+
],
9+
"allowJs": true,
10+
"skipLibCheck": true,
11+
"strict": false,
12+
"forceConsistentCasingInFileNames": true,
13+
"noEmit": true,
14+
"esModuleInterop": true,
15+
"module": "esnext",
16+
"moduleResolution": "node",
17+
"resolveJsonModule": true,
18+
"isolatedModules": true,
19+
"jsx": "preserve"
20+
},
21+
"include": [
22+
"next-env.d.ts",
23+
"**/*.ts",
24+
"**/*.tsx"
25+
],
26+
"exclude": [
27+
"node_modules"
28+
]
29+
}

0 commit comments

Comments
 (0)