Skip to content

Commit

Permalink
feat: chosungIncludes 메서드를 문서에서 바로 사용해볼 수 있는 데모를 만듭니다. (#102)
Browse files Browse the repository at this point in the history
* chosungIncludes페이지 데모 만들기

* remove unnecessary file

* Update docs/src/components/demo/chosung-includes-demo.tsx

Co-authored-by: Jonghyeon Ko <[email protected]>

* Update docs/src/pages/docs/api/chosungIncludes.ko.mdx

Co-authored-by: Jonghyeon Ko <[email protected]>

* Update docs/src/pages/docs/api/chosungIncludes.en.mdx

Co-authored-by: Jonghyeon Ko <[email protected]>

* linting

* remove useEffect in import statement

* chore: remove unnecessary mdx title

* light모드 대응하기:

* change ^ => *

---------

Co-authored-by: Jonghyeon Ko <[email protected]>
Co-authored-by: Jonghyeon Ko <[email protected]>
  • Loading branch information
3 people committed May 25, 2024
1 parent 48ce65f commit 56fa610
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 7 deletions.
1 change: 1 addition & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"start": "next start"
},
"dependencies": {
"es-hangul": "workspace:*",
"next": "14.1.4",
"nextra": "^2.13.4",
"nextra-theme-docs": "^2.13.4",
Expand Down
47 changes: 47 additions & 0 deletions docs/src/components/demo/chosung-includes-demo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import React, { useState } from 'react';
import { chosungIncludes } from 'es-hangul';

export function ChosungIncludesDemo() {
const [searchWord, setSearchWord] = useState<string>('홍길동');
const [userInput, setUserInput] = useState<string>('ㅎㄱㄷ');

const result = chosungIncludes(searchWord, userInput);

return (
<div className="bg-gray-200 dark:bg-gray-800 rounded-lg shadow-md p-6 max-w-md mx-auto my-8">
<div className="mb-4">
<label htmlFor="searchWord" className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
Search Word
</label>
<input
id="searchWord"
type="text"
placeholder="Enter search word"
value={searchWord}
onChange={e => setSearchWord(e.target.value)}
className="w-full p-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 dark:focus:ring-blue-300"
/>
</div>
<div className="mb-4">
<label htmlFor="userInput" className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
User Input
</label>
<input
id="userInput"
type="text"
placeholder="Enter user input"
value={userInput}
onChange={e => setUserInput(e.target.value)}
className="w-full p-2 border border-gray-300 dark:border-gray-600 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 dark:focus:ring-blue-300"
/>
</div>
{result !== null && (
<p
className={`mt-4 text-lg ${result ? 'text-green-500 dark:text-green-400' : 'text-red-500 dark:text-red-400'}`}
>
Result: {result ? 'Match found' : 'No match'}
</p>
)}
</div>
);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
---
title: chosungIncludes
---
import { ChosungIncludesDemo } from '@/components/demo/chosung-includes-demo';

# chosungIncludes

Expand All @@ -21,3 +19,9 @@ chosungIncludes('00프론트엔드', 'ㅍㄹㅌ'); // true
chosungIncludes('프론트엔드', 'ㅍㅌ'); // false
chosungIncludes('프론트엔드', '푸롴트'); // false
```

## Demo

<br />

<ChosungIncludesDemo />
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
---
title: chosungIncludes
---
import { ChosungIncludesDemo } from '@/components/demo/chosung-includes-demo';

# chosungIncludes

Expand All @@ -21,3 +19,9 @@ chosungIncludes('00프론트엔드', 'ㅍㄹㅌ'); // true
chosungIncludes('프론트엔드', 'ㅍㅌ'); // false
chosungIncludes('프론트엔드', '푸롴트'); // false
```

## 사용해보기

<br />

<ChosungIncludesDemo />
1 change: 1 addition & 0 deletions docs/tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Config } from 'tailwindcss';

const config: Config = {
darkMode: 'class',
content: [
'./src/pages/**/*.{js,ts,jsx,tsx,mdx}',
'./src/components/**/*.{js,ts,jsx,tsx,mdx}',
Expand Down
3 changes: 2 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3787,6 +3787,7 @@ __metadata:
"@types/react": "npm:^18"
"@types/react-dom": "npm:^18"
autoprefixer: "npm:^10.0.1"
es-hangul: "workspace:*"
eslint: "npm:^8"
eslint-config-next: "npm:14.1.4"
next: "npm:14.1.4"
Expand Down Expand Up @@ -4003,7 +4004,7 @@ __metadata:
languageName: node
linkType: hard

"es-hangul@workspace:.":
"es-hangul@workspace:*, es-hangul@workspace:.":
version: 0.0.0-use.local
resolution: "es-hangul@workspace:."
dependencies:
Expand Down

0 comments on commit 56fa610

Please sign in to comment.