Skip to content

Commit

Permalink
Merge branch 'cli' of https://github.com/williamluke4/Nitro into cli
Browse files Browse the repository at this point in the history
  • Loading branch information
williamluke4 committed Jun 13, 2020
2 parents 062416a + 5fc1090 commit 4d9f796
Show file tree
Hide file tree
Showing 51 changed files with 1,228 additions and 689 deletions.
5 changes: 1 addition & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{
"extends": [
"oclif",
"oclif-typescript"
]
"extends": ["oclif", "oclif-typescript"]
}
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
nitro
=====
# nitro

Creates NextJS WPAs from templates

Expand All @@ -9,11 +8,15 @@ Creates NextJS WPAs from templates
[![License](https://img.shields.io/npm/l/nitro.svg)](https://github.com/williamluke4/nitro/blob/master/package.json)

<!-- toc -->
* [Usage](#usage)
* [Commands](#commands)

- [Usage](#usage)
- [Commands](#commands)
<!-- tocstop -->

# Usage

<!-- usage -->

```sh-session
$ npm install -g @atto-byte/nitro
$ nitro COMMAND
Expand All @@ -25,11 +28,15 @@ USAGE
$ nitro COMMAND
...
```

<!-- usagestop -->

# Commands

<!-- commands -->
* [`nitro create [TEMPLATE]`](#nitro-create-template)
* [`nitro help [COMMAND]`](#nitro-help-command)

- [`nitro create [TEMPLATE]`](#nitro-create-template)
- [`nitro help [COMMAND]`](#nitro-help-command)

## `nitro create [TEMPLATE]`

Expand Down Expand Up @@ -65,4 +72,5 @@ OPTIONS
```

_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.1.0/src\commands\help.ts)_

<!-- commandsstop -->
38 changes: 18 additions & 20 deletions example/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
module.exports = {
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
extends: [
module.exports = {
parser: "@typescript-eslint/parser", // Specifies the ESLint parser
extends: [
"eslint:recommended",
'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin
'prettier/@typescript-eslint', // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
'plugin:prettier/recommended', // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
"plugin:@typescript-eslint/recommended", // Uses the recommended rules from the @typescript-eslint/eslint-plugin
"prettier/@typescript-eslint", // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
"plugin:prettier/recommended", // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
"plugin:react/recommended",
],
"env": {
"node": true,
"commonjs": true
env: {
node: true,
commonjs: true,
},
plugins:[
"react-hooks"
],
parserOptions: {
"ecmaFeatures": {
"jsx": true
plugins: ["react-hooks"],
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
sourceType: 'module', // Allows for the use of imports
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
sourceType: "module", // Allows for the use of imports
},
rules: {
"react/prop-types": 0,
"@typescript-eslint/explicit-function-return-type": 0,
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn"
}
};
"react-hooks/exhaustive-deps": "warn",
},
};
14 changes: 7 additions & 7 deletions example/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
semi: true,
trailingComma: 'all',
singleQuote: true,
printWidth: 120,
tabWidth: 2,
};
module.exports = {
semi: true,
trailingComma: "all",
singleQuote: true,
printWidth: 120,
tabWidth: 2,
};
8 changes: 5 additions & 3 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# **Nitro** - Next.js, Material UI, Auth0 and Typescript
# **Nitro** - Next.js, Material UI, Auth0 and Typescript

![GitHub stars](https://img.shields.io/github/stars/williamluke4/nitro.svg?style=for-the-badge)
![GitHub issues](https://img.shields.io/github/issues/williamluke4/nitro.svg?style=for-the-badge)
Expand All @@ -7,6 +7,7 @@
![NMST](nitro.gif)

##

- PR's are very welcome

- Please add `.env` to `.gitignore` before adding any secrets
Expand All @@ -18,8 +19,9 @@
- [YARN Setup](#yarn)

## Auth
- [Auth0 Setup](https://github.com/atto-byte/useAuth)
- Video On [Secrets and Environment Variables in Next.js and Now](https://www.youtube.com/watch?v=pRbQcy9f5ew)

- [Auth0 Setup](https://github.com/atto-byte/useAuth)
- Video On [Secrets and Environment Variables in Next.js and Now](https://www.youtube.com/watch?v=pRbQcy9f5ew)

## NPM

Expand Down
120 changes: 71 additions & 49 deletions example/components/Layout/User.tsx
Original file line number Diff line number Diff line change
@@ -1,76 +1,98 @@
import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import Avatar from '@material-ui/core/Avatar';
import { Typography, Button, Paper, List, ListItem, Popover } from '@material-ui/core';
import { useAuth } from 'use-auth0';
import ExitToApp from '@material-ui/icons/ExitToApp';
import React from "react";
import { makeStyles } from "@material-ui/core/styles";
import Avatar from "@material-ui/core/Avatar";
import {
Typography,
Button,
Paper,
List,
ListItem,
Popover,
} from "@material-ui/core";
import { useAuth } from "use-auth0";
import ExitToApp from "@material-ui/icons/ExitToApp";

const useStyles = makeStyles({
avatar: {
marginRight: 10
marginRight: 10,
},
root: {
marginLeft: "auto",
display: 'flex',
display: "flex",
padding: "10px 10px",
},
text: {
margin: 'auto'
margin: "auto",
},
dropDownIcon: {
marginRight: 8
}
marginRight: 8,
},
});

export function User() {
const classes = useStyles();
const { isAuthenticated, login, logout, user } = useAuth();
const [anchorEl, setAnchorEl] = React.useState<HTMLButtonElement | null>(null);
const handleOpen = (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
setAnchorEl(event.currentTarget)
}
const [anchorEl, setAnchorEl] = React.useState<HTMLButtonElement | null>(
null
);
const handleOpen = (
event: React.MouseEvent<HTMLButtonElement, MouseEvent>
) => {
setAnchorEl(event.currentTarget);
};
const handleClose = () => {
setAnchorEl(null);
}
};
const open = Boolean(anchorEl);
const id = open ? 'simple-popover' : undefined;
if(isAuthenticated() && user){
const id = open ? "simple-popover" : undefined;
if (isAuthenticated() && user) {
return (
<>
<Button aria-describedby={id} className={classes.root} onClick={handleOpen} color="secondary">
<Avatar alt={user.name} src={user.picture} className={classes.avatar} />
<Typography className={classes.text} variant="body2">{user.name}</Typography>
</Button>
<Popover
id={id}
open={open}
anchorEl={anchorEl}
onClose={handleClose}
anchorOrigin={{
vertical: 'bottom',
horizontal: 'right',
}}
transformOrigin={{
vertical: 'top',
horizontal: 'right',
}}
>
<Paper>
<List>
<ListItem button onClick={logout}>
<ExitToApp className={classes.dropDownIcon}/>
Logout
</ListItem>
</List>
</Paper>
<Button
aria-describedby={id}
className={classes.root}
onClick={handleOpen}
color="secondary"
>
<Avatar
alt={user.name}
src={user.picture}
className={classes.avatar}
/>
<Typography className={classes.text} variant="body2">
{user.name}
</Typography>
</Button>
<Popover
id={id}
open={open}
anchorEl={anchorEl}
onClose={handleClose}
anchorOrigin={{
vertical: "bottom",
horizontal: "right",
}}
transformOrigin={{
vertical: "top",
horizontal: "right",
}}
>
<Paper>
<List>
<ListItem button onClick={logout}>
<ExitToApp className={classes.dropDownIcon} />
Logout
</ListItem>
</List>
</Paper>
</Popover>
</>
);
} else {
return(
return (
<Button color="secondary" className={classes.root} onClick={login}>
Login
Login
</Button>
)
}
}
);
}
}
Loading

0 comments on commit 4d9f796

Please sign in to comment.