Skip to content

Commit 9980ba4

Browse files
committed
React tutorial
1 parent c7bb091 commit 9980ba4

24 files changed

+11842
-8
lines changed

.gitignore

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
# misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*

.gitpod.Dockerfile

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
# FROM gitpod/workspace-full:latest
2-
FROM yyoncho/pgtk:1.0.2
1+
FROM yyoncho/pgtk:1.0.15
32

43
USER gitpod
5-
RUN echo "broadwayd :5 & GDK_BACKEND=broadway BROADWAY_DISPLAY=:5 /home/gitpod/emacs/src/emacs &" >> ~/.bashrc
4+
RUN echo 'broadwayd :5 & \n \
5+
pid=$(pidof emacs) \n \
6+
if [ -z $pid ] \n \
7+
then \n \
8+
GDK_BACKEND=broadway BROADWAY_DISPLAY=:5 /home/gitpod/emacs/src/emacs $FILE & \n \
9+
fi' >> ~/.bashrc

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/emacs-lsp/lsp-gitpod)
1+
[![lsp-mode JS React Project](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#FILE=%2Fworkspace%2Flsp-gitpod%2Fprojects%2Fmy-app%2Fsrc%2FApp.js/https://github.com/emacs-lsp/lsp-gitpod)

pgtk/Dockerfile

+11-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,17 @@ RUN sudo apt-get update && sudo apt-get install -y build-essential git autoconf
99
RUN sudo apt-get install libgtk-3-dev:amd64 -y
1010
RUN sudo apt-get install libgccjit-9-dev -y
1111
RUN ./autogen.sh
12-
RUN ./configure --with-pgtk --with-cairo --with-modules --with-native-compilation
13-
RUN make -j8
12+
RUN ./configure --with-pgtk --with-cairo --with-modules --with-native-compilation --with-json
13+
RUN NATIVE_FULL_AOT=1 make -j8
1414

1515
WORKDIR /home/gitpod/
1616

17-
RUN git clone https://github.com/yyoncho/elegant-emacs .emacs.d
18-
RUN sudo apt-get install fonts-roboto -y
17+
RUN mkdir /home/gitpod/.emacs.d
18+
19+
COPY configs/install-packages.el /tmp/install-packages.el
20+
RUN ~/emacs/src/emacs --batch -l /tmp/install-packages.el
21+
22+
COPY configs/install-servers.el /tmp/install-servers.el
23+
RUN ~/emacs/src/emacs --batch -l /tmp/install-servers.el
24+
25+
COPY configs/init.el /home/gitpod/.emacs.d/init.el

pgtk/configs/init.el

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
(package-initialize)
2+
3+
(tool-bar-mode -1)
4+
(menu-bar-mode -1)
5+
(scroll-bar-mode -1)
6+
7+
(load-theme 'doom-molokai t)
8+
(helm-mode)
9+
(helm-icons-enable)
10+
(require 'helm-xref)
11+
(define-key global-map [remap find-file] #'helm-find-files)
12+
(define-key global-map [remap execute-extended-command] #'helm-M-x)
13+
(define-key global-map [remap switch-to-buffer] #'helm-mini)
14+
(add-hook 'prog-mode-hook #'lsp)
15+
16+
(with-eval-after-load 'treemacs-icons
17+
(treemacs-resize-icons 15))
18+
19+
(setq gc-cons-threshold (* 100 1024 1024)
20+
read-process-output-max (* 1024 1024)
21+
company-idle-delay 0.0
22+
company-minimum-prefix-length 1
23+
24+
;; lock file will kill `npm start'
25+
create-lockfiles nil
26+
inhibit-splash-screen t
27+
inhibit-startup-message t
28+
29+
;; avoid resizing of popup while typing.
30+
company-tooltip-maximum-width 60
31+
company-tooltip-minimum-width 60
32+
33+
;; less noise
34+
company-frontends '(company-pseudo-tooltip-frontend)
35+
36+
;; less noise
37+
lsp-completion-show-detail nil
38+
lsp-completion-show-kind nil
39+
40+
helm-buffer-details-flag nil
41+
42+
lsp-idle-delay 0.1
43+
lsp-headerline-breadcrumb-enable t
44+
lsp-signature-function #'lsp-signature-posframe
45+
company-quickhelp-delay 0.1)
46+
47+
(with-eval-after-load 'dired
48+
(treemacs-icons-dired-mode))
49+
50+
(with-eval-after-load 'lsp-mode
51+
(require 'dap-chrome)
52+
(add-hook 'lsp-mode-hook #'lsp-enable-which-key-integration)
53+
(add-hook 'dired-mode-hook #'lsp-dired-mode)
54+
(yas-global-mode)
55+
(company-quickhelp-mode))

pgtk/configs/install-packages.el

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
(package-initialize)
2+
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t)
3+
(package-refresh-contents)
4+
5+
(package-install 'quelpa)
6+
(setq package-native-compile t)
7+
8+
9+
;; with plist enabled
10+
(quelpa '(lsp-mode :repo "yyoncho/lsp-mode" :fetcher github :branch "perf2" :files ("*.el" "clients/*.el")))
11+
12+
;; with jsonc-mode
13+
(quelpa '(json-mode :repo "kiennq/json-mode" :fetcher github))
14+
15+
(mapc #'package-install
16+
'(posframe yasnippet lsp-treemacs helm-lsp projectile hydra flycheck
17+
company avy which-key helm-xref dap-mode doom-themes
18+
company-quickhelp rust-mode php-mode scala-mode dart-mode
19+
clojure-mode all-the-icons treemacs-icons-dired helm-icons
20+
lsp-java lsp-dart lsp-metals lsp-ivy lsp-sourcekit
21+
magit))
22+
23+
(all-the-icons-install-fonts t)
24+
25+
(while (not (zerop (comp-async-runnings)))
26+
(message "Waiting for native compilation to finish. %s" (comp-async-runnings))
27+
(accept-process-output nil 1))

pgtk/configs/install-servers.el

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
(package-initialize)
2+
3+
(require 'lsp-mode)
4+
5+
(lsp-install-server nil 'ts-ls)
6+
(lsp-install-server nil 'eslint)
7+
8+
9+
(while (-filter #'lsp--client-download-in-progress? (ht-values lsp-clients))
10+
(message "Waiting server installation for %s"
11+
(-map #'lsp--client-server-id (-filter #'lsp--client-download-in-progress? (ht-values lsp-clients))))
12+
(accept-process-output nil 1))

projects/my-app/README.md

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Getting Started with Create React App
2+
3+
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4+
5+
## Available Scripts
6+
7+
In the project directory, you can run:
8+
9+
### `yarn start`
10+
11+
Runs the app in the development mode.\
12+
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
13+
14+
The page will reload if you make edits.\
15+
You will also see any lint errors in the console.
16+
17+
### `yarn test`
18+
19+
Launches the test runner in the interactive watch mode.\
20+
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21+
22+
### `yarn build`
23+
24+
Builds the app for production to the `build` folder.\
25+
It correctly bundles React in production mode and optimizes the build for the best performance.
26+
27+
The build is minified and the filenames include the hashes.\
28+
Your app is ready to be deployed!
29+
30+
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31+
32+
### `yarn eject`
33+
34+
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
35+
36+
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37+
38+
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
39+
40+
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
41+
42+
## Learn More
43+
44+
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45+
46+
To learn React, check out the [React documentation](https://reactjs.org/).
47+
48+
### Code Splitting
49+
50+
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
51+
52+
### Analyzing the Bundle Size
53+
54+
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
55+
56+
### Making a Progressive Web App
57+
58+
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
59+
60+
### Advanced Configuration
61+
62+
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
63+
64+
### Deployment
65+
66+
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
67+
68+
### `yarn build` fails to minify
69+
70+
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)

projects/my-app/package.json

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "my-app",
3+
"version": "0.1.0",
4+
"private": true,
5+
"dependencies": {
6+
"@testing-library/jest-dom": "^5.11.4",
7+
"@testing-library/react": "^11.1.0",
8+
"@testing-library/user-event": "^12.1.10",
9+
"react": "^17.0.2",
10+
"react-dom": "^17.0.2",
11+
"react-scripts": "4.0.3",
12+
"web-vitals": "^1.0.1"
13+
},
14+
"scripts": {
15+
"start": "react-scripts start",
16+
"build": "react-scripts build",
17+
"test": "react-scripts test",
18+
"eject": "react-scripts eject"
19+
},
20+
"eslintConfig": {
21+
"extends": [
22+
"react-app",
23+
"react-app/jest"
24+
]
25+
},
26+
"browserslist": {
27+
"production": [
28+
">0.2%",
29+
"not dead",
30+
"not op_mini all"
31+
],
32+
"development": [
33+
"last 1 chrome version",
34+
"last 1 firefox version",
35+
"last 1 safari version"
36+
]
37+
}
38+
}

projects/my-app/public/favicon.ico

3.78 KB
Binary file not shown.

projects/my-app/public/index.html

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1" />
7+
<meta name="theme-color" content="#000000" />
8+
<meta
9+
name="description"
10+
content="Web site created using create-react-app"
11+
/>
12+
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13+
<!--
14+
manifest.json provides metadata used when your web app is installed on a
15+
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
16+
-->
17+
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
18+
<!--
19+
Notice the use of %PUBLIC_URL% in the tags above.
20+
It will be replaced with the URL of the `public` folder during the build.
21+
Only files inside the `public` folder can be referenced from the HTML.
22+
23+
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
24+
work correctly both with client-side routing and a non-root public URL.
25+
Learn how to configure a non-root public URL by running `npm run build`.
26+
-->
27+
<title>React App</title>
28+
</head>
29+
<body>
30+
<noscript>You need to enable JavaScript to run this app.</noscript>
31+
<div id="root"></div>
32+
<!--
33+
This HTML file is a template.
34+
If you open it directly in the browser, you will see an empty page.
35+
36+
You can add webfonts, meta tags, or analytics to this file.
37+
The build step will place the bundled scripts into the <body> tag.
38+
39+
To begin the development, run `npm start` or `yarn start`.
40+
To create a production bundle, use `npm run build` or `yarn build`.
41+
-->
42+
</body>
43+
</html>

projects/my-app/public/logo192.png

5.22 KB
Loading

projects/my-app/public/logo512.png

9.44 KB
Loading

projects/my-app/public/manifest.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"short_name": "React App",
3+
"name": "Create React App Sample",
4+
"icons": [
5+
{
6+
"src": "favicon.ico",
7+
"sizes": "64x64 32x32 24x24 16x16",
8+
"type": "image/x-icon"
9+
},
10+
{
11+
"src": "logo192.png",
12+
"type": "image/png",
13+
"sizes": "192x192"
14+
},
15+
{
16+
"src": "logo512.png",
17+
"type": "image/png",
18+
"sizes": "512x512"
19+
}
20+
],
21+
"start_url": ".",
22+
"display": "standalone",
23+
"theme_color": "#000000",
24+
"background_color": "#ffffff"
25+
}

projects/my-app/public/robots.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# https://www.robotstxt.org/robotstxt.html
2+
User-agent: *
3+
Disallow:

projects/my-app/src/App.css

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
.App {
2+
text-align: center;
3+
}
4+
5+
.App-logo {
6+
height: 40vmin;
7+
pointer-events: none;
8+
}
9+
10+
@media (prefers-reduced-motion: no-preference) {
11+
.App-logo {
12+
animation: App-logo-spin infinite 20s linear;
13+
}
14+
}
15+
16+
.App-header {
17+
background-color: #282c34;
18+
min-height: 100vh;
19+
display: flex;
20+
flex-direction: column;
21+
align-items: center;
22+
justify-content: center;
23+
font-size: calc(10px + 2vmin);
24+
color: white;
25+
}
26+
27+
.App-link {
28+
color: #61dafb;
29+
}
30+
31+
@keyframes App-logo-spin {
32+
from {
33+
transform: rotate(0deg);
34+
}
35+
to {
36+
transform: rotate(360deg);
37+
}
38+
}

0 commit comments

Comments
 (0)