Skip to content

Commit

Permalink
add removing newLine
Browse files Browse the repository at this point in the history
  • Loading branch information
Keito654 committed May 8, 2024
1 parent 0c17ed1 commit fa40dd6
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,8 @@
"yaml",
"toml",
"astro",
],
"cSpell.words": [
"antfu"
]
}
3 changes: 3 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ import antfu from '@antfu/eslint-config'
export default antfu({
formatters: true,
react: true,
stylistic: {
semi: true,
},
})
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Container } from '@mui/material'
import { FunctionFrame } from 'components/atomic/FunctionFrame'
import { Comparsion } from 'components/organisms/Comparsion'
import { FullHalfConvert } from 'components/organisms/FullHalfConvert'
import { RemoveNewLine } from 'components/organisms/RemoveNewLine'

export const App: FC = () => {
return (
Expand All @@ -13,6 +14,9 @@ export const App: FC = () => {
<FunctionFrame>
<Comparsion />
</FunctionFrame>
<FunctionFrame>
<RemoveNewLine />
</FunctionFrame>
<a
target="_blank"
href="https://icons8.com/icon/IXoJG4Gjzs5g/change"
Expand Down
43 changes: 43 additions & 0 deletions src/components/organisms/RemoveNewLine.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { Box, Button, TextField } from '@mui/material';
import { TextBox } from 'components/atomic/TextBox';
import { type FC, useState } from 'react';

export const RemoveNewLine: FC = () => {
const [inputValue, setInputValue] = useState('');
const [removedValue, setRemovedValue] = useState('');

const handleClick = () => {
const result = inputValue.replace(/\r?\n|\r/g, '');
setRemovedValue(result);
};

return (
<>
<Box sx={{ fontSize: '2rem', marginBottom: '1ch' }}>全角半角変換</Box>
<TextBox
labelText="変換前のテキストを入力"
handleChange={(e) => {
setInputValue(e.target.value);
}}
/>
<Box
sx={{
display: 'flex',
justifyContent: 'space-around',
margin: '1ch 0',
}}
>
<Button variant="contained" onClick={handleClick}>
改行を取り除く
</Button>
</Box>
<TextField
label="変換後のテキスト"
value={removedValue}
fullWidth
margin="normal"
spellCheck={false}
/>
</>
);
};

0 comments on commit fa40dd6

Please sign in to comment.