- Notifications
You must be signed in to change notification settings - Fork928
feat: Add helpful tooltips for the key features#2097
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
d453963
c4e15cd
c725b33
9e2b90c
915c3c5
05af10a
81f2e16
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import{ComponentMeta,Story}from"@storybook/react" | ||
import{ | ||
HelpTooltip, | ||
HelpTooltipLink, | ||
HelpTooltipLinksGroup, | ||
HelpTooltipProps, | ||
HelpTooltipText, | ||
HelpTooltipTitle, | ||
}from"./HelpTooltip" | ||
exportdefault{ | ||
title:"components/HelpTooltip", | ||
component:HelpTooltip, | ||
}asComponentMeta<typeofHelpTooltip> | ||
constTemplate:Story<HelpTooltipProps>=(args)=>( | ||
<HelpTooltip{...args}> | ||
<HelpTooltipTitle>What is template?</HelpTooltipTitle> | ||
<HelpTooltipText> | ||
With templates you can create a common configuration for your workspaces using Terraform. So, you and your team | ||
can use the same environment to deliver great software. | ||
</HelpTooltipText> | ||
<HelpTooltipLinksGroup> | ||
<HelpTooltipLinkhref="https://github.com/coder/coder/">Creating a template</HelpTooltipLink> | ||
<HelpTooltipLinkhref="https://github.com/coder/coder/">Updating a template</HelpTooltipLink> | ||
Comment on lines +24 to +25 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. Maybe just one link to the templates doc for now labeled "managing templates"? https://github.com/coder/coder/blob/main/docs/templates.md#templates 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. Ahh, this one is just a sample. I'm already using this link for the templates:
| ||
</HelpTooltipLinksGroup> | ||
</HelpTooltip> | ||
BrunoQuaresma marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
) | ||
exportconstClose=Template.bind({}) | ||
exportconstOpen=Template.bind({}) | ||
Open.args={ | ||
open:true, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
importLinkfrom"@material-ui/core/Link" | ||
importPopoverfrom"@material-ui/core/Popover" | ||
import{makeStyles}from"@material-ui/core/styles" | ||
importHelpIconfrom"@material-ui/icons/HelpOutline" | ||
importOpenInNewIconfrom"@material-ui/icons/OpenInNew" | ||
import{useState}from"react" | ||
import{Stack}from"../Stack/Stack" | ||
typeSize="small"|"medium" | ||
exportinterfaceHelpTooltipProps{ | ||
// Useful to test on storybook | ||
open?:boolean | ||
size?:Size | ||
} | ||
exportconstHelpTooltip:React.FC<HelpTooltipProps>=({ children, open, size="medium"})=>{ | ||
conststyles=useStyles({ size}) | ||
const[anchorEl,setAnchorEl]=useState<HTMLButtonElement|null>(null) | ||
open=open??Boolean(anchorEl) | ||
constid=open ?"help-popover" :undefined | ||
return( | ||
<> | ||
<buttonaria-describedby={id}className={styles.button}onClick={(event)=>setAnchorEl(event.currentTarget)}> | ||
<HelpIconclassName={styles.icon}/> | ||
</button> | ||
<Popover | ||
classes={{paper:styles.popoverPaper}} | ||
id={id} | ||
open={open} | ||
anchorEl={anchorEl} | ||
onClose={()=>{ | ||
setAnchorEl(null) | ||
}} | ||
anchorOrigin={{ | ||
vertical:"bottom", | ||
horizontal:"left", | ||
}} | ||
transformOrigin={{ | ||
vertical:"top", | ||
horizontal:"left", | ||
}} | ||
> | ||
{children} | ||
</Popover> | ||
</> | ||
) | ||
} | ||
exportconstHelpTooltipTitle:React.FC=({ children})=>{ | ||
conststyles=useStyles() | ||
return<h4className={styles.title}>{children}</h4> | ||
} | ||
exportconstHelpTooltipText:React.FC=({ children})=>{ | ||
conststyles=useStyles() | ||
return<pclassName={styles.text}>{children}</p> | ||
} | ||
exportconstHelpTooltipLink:React.FC<{href:string}>=({ children, href})=>{ | ||
conststyles=useStyles() | ||
return( | ||
<Linkhref={href}target="_blank"rel="noreferrer"className={styles.link}> | ||
<OpenInNewIconclassName={styles.linkIcon}/> | ||
{children} | ||
</Link> | ||
) | ||
} | ||
exportconstHelpTooltipLinksGroup:React.FC=({ children})=>{ | ||
conststyles=useStyles() | ||
return( | ||
<Stackspacing={1}className={styles.linksGroup}> | ||
{children} | ||
</Stack> | ||
) | ||
} | ||
constgetButtonSpacingFromSize=(size?:Size):number=>{ | ||
switch(size){ | ||
case"small": | ||
return2.75 | ||
case"medium": | ||
default: | ||
return3 | ||
} | ||
} | ||
constgetIconSpacingFromSize=(size?:Size):number=>{ | ||
switch(size){ | ||
case"small": | ||
return1.75 | ||
case"medium": | ||
default: | ||
return2 | ||
} | ||
} | ||
constuseStyles=makeStyles((theme)=>({ | ||
button:{ | ||
display:"flex", | ||
alignItems:"center", | ||
justifyContent:"center", | ||
width:({ size}:{size?:Size})=>theme.spacing(getButtonSpacingFromSize(size)), | ||
height:({ size}:{size?:Size})=>theme.spacing(getButtonSpacingFromSize(size)), | ||
padding:0, | ||
border:0, | ||
background:"transparent", | ||
color:theme.palette.text.secondary, | ||
cursor:"pointer", | ||
"&:hover":{ | ||
color:theme.palette.text.primary, | ||
}, | ||
}, | ||
icon:{ | ||
width:({ size}:{size?:Size})=>theme.spacing(getIconSpacingFromSize(size)), | ||
height:({ size}:{size?:Size})=>theme.spacing(getIconSpacingFromSize(size)), | ||
}, | ||
popoverPaper:{ | ||
marginTop:theme.spacing(0.5), | ||
width:theme.spacing(38), | ||
padding:theme.spacing(2.5), | ||
color:theme.palette.text.secondary, | ||
}, | ||
title:{ | ||
marginTop:0, | ||
marginBottom:theme.spacing(1), | ||
color:theme.palette.text.primary, | ||
}, | ||
text:{ | ||
marginTop:theme.spacing(0.5), | ||
marginBottom:theme.spacing(0.5), | ||
}, | ||
link:{ | ||
display:"flex", | ||
alignItems:"center", | ||
}, | ||
linkIcon:{ | ||
color:"inherit", | ||
width:14, | ||
height:14, | ||
marginRight:theme.spacing(1), | ||
}, | ||
linksGroup:{ | ||
marginTop:theme.spacing(2), | ||
}, | ||
})) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import{ComponentMeta,Story}from"@storybook/react" | ||
import{PageHeader,PageHeaderTitle}from"./PageHeader" | ||
exportdefault{ | ||
title:"components/PageHeader", | ||
component:PageHeader, | ||
}asComponentMeta<typeofPageHeader> | ||
constTemplate:Story=()=>( | ||
<PageHeader> | ||
<PageHeaderTitle>Templates</PageHeaderTitle> | ||
</PageHeader> | ||
) | ||
exportconstExample=Template.bind({}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import{makeStyles}from"@material-ui/core/styles" | ||
import{Stack}from"../Stack/Stack" | ||
exportinterfacePageHeaderProps{ | ||
actions?:JSX.Element | ||
} | ||
exportconstPageHeader:React.FC<PageHeaderProps>=({ children, actions})=>{ | ||
conststyles=useStyles() | ||
return( | ||
<divclassName={styles.root}> | ||
<hgroup>{children}</hgroup> | ||
<Stackdirection="row"className={styles.actions}> | ||
{actions} | ||
</Stack> | ||
</div> | ||
) | ||
} | ||
exportconstPageHeaderTitle:React.FC=({ children})=>{ | ||
conststyles=useStyles() | ||
return<h1className={styles.title}>{children}</h1> | ||
} | ||
exportconstPageHeaderSubtitle:React.FC=({ children})=>{ | ||
conststyles=useStyles() | ||
return<h2className={styles.subtitle}>{children}</h2> | ||
} | ||
constuseStyles=makeStyles((theme)=>({ | ||
root:{ | ||
display:"flex", | ||
alignItems:"center", | ||
paddingTop:theme.spacing(6), | ||
paddingBottom:theme.spacing(5), | ||
}, | ||
title:{ | ||
fontSize:theme.spacing(4), | ||
fontWeight:400, | ||
margin:0, | ||
display:"flex", | ||
alignItems:"center", | ||
lineHeight:"140%", | ||
}, | ||
subtitle:{ | ||
fontSize:theme.spacing(2.5), | ||
color:theme.palette.text.secondary, | ||
fontWeight:400, | ||
display:"block", | ||
margin:0, | ||
marginTop:theme.spacing(1), | ||
}, | ||
actions:{ | ||
marginLeft:"auto", | ||
}, | ||
})) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -9,6 +9,13 @@ import { FC } from "react" | ||
import{Workspace,WorkspaceResource}from"../../api/typesGenerated" | ||
import{getDisplayAgentStatus}from"../../util/workspace" | ||
import{AppLink}from"../AppLink/AppLink" | ||
import{ | ||
HelpTooltip, | ||
HelpTooltipLink, | ||
HelpTooltipLinksGroup, | ||
HelpTooltipText, | ||
HelpTooltipTitle, | ||
}from"../HelpTooltip/HelpTooltip" | ||
import{Stack}from"../Stack/Stack" | ||
import{TableHeaderRow}from"../TableHeaders/TableHeaders" | ||
import{TerminalLink}from"../TerminalLink/TerminalLink" | ||
@@ -21,6 +28,35 @@ const Language = { | ||
agentLabel:"Agent", | ||
statusLabel:"Status", | ||
accessLabel:"Access", | ||
resourceTooltipTitle:"What is a resource?", | ||
resourceTooltipText:"A resource is an infrastructure object that is create when the workspace is provisioned.", | ||
resourceTooltipLink:"Persistent and ephemeral resources", | ||
agentTooltipTitle:"What is an agent?", | ||
agentTooltipText: | ||
"The Coder agent runs inside your resource and gives you direct access to the shell via the UI or CLI.", | ||
} | ||
constResourcesHelpTooltip:React.FC=()=>{ | ||
return( | ||
<HelpTooltipsize="small"> | ||
<HelpTooltipTitle>{Language.resourceTooltipTitle}</HelpTooltipTitle> | ||
<HelpTooltipText>{Language.resourceTooltipText}</HelpTooltipText> | ||
<HelpTooltipLinksGroup> | ||
<HelpTooltipLinkhref="https://github.com/coder/coder/blob/main/docs/templates.md#persistent-and-ephemeral-resources"> | ||
{Language.resourceTooltipLink} | ||
</HelpTooltipLink> | ||
</HelpTooltipLinksGroup> | ||
</HelpTooltip> | ||
) | ||
BrunoQuaresma marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
} | ||
constAgentHelpTooltip:React.FC=()=>{ | ||
return( | ||
<HelpTooltipsize="small"> | ||
<HelpTooltipTitle>{Language.agentTooltipTitle}</HelpTooltipTitle> | ||
<HelpTooltipText>{Language.agentTooltipTitle}</HelpTooltipText> | ||
</HelpTooltip> | ||
) | ||
} | ||
BrunoQuaresma marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
interfaceResourcesProps{ | ||
@@ -41,8 +77,18 @@ export const Resources: FC<ResourcesProps> = ({ resources, getResourcesError, wo | ||
<TableclassName={styles.table}> | ||
<TableHead> | ||
<TableHeaderRow> | ||
<TableCell> | ||
<Stackdirection="row"spacing={0.5}alignItems="center"> | ||
{Language.resourceLabel} | ||
<ResourcesHelpTooltip/> | ||
</Stack> | ||
</TableCell> | ||
<TableCellclassName={styles.agentColumn}> | ||
<Stackdirection="row"spacing={0.5}alignItems="center"> | ||
{Language.agentLabel} | ||
<AgentHelpTooltip/> | ||
</Stack> | ||
</TableCell> | ||
<TableCell>{Language.accessLabel}</TableCell> | ||
<TableCell>{Language.statusLabel}</TableCell> | ||
</TableHeaderRow> | ||
Uh oh!
There was an error while loading.Please reload this page.