Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Yossapol
/
wds-react
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit ae138ca6
authored
Feb 22, 2019
by
jutawuth nantawan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update doc
1 parent
d09647b4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
237 additions
and
14 deletions
README.md
README.md
View file @
ae138ca
...
@@ -10,8 +10,8 @@
...
@@ -10,8 +10,8 @@
|-- public/
|-- public/
|-- src/
|-- src/
|-- actions/
|-- actions/
|-- {action1}Action.js
x
|-- {action1}Action.js
|-- {action2}Action.js
x
|-- {action2}Action.js
|-- components/
|-- components/
|-- {group}/
|-- {group}/
|-- WDS{Component}Component.jsx
|-- WDS{Component}Component.jsx
...
@@ -23,12 +23,23 @@
...
@@ -23,12 +23,23 @@
|-- {style}Style.jsx
|-- {style}Style.jsx
|-- images/
|-- images/
|-- js/
|-- js/
|-- WDS{Component}Constant.jsx
|-- WDS{Component}Constant
s
.jsx
|-- WDS{Component}Controller.jsx
|-- WDS{Component}Controller.jsx
|-- history/
|-- history/
|-- history.js
x
|-- history.js
|-- pages/
|-- pages/
Same as Component and Template. Replace a "Component" or "Template" by "Page".
|-- {group}/
|-- WDS{Page}Page.jsx
|-- resources/
|-- styles/
|-- css/
|-- {style}.css
|-- jsx/
|-- {style}Style.jsx
|-- images/
|-- js/
|-- WDS{Page}Constants.jsx
|-- WDS{Page}Controller.jsx
|-- reducers/
|-- reducers/
|-- index.js
|-- index.js
|-- {reducer}Reducer.js
|-- {reducer}Reducer.js
...
@@ -41,12 +52,12 @@
...
@@ -41,12 +52,12 @@
|-- images/
|-- images/
|-- js/
|-- js/
|-- Constants/
|-- Constants/
|-- URLConstant.js
|-- URLConstant
s
.js
|-- {xxx}Constant.js
|-- {xxx}Constant
s
.js
|-- Controllers/
|-- Controllers/
|-- {xxx}Controller.js
|-- {xxx}Controller.js
|-- Utils/
|-- Utils/
|-- {xxx}Util.js
|-- {xxx}Util
s
.js
|-- routes/
|-- routes/
|-- {xxx}Routes.js
|-- {xxx}Routes.js
|-- templates/
|-- templates/
...
@@ -59,7 +70,7 @@
...
@@ -59,7 +70,7 @@
|-- {style}Style.jsx
|-- {style}Style.jsx
|-- images/
|-- images/
|-- js/
|-- js/
|-- WDS{Template}Constant.jsx
|-- WDS{Template}Constant
s
.jsx
|-- WDS{Component}Controller.jsx
|-- WDS{Component}Controller.jsx
|-- App.jsx
|-- App.jsx
|-- index.js
|-- index.js
...
@@ -70,29 +81,241 @@
...
@@ -70,29 +81,241 @@
```
```
## 2. Declaration
## 2. Declaration
### Constant
### Constant
##### Variable
##### Variable
123
ตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
ใหญ่
</u>
ทั้งหมด คั่นระหว่างคำด้วย "_" เช่น
```
javascript
// urlConstant.js
export
const
URI
=
"localhost:3000"
export
const
URL_LOGIN
=
URI
+
"/login"
```
##### Function
##### Function
123
ขึ้นต้นด้วย "_" ตามด้วยตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
เล็ก
</u>
คั่นระหว่างคำด้วยตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
ใหญ่
</u>
เฉพาะตัวอักษรตัวแรก
ตามด้วยตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
เล็ก
</u>
```
javascript
// wdsUtils.js
/**
* @param {string} errorType
* @param {string} msg
* @description fucntion for print log
* @author dev_name 01/01/2100
*/
export
const
_printLog
=
(
errorType
,
msg
)
=>
{
// TO DO
}
/**
* @param {string} input1
* @param {string} input2
* @return {string}
* @description fucntion add number
* @author dev_name 01/01/2100
*/
export
const
_calculateAdd
=
(
input1
,
input2
)
=>
{
return
input1
+
input2
}
```
การเขียน JS doc
```
javascript
// parameter input
// @param เว้นวรรค ตามด้วย "{ประเภทตัวแปร}" เว้นวรรค ตามด้วย "ชื่อตัวแปร"
@
param
{
data
type
}
parameter
// return output
// @return เว้นวรรค ตามด้วย "{ประเภทตัวแปร}"
@
return
{
data
type
}
// description of function
// @description เว้นวรรค ตามด้วยคำอธิบาย
@
description
description
// author dev_name date
// @author ชื่อผู้สร้าง วัน/เดือน/ปี (ค.ศ.)
@
author
dev_name
01
/
01
/
2100
```
### Variable
### Variable
123
ขึ้นต้นด้วยตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
เล็ก
</u>
คั่นระหว่างคำด้วยตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
ใหญ่
</u>
เฉพาะตัวอักษรตัวแรก
ตามด้วยตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
เล็ก
</u>
```
javascript
const
input1Parameter
let
input2Parameter
```
####Boolean Variable
ขึ้นต้นด้วยคำว่า "is" หรือ "has" ตามบริบทของการใช้งาน
```
javascript
const
isValid
=
true
const
hasChild
=
false
```
####Local Constant Variable
ตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
เล็ก
</u>
ทั้งหมด คั่นระหว่างคำด้วย "_"
```
javascript
const
page_name
=
"Home"
;
```
### Function
### Function
123
#### React Life Cycle Function
ขึ้นต้นด้วยตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
เล็ก
</u>
คั่นระหว่างคำด้วยตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
ใหญ่
</u>
เฉพาะตัวอักษรตัวแรก
ตามด้วยตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
เล็ก
</u>
```
javascript
componentDidMount
()
{
// To Do
}
```
#### Common Function
ขึ้นต้นด้วยตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
เล็ก
</u>
คั่นระหว่างคำด้วยตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
ใหญ่
</u>
เฉพาะตัวอักษรตัวแรก
ตามด้วยตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
เล็ก
</u>
```
javascript
onClick
=
(
e
)
=>
{
// Recommended
}
!!!
ไม่ควรใช้
function
แบบเดิม
เพราะต้อง
bind
function
เอง
function
onClick
(
e
)
{
// Not Recommended
}
```
#### Custom Function
ขึ้นต้นด้วย "_ " ตามด้วย ตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
เล็ก
</u>
คั่นระหว่างคำด้วยตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
ใหญ่
</u>
เฉพาะตัวอักษรตัวแรก
ตามด้วยตัวอักษรภาษาอังกฤษตัวพิมพ์
<u>
เล็ก
</u>
```
javascript
_validateFromSubmit
=
(
e
)
=>
{
// Recommended
}
!!!
ไม่ควรใช้
function
แบบเดิม
เพราะต้อง
bind
function
เอง
function
_validateFromSubmit
(
e
)
{
// Not Recommended
}
```
### Class
### Class
123
```
javascript
import
React
,
{
Component
,
Fragment
}
from
'react'
;
export
default
class
HomePage
extends
Component
{
render
()
{
return
(
<
Fragment
>
<
h1
>
Home
<
/h1
>
<
/Fragment
>
);
}
}
```
การตั้งชื่อ class
| | |
| --------- | ---- |
| Component | |
| Template | |
| Page | |
-
Component
-
Template
-
Page
### Import
```
javascript
// กลุ่มของ Dependency Library
import
React
,
{
Component
,
Fragment
}
from
'react'
;
import
Axios
from
'axios'
;
import
{
Form
,
Input
,
Button
}
from
'antd'
;
// กลุ่มของ Template
import
WDSHeaderTemplate
from
"../../template/common/WDSHeaderTemplate"
import
WDSFooterTemplate
from
"../../template/common/WDSFooterTemplate"
// กลุ่มของ Component
import
WDSTextfieldComponent
from
"../../component/common/WDSTextfieldComponent"
import
WDSDropdownComponent
from
"../../component/common/WDSDropdownComponent"
// กลุ่มของ Constants
import
*
as
UrlConstants
from
'../../resources/js/constants/urlConstants'
;
import
*
as
EventConstants
from
'../../resources/js/constants/eventConstants'
;
// กลุ่มของ Controller
import
*
as
CommonController
from
'../../resources/js/controller/commonController'
;
import
{
_printLog
,
_calculateAdd
}
from
'../../resources/js/controller/commonUtils'
;
// กลุ่มของรูปภาพ
import
Logo
from
'./resources/images/logo_login.png'
;
import
Icon
from
'./resources/images/icon.png'
;
// กลุ่มของ Style
import
{
Style
}
from
"../../resources/style/jax/wdsStyle"
import
'../../resources/style/css/style.css'
;
```
## 3. Event Handling
## 3. Event Handling
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment