-
Notifications
You must be signed in to change notification settings - Fork 394
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
WIP: add glossary with some basic DVC terms #431
Merged
Merged
Changes from 8 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
edf9bc5
Add glossary with some basic DVC terminologies
algomaster99 61754a6
Add tooltip component to show meanings of DVC terminologies
algomaster99 7825e8f
Change direction of tooltip opening according to the right offset
algomaster99 87cf864
Use js file for glossary for better formatting of code
algomaster99 93a8726
Underline keywords instead of showing a symbol
algomaster99 6343214
Rewrite workspace directory description
algomaster99 0372694
Add data artifact term in glossary
algomaster99 99d9e73
Toogle position of tooltip vertically
algomaster99 586fea6
Prevent rendering of tooltip if match is false
algomaster99 9733399
Soft code height of header
algomaster99 8360f06
Mention default location for cache directory
algomaster99 5ab1e96
Disable tooltip in mobile view
algomaster99 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 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,34 @@ | ||
export default { | ||
name: 'Glossary', | ||
desc: | ||
'This guide is aimed to familiarize the users with definitions to ' + | ||
'relevant DVC concepts and terminologies which are frequently used.', | ||
contents: [ | ||
{ | ||
name: 'Workspace directory', | ||
match: ['workspace'], | ||
desc: | ||
'The **workspace** contains all of your DVC **project** files and ' + | ||
"directories. It's typically also a Git **repository**. See also " + | ||
'[`dvc init`](/doc/commands-reference/init).' | ||
}, | ||
{ | ||
name: 'DVC cache', | ||
match: ['cache'], | ||
desc: | ||
'DVC cache is a hidden storage which is found at `.dvc/cache`. This ' + | ||
'storage is used to manage different versions of files which are ' + | ||
'under DVC control. For more information on cache, please refer to ' + | ||
'the this [guide](/doc/commands-reference/config#cache).' | ||
}, | ||
{ | ||
name: 'Data artifact', | ||
match: ['data artifact', 'data artifacts'], | ||
desc: | ||
'Any **data** file or directory, as well as intermediate or final ' + | ||
'result (such as extracted features or a ML model file) that is ' + | ||
'under DVC control. Refer to [Data and Model Files Versioning]' + | ||
'(/doc/use-cases/data-and-model-files-versioning) for more details.' | ||
} | ||
] | ||
} |
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,228 @@ | ||
import React, { Component } from 'react' | ||
import ReactMarkdown from 'react-markdown' | ||
import styled from 'styled-components' | ||
|
||
import glossary from '../Documentation/glossary' | ||
|
||
class Tooltip extends Component { | ||
state = { | ||
description: '', | ||
header: '', | ||
hover: false, | ||
id: null, | ||
margin: -70, | ||
pointBorderAfter: 'white transparent transparent transparent', | ||
pointBorderBefore: '#d1d5da transparent transparent transparent', | ||
pointMargin: -15, | ||
pointTop: 100, | ||
pointTopAfter: -14, | ||
pointTopBefore: 16, | ||
timeout: null, | ||
top: 'unset', | ||
width: 400 | ||
} | ||
|
||
componentDidMount() { | ||
glossary.contents.forEach((glossaryItem, index) => { | ||
if (glossaryItem.match.includes(this.props.text)) { | ||
this.setState({ | ||
description: glossaryItem.desc, | ||
header: glossaryItem.name, | ||
key: index | ||
}) | ||
} | ||
}) | ||
} | ||
|
||
tooltipPositionEval = () => { | ||
const markdownBody = document.getElementsByClassName('markdown-body')[0] | ||
const tooltipBoundary = document | ||
.getElementById(`tooltip-text-${this.state.key}`) | ||
.getBoundingClientRect() | ||
const tooltipBoxHeight = document.getElementById( | ||
`tooltip-box-${this.state.key}` | ||
).offsetHeight | ||
const tooltipHeight = tooltipBoundary.top - tooltipBoxHeight | ||
const maxWidth = markdownBody.offsetLeft + markdownBody.clientWidth | ||
const container = document.getElementsByClassName('tooltip-container')[0] | ||
const tooltipWidth = container.offsetLeft + this.state.width | ||
const vertical = tooltipHeight > 80 ? 'top' : 'bottom' | ||
algomaster99 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const horizontal = tooltipWidth > maxWidth ? 'right' : 'left' | ||
|
||
switch (`${horizontal} ${vertical}`) { | ||
case 'left top': | ||
this.setState({ | ||
margin: -70, | ||
pointBorderAfter: 'white transparent transparent transparent', | ||
pointBorderBefore: '#d1d5da transparent transparent transparent', | ||
pointMargin: -15, | ||
pointTop: 100, | ||
pointTopAfter: 'unset', | ||
pointTopBefore: 'unset', | ||
top: -tooltipBoxHeight | ||
}) | ||
break | ||
case 'right top': | ||
this.setState({ | ||
margin: -340, | ||
pointBorderAfter: 'white transparent transparent transparent', | ||
pointBorderBefore: '#d1d5da transparent transparent transparent', | ||
pointMargin: 260, | ||
pointTop: 100, | ||
pointTopAfter: 'unset', | ||
pointTopBefore: 'unset', | ||
top: -tooltipBoxHeight | ||
}) | ||
break | ||
case 'left bottom': | ||
this.setState({ | ||
margin: -70, | ||
pointBorderAfter: 'transparent transparent white transparent', | ||
pointBorderBefore: 'transparent transparent #d1d5da transparent', | ||
pointMargin: -15, | ||
pointTop: -15, | ||
pointTopAfter: -20, | ||
pointTopBefore: -23, | ||
top: 40 | ||
}) | ||
break | ||
case 'right bottom': | ||
this.setState({ | ||
margin: -340, | ||
pointBorderAfter: 'transparent transparent white transparent', | ||
pointBorderBefore: 'transparent transparent #d1d5da transparent', | ||
pointMargin: 260, | ||
pointTop: -15, | ||
pointTopAfter: -20, | ||
pointTopBefore: -23, | ||
top: 40 | ||
}) | ||
break | ||
} | ||
} | ||
|
||
hoverIn = () => { | ||
if (this.state.interval) { | ||
clearTimeout(this.state.interval) | ||
this.setState( | ||
{ | ||
interval: null, | ||
hover: true | ||
}, | ||
this.tooltipPositionEval | ||
) | ||
} else { | ||
this.setState( | ||
{ | ||
hover: true | ||
}, | ||
this.tooltipPositionEval | ||
) | ||
} | ||
} | ||
|
||
hoverOut = () => { | ||
this.setState({ | ||
interval: setTimeout(() => { | ||
this.setState({ | ||
hover: false | ||
}) | ||
}, 100) | ||
}) | ||
} | ||
|
||
render() { | ||
return ( | ||
<> | ||
<HighlightedText | ||
onMouseOver={this.hoverIn} | ||
onMouseLeave={this.hoverOut} | ||
> | ||
<span id={`tooltip-text-${this.state.key}`}>{this.props.text}</span> | ||
</HighlightedText> | ||
{this.state.hover && ( | ||
<TooltipContainer | ||
className="tooltip-container" | ||
onMouseOver={this.hoverIn} | ||
onMouseLeave={this.hoverOut} | ||
> | ||
<TooltipText | ||
id={`tooltip-box-${this.state.key}`} | ||
margin={this.state.margin} | ||
width={this.state.width} | ||
pointBorderAfter={this.state.pointBorderAfter} | ||
pointBorderBefore={this.state.pointBorderBefore} | ||
pointMargin={this.state.pointMargin} | ||
pointTop={this.state.pointTop} | ||
pointTopBefore={this.state.pointTopBefore} | ||
pointTopAfter={this.state.pointTopAfter} | ||
top={this.state.top} | ||
bottom={this.state.bottom} | ||
> | ||
<div className="header">{this.state.header}</div> | ||
<ReactMarkdown source={this.state.description} /> | ||
</TooltipText> | ||
</TooltipContainer> | ||
)} | ||
</> | ||
) | ||
} | ||
} | ||
|
||
const HighlightedText = styled.span` | ||
border-bottom: 1px black dotted; | ||
` | ||
|
||
const TooltipContainer = styled.div` | ||
position: absolute; | ||
display: inline-block; | ||
z-index: 300000000; | ||
background-color: white; | ||
` | ||
|
||
const TooltipText = styled.div` | ||
padding: 8px 10px; | ||
border: 1px solid #d1d5da; | ||
border-radius: 3px; | ||
background-color: white; | ||
position: absolute; | ||
z-index: 1; | ||
top: ${props => { | ||
if (props.top === 'unset') { | ||
return 'unset' | ||
} else { | ||
return `${props.top}px` | ||
} | ||
}}; | ||
margin-left: ${props => props.margin || -70}px; | ||
width: ${props => props.width || 400}px; | ||
|
||
&:after, | ||
&:before { | ||
content: ''; | ||
position: absolute; | ||
top: ${props => props.pointTop}%; | ||
border-style: solid; | ||
margin-left: ${props => props.pointMargin || -15}px; | ||
} | ||
|
||
&:after { | ||
top: ${props => props.pointTopAfter}px; | ||
left: 10%; | ||
border-width: 10px; | ||
border-color: ${props => props.pointBorderAfter}; | ||
} | ||
&:before { | ||
top: ${props => props.pointTopBefore}px; | ||
left: 10%; | ||
border-width: 11px; | ||
border-color: ${props => props.pointBorderBefore}; | ||
} | ||
|
||
.header { | ||
font-size: 1.3em; | ||
font-weight: bold; | ||
} | ||
` | ||
|
||
export default Tooltip |
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
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.
it's usually
.dvc/cache
- not alwaysThere 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.
Use
name: 'DVC Cache'
, and you can probably copy adesc
from https://dvc.org/doc/user-guide/dvc-files-and-directories or https://dvc.org/doc/commands-reference/cacheBTW we'll have to review if we need to unify al these definitions throughout docs... But that's for afuture issue i.e. #461There 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.
please address this comment