Skip to content

Commit 02d77df

Browse files
committed
Merge develop
2 parents 10935e8 + 319c90f commit 02d77df

File tree

200 files changed

+11744
-7254
lines changed

Some content is hidden

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

200 files changed

+11744
-7254
lines changed

.eslintrc

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "airbnb",
2+
"extends": ["airbnb", "prettier"],
33
"parser": "babel-eslint",
44
"env": {
55
"browser": true,
@@ -16,12 +16,12 @@
1616
"import/no-unresolved": 0,
1717
"import/no-named-as-default": 2,
1818
"comma-dangle": 0, // not sure why airbnb turned this on. gross!
19-
"indent": [2, 2, {"SwitchCase": 1}],
19+
"indent": 0,
2020
"no-console": 0,
2121
"no-alert": 0,
2222
"no-underscore-dangle": 0,
2323
"max-len": [1, 120, 2, {"ignoreComments": true, "ignoreTemplateLiterals": true}],
24-
"quote-props": [1, "consistent-as-needed"],
24+
"quote-props": [1, "as-needed"],
2525
"no-unused-vars": [1, {"vars": "local", "args": "none"}],
2626
"consistent-return": ["error", { "treatUndefinedAsUnspecified": true }],
2727
"no-param-reassign": [2, { "props": false }],
@@ -60,10 +60,13 @@
6060
},
6161
"allowChildren": false
6262
}
63+
],
64+
"prettier/prettier": [
65+
"error"
6366
]
6467
},
6568
"plugins": [
66-
"react", "jsx-a11y", "import"
69+
"react", "jsx-a11y", "import", "prettier"
6770
],
6871
"settings": {
6972
"import/parser": "babel-eslint",

.github/workflows/deploy-staging.yml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Deploy to staging
2+
on:
3+
workflow_run:
4+
workflows: ["Test"]
5+
branches:
6+
- develop
7+
types:
8+
- completed
9+
env:
10+
PROJECT_ID: ${{ secrets.GKE_PROJECT }}
11+
GKE_CLUSTER: p5js-web-editor-cluster
12+
GKE_ZONE: us-east1-c
13+
DEPLOYMENT_NAME: web-editor-node
14+
IMAGE: ${{ secrets.DOCKER_USERNAME }}/p5.js-web-editor-staging
15+
jobs:
16+
push_to_registry:
17+
environment: staging
18+
name: Push Docker image to Docker Hub
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Check out the repo
22+
uses: actions/checkout@v2
23+
- name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v1
25+
- name: Login to Docker Hub
26+
uses: docker/login-action@v1
27+
with:
28+
username: ${{ secrets.DOCKER_USERNAME }}
29+
password: ${{ secrets.DOCKER_PASSWORD }}
30+
- name: Build and push to Docker Hub
31+
uses: docker/build-push-action@v2
32+
with:
33+
context: .
34+
file: ./Dockerfile
35+
pull: true
36+
push: true
37+
tags: |
38+
${{ env.IMAGE }}:${{ github.sha }}
39+
${{ env.IMAGE }}:latest
40+
target: production
41+
# Setup gcloud CLI
42+
- uses: google-github-actions/setup-gcloud@v0.2.0
43+
with:
44+
service_account_key: ${{ secrets.GKE_SA_KEY }}
45+
project_id: ${{ secrets.GKE_PROJECT }}
46+
47+
# Configure docker to use the gcloud command-line tool as a credential helper
48+
- run: |-
49+
gcloud --quiet auth configure-docker
50+
51+
# Get the GKE credentials so we can deploy to the cluster
52+
- uses: google-github-actions/get-gke-credentials@v0.2.1
53+
with:
54+
cluster_name: ${{ env.GKE_CLUSTER }}
55+
location: ${{ env.GKE_ZONE }}
56+
credentials: ${{ secrets.GKE_SA_KEY }}
57+
58+
# Deploy the Docker image to the GKE cluster
59+
- name: Deploy
60+
run: |-
61+
kubectl set image deployment/$DEPLOYMENT_NAME web-editor-app=index.docker.io/$IMAGE:$GITHUB_SHA --namespace=staging
62+
kubectl get services -o wide

.github/workflows/deploy.yml

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Deploy to production
2+
on:
3+
workflow_run:
4+
workflows: ["Test"]
5+
branches:
6+
- release
7+
types:
8+
- completed
9+
env:
10+
PROJECT_ID: ${{ secrets.GKE_PROJECT }}
11+
GKE_CLUSTER: p5js-web-editor-cluster
12+
GKE_ZONE: us-east1-c
13+
DEPLOYMENT_NAME: web-editor-node
14+
IMAGE: ${{ secrets.DOCKER_USERNAME }}/p5.js-web-editor
15+
jobs:
16+
push_to_registry:
17+
environment: production
18+
name: Push Docker image to Docker Hub
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Check out the repo
22+
uses: actions/checkout@v2
23+
- name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v1
25+
- name: Login to Docker Hub
26+
uses: docker/login-action@v1
27+
with:
28+
username: ${{ secrets.DOCKER_USERNAME }}
29+
password: ${{ secrets.DOCKER_PASSWORD }}
30+
- name: Build and push to Docker Hub
31+
uses: docker/build-push-action@v2
32+
with:
33+
context: .
34+
file: ./Dockerfile
35+
pull: true
36+
push: true
37+
tags: |
38+
${{ env.IMAGE }}:${{ github.sha }}
39+
${{ env.IMAGE }}:latest
40+
target: production
41+
# Setup gcloud CLI
42+
- uses: google-github-actions/setup-gcloud@v0.2.0
43+
with:
44+
service_account_key: ${{ secrets.GKE_SA_KEY }}
45+
project_id: ${{ secrets.GKE_PROJECT }}
46+
47+
# Configure docker to use the gcloud command-line tool as a credential helper
48+
- run: |-
49+
gcloud --quiet auth configure-docker
50+
51+
# Get the GKE credentials so we can deploy to the cluster
52+
- uses: google-github-actions/get-gke-credentials@v0.2.1
53+
with:
54+
cluster_name: ${{ env.GKE_CLUSTER }}
55+
location: ${{ env.GKE_ZONE }}
56+
credentials: ${{ secrets.GKE_SA_KEY }}
57+
58+
# Deploy the Docker image to the GKE cluster
59+
- name: Deploy
60+
run: |-
61+
kubectl set image deployment/$DEPLOYMENT_NAME web-editor-app=index.docker.io/$IMAGE:$GITHUB_SHA
62+
kubectl get services -o wide
63+

.github/workflows/test.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Test
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
name: Test and lint code base
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
- name: Use Node.js
12+
uses: actions/setup-node@v1
13+
with:
14+
node-version: '12.x'
15+
- run: npm install
16+
- run: npm run test
17+
- run: npm run lint
18+
19+

.prettierrc

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"arrowParens": "always",
3+
"bracketSpacing": true,
4+
"htmlWhitespaceSensitivity": "css",
5+
"insertPragma": false,
6+
"jsxBracketSameLine": false,
7+
"jsxSingleQuote": false,
8+
"parser": "babel",
9+
"printWidth": 80,
10+
"proseWrap": "never",
11+
"requirePragma": false,
12+
"semi": true,
13+
"singleQuote": true,
14+
"tabWidth": 2,
15+
"trailingComma": "none",
16+
"useTabs": false,
17+
"quoteProps": "as-needed"
18+
}

client/common/Button.jsx

+51-23
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { remSize, prop } from '../theme';
88
const kinds = {
99
block: 'block',
1010
icon: 'icon',
11-
inline: 'inline',
11+
inline: 'inline'
1212
};
1313

1414
// The '&&&' will increase the specificity of the
@@ -34,7 +34,7 @@ const StyledButton = styled.button`
3434
svg * {
3535
fill: ${prop('Button.default.foreground')};
3636
}
37-
37+
3838
&:hover:not(:disabled) {
3939
color: ${prop('Button.hover.foreground')};
4040
background-color: ${prop('Button.hover.background')};
@@ -115,7 +115,7 @@ const StyledIconButton = styled.button`
115115
border-radius: 50%;
116116
padding: ${remSize(8)} ${remSize(25)};
117117
line-height: 1;
118-
118+
119119
&:hover:not(:disabled) {
120120
color: ${prop('Button.hover.foreground')};
121121
background-color: ${prop('Button.hover.background')};
@@ -150,10 +150,24 @@ const StyledIconButton = styled.button`
150150
* A Button performs an primary action
151151
*/
152152
const Button = ({
153-
children, href, kind, iconBefore, iconAfter, 'aria-label': ariaLabel, to, type, ...props
153+
children,
154+
href,
155+
kind,
156+
iconBefore,
157+
iconAfter,
158+
'aria-label': ariaLabel,
159+
to,
160+
type,
161+
...props
154162
}) => {
155163
const hasChildren = React.Children.count(children) > 0;
156-
const content = <>{iconBefore}{hasChildren && <span>{children}</span>}{iconAfter}</>;
164+
const content = (
165+
<>
166+
{iconBefore}
167+
{hasChildren && <span>{children}</span>}
168+
{iconAfter}
169+
</>
170+
);
157171
let StyledComponent = StyledButton;
158172

159173
if (kind === kinds.inline) {
@@ -177,22 +191,36 @@ const Button = ({
177191
}
178192

179193
if (to) {
180-
return <StyledComponent kind={kind} as={Link} aria-label={ariaLabel} to={to} {...props}>{content}</StyledComponent>;
194+
return (
195+
<StyledComponent
196+
kind={kind}
197+
as={Link}
198+
aria-label={ariaLabel}
199+
to={to}
200+
{...props}
201+
>
202+
{content}
203+
</StyledComponent>
204+
);
181205
}
182206

183-
return <StyledComponent kind={kind} aria-label={ariaLabel} type={type} {...props}>{content}</StyledComponent>;
207+
return (
208+
<StyledComponent kind={kind} aria-label={ariaLabel} type={type} {...props}>
209+
{content}
210+
</StyledComponent>
211+
);
184212
};
185213

186214
Button.defaultProps = {
187-
'children': null,
188-
'disabled': false,
189-
'iconAfter': null,
190-
'iconBefore': null,
191-
'kind': kinds.block,
192-
'href': null,
215+
children: null,
216+
disabled: false,
217+
iconAfter: null,
218+
iconBefore: null,
219+
kind: kinds.block,
220+
href: null,
193221
'aria-label': null,
194-
'to': null,
195-
'type': 'button',
222+
to: null,
223+
type: 'button'
196224
};
197225

198226
Button.kinds = kinds;
@@ -202,39 +230,39 @@ Button.propTypes = {
202230
* The visible part of the button, telling the user what
203231
* the action is
204232
*/
205-
'children': PropTypes.element,
233+
children: PropTypes.element,
206234
/**
207235
If the button can be activated or not
208236
*/
209-
'disabled': PropTypes.bool,
237+
disabled: PropTypes.bool,
210238
/**
211239
* SVG icon to place after child content
212240
*/
213-
'iconAfter': PropTypes.element,
241+
iconAfter: PropTypes.element,
214242
/**
215243
* SVG icon to place before child content
216244
*/
217-
'iconBefore': PropTypes.element,
245+
iconBefore: PropTypes.element,
218246
/**
219247
* The kind of button - determines how it appears visually
220248
*/
221-
'kind': PropTypes.oneOf(Object.values(kinds)),
249+
kind: PropTypes.oneOf(Object.values(kinds)),
222250
/**
223251
* Specifying an href will use an <a> to link to the URL
224252
*/
225-
'href': PropTypes.string,
253+
href: PropTypes.string,
226254
/*
227255
* An ARIA Label used for accessibility
228256
*/
229257
'aria-label': PropTypes.string,
230258
/**
231259
* Specifying a to URL will use a react-router Link
232260
*/
233-
'to': PropTypes.string,
261+
to: PropTypes.string,
234262
/**
235263
* If using a button, then type is defines the type of button
236264
*/
237-
'type': PropTypes.oneOf(['button', 'submit']),
265+
type: PropTypes.oneOf(['button', 'submit'])
238266
};
239267

240268
export default Button;

0 commit comments

Comments
 (0)