|
1 | | -'use client'; |
2 | | -import styled from '@emotion/styled'; |
3 | | -import React, { useCallback } from 'react'; |
4 | | -import { Controller, FormProvider } from 'react-hook-form'; |
5 | | -import { Col, Form, Grid, Panel, Row, ButtonToolbar } from 'rsuite'; |
6 | | -import { AppLayout } from '@/Layout/App'; |
7 | | -import { |
8 | | - characterCountWithoutSpace, |
9 | | - characterCountWithSpace, |
10 | | - fullWidthCharacterCount, |
11 | | - halfWidthCharacterCount, |
12 | | - linesCount, |
13 | | - spaceCount, |
14 | | -} from '@/app/character_count/CharacterCountLib'; |
15 | | -import { Editor } from '@/components/common/Editor'; |
16 | | -import { ClearButton } from '@/components/common/Form/ClearButton'; |
17 | | -import { LabelInput } from '@/components/common/Form/LabelInput'; |
18 | | -import { useCustomForm } from '@/components/common/Form/useCustomForm'; |
19 | | -import { PageTitle } from '@/components/common/PageTitle'; |
20 | | -import { PanelHeader } from '@/components/common/PanelHeader'; |
| 1 | +import React, { FC } from 'react'; |
| 2 | +import { CharacterCount } from '@/app/character_count/CharacterCount'; |
21 | 3 |
|
22 | | -type characterCountForm = { |
23 | | - input: string; |
| 4 | +export const metadata = { |
| 5 | + title: 'Dev Toolkit - 文字数カウント', |
24 | 6 | }; |
25 | 7 |
|
26 | | -const CharacterCountPage: React.FC = () => { |
27 | | - const methods = useCustomForm<characterCountForm>({ |
28 | | - defaultValues: { |
29 | | - input: '', |
30 | | - }, |
31 | | - }); |
32 | | - const { control, watch } = methods; |
33 | | - |
34 | | - const title = '文字数カウント'; |
35 | | - const input = watch('input', ''); |
36 | | - |
37 | | - const characterCountValue = characterCountWithSpace(input).toString(); |
38 | | - const characterCountWithoutSpaceValue = characterCountWithoutSpace(input).toString(); |
39 | | - const spaceCharacterCountValue = spaceCount(input).toString(); |
40 | | - const fullWidthCharacterCountValue = fullWidthCharacterCount(input).toString(); |
41 | | - const halfWidthCharacterCountValue = halfWidthCharacterCount(input).toString(); |
42 | | - const linesCountValue = linesCount(input).toString(); |
43 | | - |
44 | | - return ( |
45 | | - <FormProvider {...methods}> |
46 | | - <AppLayout title={title}> |
47 | | - <Grid fluid> |
48 | | - <PageTitle title={title} /> |
49 | | - <Row gutter={5}> |
50 | | - <Col xs={24} md={12}> |
51 | | - <Panel |
52 | | - bordered |
53 | | - header={ |
54 | | - <PanelHeader |
55 | | - title="カウントする文字列" |
56 | | - right={ |
57 | | - <ButtonToolbar> |
58 | | - <ClearButton name="input" /> |
59 | | - </ButtonToolbar> |
60 | | - } |
61 | | - /> |
62 | | - } |
63 | | - > |
64 | | - <Controller |
65 | | - render={({ field }) => <Editor {...field} ref={null} />} |
66 | | - name="input" |
67 | | - control={control} |
68 | | - /> |
69 | | - </Panel> |
70 | | - </Col> |
71 | | - <Col xs={24} md={12}> |
72 | | - <Panel bordered header={<PanelHeader title="文字数" />}> |
73 | | - <ConvertedForm layout="horizontal"> |
74 | | - <LabelInput label="文字数(スペース込み)" value={characterCountValue} /> |
75 | | - <LabelInput label="文字数(スペース除)" value={characterCountWithoutSpaceValue} /> |
76 | | - <LabelInput label="スペースの数" value={spaceCharacterCountValue} /> |
77 | | - <LabelInput label="全角文字数" value={fullWidthCharacterCountValue} /> |
78 | | - <LabelInput label="半角文字数" value={halfWidthCharacterCountValue} /> |
79 | | - <LabelInput label="行数" value={linesCountValue} /> |
80 | | - </ConvertedForm> |
81 | | - </Panel> |
82 | | - </Col> |
83 | | - </Row> |
84 | | - </Grid> |
85 | | - </AppLayout> |
86 | | - </FormProvider> |
87 | | - ); |
| 8 | +const CharacterCountPage: FC = () => { |
| 9 | + return <CharacterCount />; |
88 | 10 | }; |
89 | 11 |
|
90 | | -const ConvertedForm = styled(Form)` |
91 | | - > div:not(:last-child) { |
92 | | - margin-bottom: 12px !important; |
93 | | - } |
94 | | -`; |
95 | | - |
96 | 12 | export default CharacterCountPage; |
0 commit comments