-
-
Notifications
You must be signed in to change notification settings - Fork 480
[UX] Help component #3135
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
Merged
Merged
[UX] Help component #3135
Changes from 13 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
8da8d58
[UX] Help component prototype
arielj 8e426bb
Update electron to version 26.2.1
arielj f082e3a
Merge branch 'main' of github.com:Heroic-Games-Launcher/HeroicGamesLa…
arielj ee0435a
Merge branch 'electron-26-2-1' of github.com:Heroic-Games-Launcher/He…
arielj ba87af8
Use Popover API to be able to use the help with modals
arielj b2a1c8f
Merge branch 'main' of github.com:Heroic-Games-Launcher/HeroicGamesLa…
arielj c9b6a85
Help: style and add some content
arielj 78c13f7
Help: ignore missing type
arielj 5e53298
Help: ignore popopver attributes
arielj 4aeed95
Help: make it experimental feature
arielj 96a89b1
Merge branch 'main' of github.com:Heroic-Games-Launcher/HeroicGamesLa…
arielj b8a4fe8
Fix prettier issues
arielj 5efe1d4
Fix prettier issues
arielj af7ba25
Merge branch 'main' of github.com:Heroic-Games-Launcher/HeroicGamesLa…
arielj 25ef8ff
Merge branch 'main' of github.com:Heroic-Games-Launcher/HeroicGamesLa…
arielj 9f8184d
Help opacity, prevent navigating to another page while open
arielj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,73 @@ | ||
.HelpButton, | ||
.HelpContent { | ||
transition: transform 300ms ease-out; | ||
z-index: 100; | ||
} | ||
|
||
.HelpButton { | ||
transform: translateX(0); | ||
color: white; | ||
border: 1px solid white; | ||
border-radius: 0px; | ||
background: black; | ||
padding: 0.5rem 1rem; | ||
font-size: 2rem; | ||
font-weight: bold; | ||
opacity: 0.5; | ||
transition: | ||
opacity 100ms linear, | ||
transform 300ms ease-out; | ||
cursor: pointer; | ||
|
||
&:hover, | ||
&:focus { | ||
opacity: 1; | ||
} | ||
|
||
&.open { | ||
transform: translateX(-30vw); | ||
} | ||
} | ||
|
||
.HelpContent { | ||
display: block; | ||
background: var(--background); | ||
color: var(--text-default); | ||
border: 1px solid var(--text-default); | ||
top: 0px; | ||
height: 100vh; | ||
width: 30vw; | ||
right: 0; | ||
left: 70vw; | ||
padding: 0 1rem; | ||
transform: translateX(100%); | ||
transition: transform 300ms ease-out; | ||
text-align: start; | ||
|
||
&:popover-open { | ||
transform: translateX(0); | ||
} | ||
|
||
& button { | ||
background: white; | ||
border: 0; | ||
border-radius: 0 0 0 50%; | ||
padding: 0.5rem 1rem; | ||
} | ||
|
||
& details:not(:last-child) { | ||
border-bottom: 1px solid var(--text-default); | ||
} | ||
|
||
& summary { | ||
font-size: 1.2rem; | ||
} | ||
|
||
& p { | ||
font-size: 1.1rem; | ||
} | ||
|
||
& summary + p { | ||
margin-top: 0; | ||
} | ||
} |
This file contains hidden or 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,51 @@ | ||
import React, { useState } from 'react' | ||
|
||
import './index.css' | ||
import { HelpItem } from 'frontend/types' | ||
import { useTranslation } from 'react-i18next' | ||
|
||
interface Props { | ||
items: { [key: string]: HelpItem } | ||
} | ||
|
||
export default function Help({ items }: Props) { | ||
const { t } = useTranslation() | ||
const [open, setOpen] = useState(false) | ||
|
||
const toggleOpen = () => { | ||
setOpen(!open) | ||
} | ||
|
||
return ( | ||
<> | ||
<button | ||
className={`HelpButton ${open ? 'open' : ''}`} | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore, this feature is new and not yet typed | ||
popovertarget="help_content" | ||
onClick={() => toggleOpen()} | ||
title={ | ||
open | ||
? t('help.button.close', 'Close Help') | ||
: t('help.button.open', 'Open Help') | ||
} | ||
> | ||
? | ||
</button> | ||
<div | ||
className={`HelpContent ${open ? 'open' : ''}`} | ||
id="help_content" | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore, this feature is new and not yet typed | ||
popover="manual" | ||
> | ||
{Object.keys(items).map((key) => ( | ||
<details key={key}> | ||
<summary>{items[key]['title']}</summary> | ||
{items[key]['content']} | ||
</details> | ||
))} | ||
</div> | ||
</> | ||
) | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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,21 @@ | ||
import ContextProvider from 'frontend/state/ContextProvider' | ||
import { useEffect, useContext } from 'react' | ||
|
||
export const hasHelp = ( | ||
helpItemId: string, | ||
title: string, | ||
content: JSX.Element | ||
) => { | ||
const { help } = useContext(ContextProvider) | ||
|
||
useEffect(() => { | ||
help.addHelpItem(helpItemId, { | ||
title, | ||
content | ||
}) | ||
|
||
return () => { | ||
help.removeHelpItem(helpItemId) | ||
} | ||
}, []) | ||
} |
This file contains hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
typescript doesn't understand these properties, they are too new