Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
BrunoQuaresma merged 7 commits intomainfrombq/add-page-header-and-tooltips
Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletionssite/src/components/HelpTooltip/HelpTooltip.stories.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff 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
Copy link
Member

Choose a reason for hiding this comment

The 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

Copy link
CollaboratorAuthor

Choose a reason for hiding this comment

The 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:

 <HelpTooltipLink href="https://github.com/coder/coder/blob/main/docs/templates.md#manage-templates">  Manage templates</HelpTooltipLink>

</HelpTooltipLinksGroup>
</HelpTooltip>
)

exportconstClose=Template.bind({})

exportconstOpen=Template.bind({})
Open.args={
open:true,
}
159 changes: 159 additions & 0 deletionssite/src/components/HelpTooltip/HelpTooltip.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff 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),
},
}))
15 changes: 15 additions & 0 deletionssite/src/components/PageHeader/PageHeader.stories.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff 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({})
62 changes: 62 additions & 0 deletionssite/src/components/PageHeader/PageHeader.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff 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",
},
}))
50 changes: 48 additions & 2 deletionssite/src/components/Resources/Resources.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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"
Expand All@@ -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>
)
}

constAgentHelpTooltip:React.FC=()=>{
return(
<HelpTooltipsize="small">
<HelpTooltipTitle>{Language.agentTooltipTitle}</HelpTooltipTitle>
<HelpTooltipText>{Language.agentTooltipTitle}</HelpTooltipText>
</HelpTooltip>
)
}

interfaceResourcesProps{
Expand All@@ -41,8 +77,18 @@ export const Resources: FC<ResourcesProps> = ({ resources, getResourcesError, wo
<TableclassName={styles.table}>
<TableHead>
<TableHeaderRow>
<TableCell>{Language.resourceLabel}</TableCell>
<TableCellclassName={styles.agentColumn}>{Language.agentLabel}</TableCell>
<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>
Expand Down
8 changes: 6 additions & 2 deletionssite/src/components/Stack/Stack.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
import{makeStyles}from"@material-ui/core/styles"
import{CSSProperties}from"@material-ui/core/styles/withStyles"
import{FC}from"react"
import{combineClasses}from"../../util/combineClasses"

Expand All@@ -7,24 +8,27 @@ type Direction = "column" | "row"
interfaceStyleProps{
direction:Direction
spacing:number
alignItems?:CSSProperties["alignItems"]
}

constuseStyles=makeStyles((theme)=>({
stack:{
display:"flex",
flexDirection:({ direction}:StyleProps)=>direction,
gap:({ spacing}:StyleProps)=>theme.spacing(spacing),
alignItems:({ alignItems}:StyleProps)=>alignItems,
},
}))

exportinterfaceStackProps{
className?:string
direction?:Direction
spacing?:number
alignItems?:CSSProperties["alignItems"]
}

exportconstStack:FC<StackProps>=({ children, className, direction="column", spacing=2})=>{
conststyles=useStyles({ spacing, direction})
exportconstStack:FC<StackProps>=({ children, className, direction="column", spacing=2, alignItems})=>{
conststyles=useStyles({ spacing, direction, alignItems})

return<divclassName={combineClasses([styles.stack,className])}>{children}</div>
}
Loading

[8]ページ先頭

©2009-2025 Movatter.jp