-
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Welcome page #52
base: master
Are you sure you want to change the base?
Welcome page #52
Changes from all commits
ac62675
d2b3c9a
baf58cf
102be79
6aacf0a
5ffbfe0
f10f133
a052746
ad653c7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import React from "react"; | ||
import styled from "styled-components"; | ||
|
||
import { HTMLComponent } from "../../../types/html-component"; | ||
|
||
type Props = { | ||
href?: string; | ||
loading?: boolean; | ||
disabled?: boolean; | ||
prefixIcon?: React.ReactNode; | ||
color?: "primary" | "secondary"; | ||
variant?: "default" | "ghost"; | ||
size?: "default" | "small" | "large"; | ||
onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void; | ||
}; | ||
|
||
type ButtonProps = HTMLComponent< | ||
Props, | ||
React.ButtonHTMLAttributes<HTMLButtonElement> | ||
>; | ||
|
||
const Button: React.FC<ButtonProps> = styled( | ||
({ | ||
as: Component = "button", | ||
href, | ||
loading, | ||
disabled = loading, | ||
prefixIcon, | ||
color = "primary", | ||
variant = "default", | ||
size = "default", | ||
onClick, | ||
className = "", | ||
children, | ||
...rest | ||
}: ButtonProps) => { | ||
href; | ||
color; | ||
variant; | ||
size; | ||
/* if (href && !disabled) { | ||
jerembdn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return ( | ||
<_LinkAsButton className={className} href={href}> | ||
{children} | ||
</_LinkAsButton> | ||
); | ||
} */ | ||
|
||
const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => { | ||
e.preventDefault(); | ||
onClick && onClick(e); | ||
}; | ||
|
||
return ( | ||
<Component | ||
onClick={handleClick} | ||
className={className} | ||
disabled={disabled} | ||
whileTap={{ opacity: 0.8 }} | ||
transition={{ duration: 0.2 }} | ||
{...rest} | ||
> | ||
<ButtonContent> | ||
<div className={"flex flex-row gap-x-[15px] items-center"}> | ||
{prefixIcon && prefixIcon} | ||
{children} | ||
</div> | ||
</ButtonContent> | ||
</Component> | ||
); | ||
}, | ||
)<ButtonProps>` | ||
cursor: pointer; | ||
|
||
font-family: "neulis-cursive"; | ||
font-weight: 600; | ||
color: #ffffff; | ||
background-color: var(--green); | ||
|
||
padding: 15px 20px; | ||
border: none; | ||
border-radius: 5px; | ||
`; | ||
|
||
const ButtonContent = styled.div` | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
justify-content: center; | ||
|
||
line-height: 20px; | ||
`; | ||
|
||
export default Button; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const installNotice = () => { | ||
console.log("kartrak - extension installed"); | ||
|
||
chrome.tabs.create({ | ||
url: chrome.runtime.getURL("welcome.html"), | ||
}); | ||
}; | ||
|
||
export default installNotice; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
html { | ||
jerembdn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
width: 380px; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,9 @@ | |
import { createRoot } from "react-dom/client"; | ||
|
||
import Popup from "./Popup"; | ||
import "./index.css"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove it |
||
import "./../../styles/fonts.css"; | ||
|
||
const container = document.getElementById("app-container"); | ||
const root = createRoot(container!); // createRoot(container!) if you use TypeScript | ||
root.render(<Popup />); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
import React from "react"; | ||
import styled from "styled-components"; | ||
|
||
import Button from "../../components/ui/Button"; | ||
import GlobalStyle from "../../components/ui/GlobalStyle"; | ||
|
||
const WelcomePage: React.FC = () => { | ||
const [isPinned, setIsPinned] = React.useState<boolean>(false); | ||
const [error, setError] = React.useState<string | null>(null); | ||
|
||
const handleCheckIfPinned = React.useCallback((shouldError = true) => { | ||
console.log("kartrak - check if pinned"); | ||
|
||
const checkIfPinned = async (): Promise<boolean> => { | ||
const userSettings = await chrome.action.getUserSettings(); | ||
|
||
console.log("kartrak - userSettings", userSettings); | ||
|
||
return userSettings.isOnToolbar; | ||
}; | ||
|
||
checkIfPinned().then((isPinned) => { | ||
if (isPinned) { | ||
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => { | ||
const activeTab = tabs[0]; | ||
|
||
if (activeTab) { | ||
setIsPinned(true); | ||
} | ||
}); | ||
} else if (shouldError) { | ||
setError("L'extension n'est pas épinglée à la barre d'outils."); | ||
} | ||
}); | ||
}, []); | ||
|
||
const handleCloseTab = React.useCallback(() => { | ||
console.log("kartrak - close tab"); | ||
|
||
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => { | ||
const activeTab = tabs[0]; | ||
|
||
if (activeTab) { | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
chrome.tabs.remove(activeTab.id!); | ||
} | ||
}); | ||
}, []); | ||
|
||
React.useEffect(() => { | ||
handleCheckIfPinned(false); | ||
}, []); | ||
|
||
console.log("kartrak - isPinned", isPinned); | ||
|
||
return ( | ||
<Container> | ||
<Row> | ||
<GlobalStyle /> | ||
|
||
{isPinned ? ( | ||
<> | ||
<Title>{"Vous êtes prêt à y aller !"}</Title> | ||
|
||
<TextContent> | ||
{ | ||
"Vous pouvez désormais cliquer sur l’extension quand vous le souhaitez pour analyser des sites internets ou voir vos statistiques d’activités." | ||
} | ||
</TextContent> | ||
|
||
<Image | ||
src={require("../../assets/img/welcome/opened-extension.png")} | ||
alt={"Extension ouverte"} | ||
/> | ||
|
||
<StyledButton onClick={handleCloseTab}> | ||
{"J’ai compris, merci"} | ||
</StyledButton> | ||
</> | ||
) : ( | ||
<> | ||
<Title> | ||
{"Kartrak est désormais installé sur votre navigateur"} | ||
</Title> | ||
|
||
<TextContent> | ||
{ | ||
"Épinglez dès maintenant l’extension à la barre d’outils de votre navigateur. Vous serez amenés à ouvrir souvent l’extension, alors ça sera plus pratique !" | ||
} | ||
</TextContent> | ||
|
||
<Image | ||
jerembdn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
src={require("../../assets/img/welcome/extension-pinned.png")} | ||
alt={"Extension épinglée"} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add width and height attributes to avoid blinking during first paint There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i don't understand There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. an image should have a width and height attribute, what you. don't understand ? |
||
/> | ||
|
||
<StyledButton onClick={() => handleCheckIfPinned()}> | ||
{"J'ai épinglé l'extension"} | ||
</StyledButton> | ||
|
||
{error && <Error>{error}</Error>} | ||
</> | ||
)} | ||
</Row> | ||
</Container> | ||
); | ||
}; | ||
|
||
const Container = styled.main` | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
height: 100vh; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't use 100vh because we cant scroll if the window height is low There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok so i don't know how to do it |
||
`; | ||
|
||
const Row = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
max-width: 750px; | ||
`; | ||
|
||
const Title = styled.h1` | ||
font-family: "neulis-cursive"; | ||
font-size: 48px; | ||
font-weight: 600; | ||
text-align: center; | ||
color: var(--primary); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's true that I didn't do it everywhere, but get into the habit of using fallback colors when you use css variables There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. idk how to do it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
`; | ||
|
||
const TextContent = styled.p` | ||
margin-top: 15px; | ||
jerembdn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
text-align: center; | ||
|
||
color: var(--grey); | ||
font-size: 18px; | ||
`; | ||
|
||
const Image = styled.img` | ||
margin-top: 40px; | ||
jerembdn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
max-width: 560px; | ||
jerembdn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
width: 100%; | ||
`; | ||
|
||
const StyledButton = styled(Button)` | ||
margin-top: 40px; | ||
jerembdn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
`; | ||
|
||
const Error = styled.p` | ||
margin-top: 10px; | ||
color: var(--red); | ||
`; | ||
|
||
export default WelcomePage; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="fr"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<title>Merci d'avoir installé Kartrak</title> | ||
</head> | ||
|
||
<body> | ||
<div id="app-container"></div> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import "./../../styles/fonts.css"; | ||
|
||
import React from "react"; | ||
import { createRoot } from "react-dom/client"; | ||
|
||
import WelcomePage from "./Welcome"; | ||
|
||
const container = document.getElementById("app-container"); | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
const root = createRoot(container!); | ||
root.render(<WelcomePage />); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export type HTMLComponent<P, N = React.HTMLAttributes<any>> = { | ||
/** | ||
* The root element. | ||
*/ | ||
as?: React.ElementType; | ||
/** | ||
* The content, duh. | ||
*/ | ||
children?: React.ReactNode; | ||
} & P & | ||
Partial<Omit<N, keyof P>>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in this file you just dont respect the sizes indicated on the figma
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahbon