-
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
Showing
6 changed files
with
79 additions
and
49 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,38 @@ | ||
import classNames from "classnames"; | ||
import { useEffect, useState } from "react"; | ||
import { FaGamepad, FaMoon } from "react-icons/fa"; | ||
|
||
import StorageTool from "../../class/StorageTool"; | ||
import { FrontConfigs } from "../../components/config"; | ||
import CopyTootrip from "../../components/CopyBtn"; | ||
import Heading from "../../components/Heading"; | ||
import { Switches } from "../../components/Switches"; | ||
import { SwitchItem } from "../../components/SwitchItem"; | ||
import IsTrue from "../../utils/isTrue"; | ||
|
||
export default function Top() { | ||
return ( | ||
<> | ||
<ConfigSection name="Rainbow Websites" desc="虹色にするウェブサイトを設定します"> | ||
<ConfigSection name="Websites" desc="それぞれのウェブサイトで有効化する機能を設定できます"> | ||
<div className="flex flex-wrap"> | ||
<Switches className="flex-row-reverse items-center child:m-2" category="rainbow" /> | ||
</div> | ||
</ConfigSection> | ||
|
||
<ConfigSection name="Dark Websites" desc="ダークモードを有効化するウェブサイトを設定します"> | ||
<div className="flex flex-wrap"> | ||
<Switches className="flex-row-reverse items-center child:m-2" category="dark" /> | ||
{FrontConfigs.map((config) => { | ||
return ( | ||
<div className="chiid:p-1 mx-4 my-2 flex w-60 justify-center child:grow" key={config.id}> | ||
<p className="my-0 flex min-w-1/2 items-center justify-center rounded-l-lg bg-base-300 text-center"> | ||
{config.name} | ||
</p> | ||
<div className="items-center rounded-r-lg bg-neutral-focus child:m-2"> | ||
<div className="flex items-center justify-center child:px-1"> | ||
<FaMoon className="grow" /> | ||
<SwitchItem config={config} category="dark" /> | ||
</div> | ||
<div className="flex items-center justify-center child:px-1"> | ||
<FaGamepad className="grow" /> | ||
<SwitchItem config={config} category="rainbow" /> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
</ConfigSection> | ||
|
||
|
@@ -35,7 +49,7 @@ export default function Top() { | |
<ConfigSection name="群馬大学学務課・メディアセンターの方へ"> | ||
<p>このソフトウェアについて問題がある場合は以下のメールアドレスまでご連絡ください。</p> | ||
<CopyTootrip copyText="[email protected]" className="my-5"> | ||
<button className="btn btn-neutral">[email protected]</button> | ||
<button className="btn bg-base-300">[email protected]</button> | ||
</CopyTootrip> | ||
</ConfigSection> | ||
</> | ||
|
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
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,29 +1,64 @@ | ||
import { DetailedHTMLProps, useEffect, useState } from "react"; | ||
import { FaGamepad, FaMoon } from "react-icons/fa"; | ||
|
||
import { Switches } from "../../components/Switches"; | ||
import { FrontConfig, FrontConfigs } from "../../components/config"; | ||
import { SwitchItem } from "../../components/SwitchItem"; | ||
|
||
type MainProps = DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>; | ||
|
||
export default function Main(props: MainProps) { | ||
const [showSwitchClass, setShowSwitchClass] = useState(true); | ||
|
||
useEffect( | ||
() => | ||
useEffect(() => { | ||
try { | ||
chrome.tabs.query({ active: true, currentWindow: true }, (e) => { | ||
const url = e[0].url; | ||
if (url?.startsWith(`chrome-extension://${chrome.runtime.id}/options.html`)) { | ||
setShowSwitchClass(false); | ||
} | ||
}), | ||
[], | ||
}); | ||
} catch (e) { | ||
console.error(e); | ||
} | ||
}, []); | ||
|
||
const switches = ( | ||
<div className="flex flex-col items-center"> | ||
{FrontConfigs.map((config) => { | ||
return ( | ||
<div className="my-2 flex w-full grow rounded-lg bg-base-300 p-2" key={config.id}> | ||
<p className="flex w-2/3 items-center justify-center">{config.name}</p> | ||
<Switches config={config} /> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
); | ||
|
||
const switches = <Switches category="rainbow" className="w-full justify-center child:w-1/2 child:text-center" />; | ||
const hiddenMsg = <p className="text-center text-lg">設定画面を表示中はポップアップを利用できません</p>; | ||
|
||
return <main {...props}>{showSwitchClass ? switches : hiddenMsg}</main>; | ||
} | ||
|
||
function Switches({ config }: { config: FrontConfig }) { | ||
return ( | ||
<> | ||
<main {...props}>{showSwitchClass ? switches : hiddenMsg}</main> | ||
</> | ||
<div className="grow"> | ||
{( | ||
[ | ||
{ category: "dark", icon: <FaMoon size="1.5rem" className="grow px-2" /> }, | ||
{ category: "rainbow", icon: <FaGamepad size="1.5rem" className="grow px-2" /> }, | ||
] as { | ||
category: "dark" | "rainbow"; | ||
icon: JSX.Element; | ||
}[] | ||
).map((item) => { | ||
return ( | ||
<div className="flex items-center justify-around" key={item.category}> | ||
{item.icon} | ||
<SwitchItem category={item.category} config={config} /> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
); | ||
} |