Skip to content

Commit

Permalink
fix: make annotation target better clickable (#517)
Browse files Browse the repository at this point in the history
This PR makes the annotation click target better clickable and also improves the UX by making the hover state of the line to change opacity, indicating that it's a clickable target.
  • Loading branch information
ChitlangeSahas authored Mar 29, 2021
1 parent d8977e2 commit 395f67c
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 19 deletions.
2 changes: 1 addition & 1 deletion giraffe/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@influxdata/giraffe",
"version": "2.7.0",
"version": "2.7.1",
"main": "dist/index.js",
"module": "src/index.js",
"license": "MIT",
Expand Down
12 changes: 12 additions & 0 deletions giraffe/src/components/AnnotationLine.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
Annotation Line Styles
------------------------------------------------------------------------------
*/

.giraffe-annotation-hover{
cursor: pointer;
&:hover {
opacity: 80%;
transition: opacity 0.25s ease;
}
}
7 changes: 7 additions & 0 deletions giraffe/src/components/AnnotationLine.scss.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// This file is automatically generated.
// Please do not change this file!
interface CssExports {
'giraffe-annotation-hover': string;
}
export const cssExports: CssExports;
export default cssExports;
39 changes: 22 additions & 17 deletions giraffe/src/components/AnnotationLine.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React, {FunctionComponent, createElement} from 'react'
import {AnnotationDimension, AnnotationPinType} from '../types'

import styles from './AnnotationLine.scss'

interface AnnotationLineProps {
dimension: AnnotationDimension
color: string
Expand Down Expand Up @@ -29,6 +31,16 @@ export const AnnotationLine: FunctionComponent<AnnotationLineProps> = props => {
if (dimension === 'y') {
return (
<>
<line
x1="0"
x2={length}
y1={clampedStart}
y2={clampedStart}
stroke={color}
strokeWidth={strokeWidth}
id={props.id}
className={`${styles['giraffe-annotation-hover']} giraffe-annotation-line`}
/>
{pin === 'circle' &&
createElement('circle', {
r: PIN_CIRCLE_RADIUS,
Expand All @@ -53,20 +65,22 @@ export const AnnotationLine: FunctionComponent<AnnotationLineProps> = props => {
PIN_TRIANGLE_WIDTH} ${length}, ${clampedStart}`,
fill: color,
})}
<line
x1="0"
x2={length}
y1={clampedStart}
y2={clampedStart}
stroke={color}
strokeWidth={strokeWidth}
/>
</>
)
}

return (
<>
<line
x1={clampedStart}
x2={clampedStart}
y1="0"
y2={length}
stroke={color}
strokeWidth={strokeWidth}
id={props.id}
className={`${styles['giraffe-annotation-hover']} giraffe-annotation-line`}
/>
{pin === 'circle' &&
createElement('circle', {
r: PIN_CIRCLE_RADIUS,
Expand All @@ -91,15 +105,6 @@ export const AnnotationLine: FunctionComponent<AnnotationLineProps> = props => {
2} ${clampedStart}, ${PIN_TRIANGLE_HEIGHT}`,
fill: color,
})}
<line
x1={clampedStart}
x2={clampedStart}
y1="0"
y2={length}
stroke={color}
strokeWidth={strokeWidth}
className="giraffe-annotation-line"
/>
</>
)
}
Expand Down
2 changes: 1 addition & 1 deletion giraffe/src/components/AnnotationTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const AnnotationTooltip: FunctionComponent<Props> = props => {

let tooltipCaretStyle: CSSProperties = {
position: 'absolute',
borderWidth: '10px',
borderWidth: '7px',
borderStyle: 'solid',
borderColor: 'transparent',
zIndex: 2,
Expand Down

0 comments on commit 395f67c

Please sign in to comment.