-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f3f026b
commit 0d6a1fa
Showing
15 changed files
with
331 additions
and
245 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.next | ||
node_modules | ||
next.config.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"tabWidth": 2, | ||
"semi": false, | ||
"singleQuote": true | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,72 @@ | ||
h1 { | ||
.wrapper { | ||
padding: 12px; | ||
margin-bottom: 20px; | ||
text-align: center; | ||
} | ||
|
||
h2 { | ||
margin-left: 24px; | ||
width: 104px; | ||
border: 2px solid #333; | ||
padding-left: 8px; | ||
header { | ||
max-width: 800px; | ||
margin: 0 auto; | ||
text-align: center; | ||
background-color: lightgray; | ||
padding: 20px 0; | ||
} | ||
|
||
h1 { | ||
font-size: xx-large; | ||
} | ||
|
||
.check { | ||
main { | ||
width: 100%; | ||
max-width: 800px; | ||
margin: 0 auto; | ||
display: flex; | ||
flex-wrap: wrap; | ||
padding: 10px; | ||
justify-content: flex-start; | ||
justify-self: auto; | ||
flex-direction: column; | ||
align-items: center; | ||
} | ||
section { | ||
width: 100%; | ||
margin-top: 20px; | ||
} | ||
|
||
h2 { | ||
margin: 1rem auto; | ||
} | ||
p { | ||
text-align: center; | ||
} | ||
|
||
ul { | ||
list-style-type: none; | ||
} | ||
|
||
.prefContent { | ||
display: grid; | ||
grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); | ||
gap: 1rem; | ||
margin: 0; | ||
padding: 20px; | ||
border-radius: 8px; | ||
border: 2px solid lightgray; | ||
} | ||
|
||
.populationContent { | ||
max-width: 800px; | ||
padding: 40px 12px 16px 4px; | ||
border-radius: 8px; | ||
border: 2px solid lightgray; | ||
} | ||
|
||
.check-item { | ||
width: 160px;; | ||
margin-bottom: 10px; | ||
} | ||
button { | ||
width: 100%; | ||
font-weight: bold; | ||
border: none; | ||
padding: 12px; | ||
background-color: darkmagenta; | ||
color: white; | ||
border-radius: 8px; | ||
cursor: pointer; | ||
} | ||
button:hover { | ||
background-color: magenta; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,27 @@ | ||
'use client' | ||
import { useRef, useState } from 'react' | ||
import CheckboxList from '@/components/CheckboxList' | ||
import Graph from '@/components/Graph' | ||
|
||
import { useState } from 'react' | ||
|
||
import { ButtonList } from '@/components/ButtonList' | ||
import { Chart } from '@/components/Chart' | ||
|
||
export default function Home() { | ||
const [selectedPref, setSelectedPref] = useState<number[]>([]) | ||
const [selected, setSelected] = useState<number[]>([]) | ||
|
||
return ( | ||
<main> | ||
<h1>都道府県別人口推移</h1> | ||
<CheckboxList setSelectedPref={setSelectedPref} /> | ||
<Graph selectedPref={selectedPref} /> | ||
</main> | ||
<div className="wrapper"> | ||
<header> | ||
<h1>RESAS Chart App</h1> | ||
<p>都道府県別の人口推移チャート表示アプリ</p> | ||
</header> | ||
|
||
<main> | ||
{/* 都道府県を選択 */} | ||
<ButtonList setSelected={setSelected} /> | ||
|
||
{/* 総人口推移チャート */} | ||
<Chart selectedPref={selected} /> | ||
</main> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Dispatch, SetStateAction, useState } from 'react' | ||
import { Prefecture } from '@/types/prefecture' | ||
|
||
export const Button = ({ | ||
item, | ||
setSelected | ||
}: { | ||
item: Prefecture | ||
setSelected: Dispatch<SetStateAction<number[]>> | ||
}) => { | ||
const [isChecked, setIsChecked] = useState(false) | ||
|
||
const checkHandler = () => { | ||
if (isChecked) { | ||
setSelected((prev) => prev.filter((prefCode) => prefCode !== item.prefCode)) | ||
setIsChecked(false) | ||
} else { | ||
setSelected((prev) => [...prev, item.prefCode]) | ||
setIsChecked(true) | ||
} | ||
} | ||
|
||
return ( | ||
<button key={item.prefCode} onClick={checkHandler}> | ||
{item.prefName} | ||
</button> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Dispatch, SetStateAction } from 'react' | ||
|
||
import { Button } from './Button' | ||
import { usePref } from '@/hooks/usePref' | ||
|
||
export const ButtonList = ({ setSelected }: { setSelected: Dispatch<SetStateAction<number[]>> }) => { | ||
const { pref } = usePref() | ||
|
||
return ( | ||
<section> | ||
<h2>都道府県を選択</h2> | ||
|
||
{/* prefデータが存在する場合、pref を map で回して Buttonコンポーネント を表示する */} | ||
{pref && ( | ||
<ul className="prefContent"> | ||
{pref.map((item) => ( | ||
<li key={item.prefCode}> | ||
<Button setSelected={setSelected} item={item} /> | ||
</li> | ||
))} | ||
</ul> | ||
)} | ||
</section> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.