> ## Documentation Index
> Fetch the complete documentation index at: https://styleguide-nextjs.2smooth.io/llms.txt
> Use this file to discover all available pages before exploring further.

# การเขียน commit ที่ดี

export const CLASSIFICATION_TERMS = {
  positive: {
    must: '+MUST',
    should: '+SHOULD',
    optional: '+OPTIONAL'
  },
  negative: {
    must: '-MUST',
    should: '-SHOULD',
    optional: '-OPTIONAL'
  }
};

export const TextHighlight = ({text = '', positive = false, negative = false}) => {
  let textColor = undefined;
  let bgColor = undefined;
  if (positive) {
    textColor = 'black';
    bgColor = 'oklch(72.77% 0.1798 128.27)';
  }
  if (negative) {
    textColor = 'black';
    bgColor = 'oklch(51.73% 0.2119 28.74)';
  }
  return <div style={{
    display: 'inline-block',
    fontWeight: 'bold',
    paddingLeft: '4px',
    paddingRight: '4px',
    border: '1px solid',
    borderRadius: '8px',
    color: textColor,
    backgroundColor: bgColor
  }}>
      {text}
    </div>;
};

## ข้อกำหนด

* <TextHighlight positive text={ CLASSIFICATION_TERMS.positive.must } /> จะต้องใช้ภาษาอังกฤษทั้งหมด
* <TextHighlight negative text={ CLASSIFICATION_TERMS.negative.must } /> ห้ามรวบทุกอย่างที่ทำอยู่ใน commit เดียว
* <TextHighlight positive text={ CLASSIFICATION_TERMS.positive.should } /> ควร commit สิ่งที่ทำภายในวันนั้นๆ
* [Reference](https://www.conventionalcommits.org/th/v1.0.0/)

## รูปแบบ Format

```sh theme={null}
<ประเภท>(<ขอบเขต>): <รายละเอียด>
/// หรือ
<type>(<scope>): <subject>
```

* ตัวอย่าง (จะต้องใช้ภาษาอังกฤษทั้งหมด)
  * `feat: create login page`
  * `feat(login): form validation`
  * `fix: loading indicator not disappear`
  * `fix(profile): incorrect data display`
  * `refactor(utils): make variables in numeric-formatter to be more descriptive`
  * `perf: simplify/adjust the process flow`
  * `docs: update README.md`
  * `build: add antd package deps`
  * `chore: update package.json script`
  * `ops: add Dockerfile`
  * `ci: setup github action config`

## ประเภท Type

* `fix`: เป็นการ Commit ที่แก้ไข bugs/issues
* `feat`: เป็นการ Commit ที่เป็นการ เพิ่ม/ลด feature หรือ เปลี่ยนแปลงผลลัพธ์
* `refactor`: เป็นการ Commit ที่ แก้ไข code ให้ดีขึ้น โดย **ไม่** เปลี่ยนแปลงผลลัพธ์
  * `perf`: เป็นการ Commit ที่เป็นส่วนหนึ่งของ `refactor` แต่เจาะจงไปในส่วนที่เกี่ยวกับ performance
  * `style`: เป็นการ Commit ที่เกี่ยวกับการจัดโค้ด เช่น การเว้นวรรค, ใส่ semi-colons, หรือ อื่นๆ
* `test`: เป็นการ Commit ที่เกี่ยวกับการ เพิ่ม/แก้ไข/ลบ test script
* `docs`: เป็นการ Commit ที่เกี่ยวกับการเขียน documentation เท่านั้น
* `build`: เป็นการ Commit ที่เกี่ยวกับ build tool, ci pipeline, dependencies, หรือ project version
* `ops`: เป็นการ Commit ที่เกี่ยวกับ deployment, backup, หรือ recovery
  * `ci`: เป็นการ Commit ที่เกี่ยวกับ CI config
* `chore`: เป็นการ Commit ในเรื่องทั่วไป ที่ส่งผลเฉพาะภายใน project เช่นการแก้ `.gitignore`

## ขอบเขต Scope

* <TextHighlight positive text={ CLASSIFICATION_TERMS.positive.optional } /> ระบุขอบเขตของ commit ว่าเป็นส่วนไหน

## รายละเอียด Subject

* <TextHighlight positive text={ CLASSIFICATION_TERMS.positive.must } /> ระบุสิ่งที่ทำใน commit นั้นๆ โดยสรุป ไม่สั้นจนเกินไป
