Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(created a global state to handle entire pop ui): state
- Loading branch information
1 parent
6c11efd
commit 49bf0ba
Showing
19 changed files
with
355 additions
and
58 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { useEffect, useState } from "react"; | ||
import { GlobalStateI, ReturnUseGlobal } from "./types"; | ||
|
||
const INITIAL_STATE: GlobalStateI = { | ||
showThumbnails: false, | ||
zipBulkDownloads: false, | ||
displayDownloadOnChat: true, | ||
}; | ||
|
||
export default function useGlobal():ReturnUseGlobal { | ||
const [state, setState] = useState<GlobalStateI>(INITIAL_STATE); | ||
|
||
useEffect(() => { | ||
const data = window.localStorage.getItem("configuration"); | ||
|
||
const parsedData: GlobalStateI = | ||
data === null ? INITIAL_STATE : JSON.parse(data); | ||
|
||
setState(parsedData); | ||
|
||
console.log(parsedData); | ||
}, []); | ||
|
||
return { | ||
...state, | ||
}; | ||
} |
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,9 @@ | ||
export interface GlobalStateI{ | ||
showThumbnails:boolean; | ||
zipBulkDownloads:boolean; | ||
displayDownloadOnChat:boolean; | ||
} | ||
|
||
export interface ReturnUseGlobal extends GlobalStateI{ | ||
|
||
} |
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,16 @@ | ||
import ui from "./styles.module.scss"; | ||
|
||
export default function ErrorPage() { | ||
return ( | ||
<div className={ui.errorContainer}> | ||
<h1>Hello stranger</h1> | ||
<p> | ||
You shouldn't be seeing this, i don't know how you did this but. Get in | ||
touch with me cause this is a bug 😸 | ||
</p> | ||
<a href="https://t.me/pptronix" target="_blank"> | ||
@pptronix | ||
</a> | ||
</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
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,11 +1,27 @@ | ||
import React from 'react' | ||
import ReactDOM from 'react-dom/client' | ||
import App from './App.tsx' | ||
import './index.css' | ||
import 'bootswatch/dist/minty/bootstrap.min.css' | ||
import React from "react"; | ||
import ReactDOM from "react-dom/client"; | ||
import App from "./App.tsx"; | ||
import "./index.css"; | ||
import "bootswatch/dist/minty/bootstrap.min.css"; | ||
import { RouterProvider, createMemoryRouter } from "react-router-dom"; | ||
import ErrorPage from "./error-page.tsx"; | ||
import ConfigurationAddOn from "./structure/configuration/index.tsx"; | ||
|
||
ReactDOM.createRoot(document.getElementById('root')!).render( | ||
const router = createMemoryRouter([ | ||
{ | ||
path: "/", | ||
element: <App />, | ||
errorElement: <ErrorPage />, | ||
}, | ||
{ | ||
path: "/configuration", | ||
element: <ConfigurationAddOn />, | ||
errorElement: <ErrorPage />, | ||
}, | ||
]); | ||
|
||
ReactDOM.createRoot(document.getElementById("root")!).render( | ||
<React.StrictMode> | ||
<App /> | ||
</React.StrictMode>, | ||
) | ||
<RouterProvider router={router} /> | ||
</React.StrictMode> | ||
); |
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,11 @@ | ||
import SettingsNav from "../SettingsNav"; | ||
import ui from "./styles.module.scss"; | ||
|
||
export default function Header() { | ||
return ( | ||
<div className={ui.header}> | ||
<SettingsNav /> | ||
<h1>Telegram Downloader 1.0.0</h1> | ||
</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,11 @@ | ||
.header { | ||
display: grid; | ||
grid-template-columns: 10% 85%; | ||
justify-content: space-around; | ||
align-items: center; | ||
> * { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Link } from "react-router-dom"; | ||
|
||
export default function SettingsNav() { | ||
return ( | ||
<Link className="btn btn-primary btn-sm" to={`configuration`}> | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
viewBox="0 0 24 24" | ||
fill="currentColor" | ||
className="w-6 h-6" | ||
> | ||
<path | ||
fillRule="evenodd" | ||
d="M11.078 2.25c-.917 0-1.699.663-1.85 1.567L9.05 4.889c-.02.12-.115.26-.297.348a7.493 7.493 0 0 0-.986.57c-.166.115-.334.126-.45.083L6.3 5.508a1.875 1.875 0 0 0-2.282.819l-.922 1.597a1.875 1.875 0 0 0 .432 2.385l.84.692c.095.078.17.229.154.43a7.598 7.598 0 0 0 0 1.139c.015.2-.059.352-.153.43l-.841.692a1.875 1.875 0 0 0-.432 2.385l.922 1.597a1.875 1.875 0 0 0 2.282.818l1.019-.382c.115-.043.283-.031.45.082.312.214.641.405.985.57.182.088.277.228.297.35l.178 1.071c.151.904.933 1.567 1.85 1.567h1.844c.916 0 1.699-.663 1.85-1.567l.178-1.072c.02-.12.114-.26.297-.349.344-.165.673-.356.985-.57.167-.114.335-.125.45-.082l1.02.382a1.875 1.875 0 0 0 2.28-.819l.923-1.597a1.875 1.875 0 0 0-.432-2.385l-.84-.692c-.095-.078-.17-.229-.154-.43a7.614 7.614 0 0 0 0-1.139c-.016-.2.059-.352.153-.43l.84-.692c.708-.582.891-1.59.433-2.385l-.922-1.597a1.875 1.875 0 0 0-2.282-.818l-1.02.382c-.114.043-.282.031-.449-.083a7.49 7.49 0 0 0-.985-.57c-.183-.087-.277-.227-.297-.348l-.179-1.072a1.875 1.875 0 0 0-1.85-1.567h-1.843ZM12 15.75a3.75 3.75 0 1 0 0-7.5 3.75 3.75 0 0 0 0 7.5Z" | ||
clipRule="evenodd" | ||
/> | ||
</svg> | ||
</Link> | ||
); | ||
} |
Oops, something went wrong.