Skip to content

Commit 909ac2c

Browse files
authored
feat: add optional svg style to disable user select for Single Stat (#817)
1 parent fadfb2e commit 909ac2c

File tree

7 files changed

+26
-18
lines changed

7 files changed

+26
-18
lines changed

giraffe/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@influxdata/giraffe",
3-
"version": "2.36.1",
3+
"version": "2.37.0",
44
"main": "dist/index.js",
55
"module": "dist/index.js",
66
"license": "MIT",

giraffe/src/components/SingleStat/SingleStatLayer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
SINGLE_STAT_SVG_DEFAULT_ATTRIBUTES,
77
SINGLE_STAT_SVG_TEXT_DEFAULT_ATTRIBUTES,
88
SINGLE_STAT_SVG_TEXT_DEFAULT_STYLE,
9-
} from '../../constants/singleStatStyles'
9+
} from '../../style/singleStatStyles'
1010
import {SingleStatLayerConfig} from '../../types'
1111
import {formatStatValue} from '../../utils/formatStatValue'
1212

giraffe/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export {lineTransform} from './transforms/line'
2727
export * from './constants/colorSchemes'
2828
export * from './constants/columnKeys'
2929
export * from './style/gaugeStyles'
30-
export * from './constants/singleStatStyles'
30+
export * from './style/singleStatStyles'
3131
export {DEFAULT_TABLE_COLORS} from './constants/tableGraph'
3232

3333
// Types
Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import CSS from 'csstype'
2-
1+
import {CSSProperties} from 'react'
32
export const LASER = '#00C9FF'
43

54
export const SINGLE_STAT_DEFAULT_TEST_ID = 'giraffe-layer-single-stat'
65

7-
export const SINGLE_STAT_DEFAULT_STYLE: CSS.Properties = {
6+
export const SINGLE_STAT_DEFAULT_STYLE: CSSProperties = {
87
alignItems: 'center',
98
borderRadius: '4px',
109
bottom: 0,
@@ -27,7 +26,7 @@ export const SINGLE_STAT_DEFAULT_STYLE: CSS.Properties = {
2726
width: '100%',
2827
}
2928

30-
export const SINGLE_STAT_RESIZER_DEFAULT_STYLE: CSS.Properties = {
29+
export const SINGLE_STAT_RESIZER_DEFAULT_STYLE: CSSProperties = {
3130
overflow: 'hidden',
3231
width: '100%',
3332
height: '100%',
@@ -47,6 +46,14 @@ export const SINGLE_STAT_SVG_TEXT_DEFAULT_ATTRIBUTES = {
4746
opacity: 1,
4847
}
4948

50-
export const SINGLE_STAT_SVG_TEXT_DEFAULT_STYLE: CSS.Properties = {
49+
export const SINGLE_STAT_SVG_TEXT_DEFAULT_STYLE: CSSProperties = {
5150
fill: LASER,
5251
}
52+
53+
export const SINGLE_STAT_SVG_NO_USER_SELECT: CSSProperties = {
54+
MozUserSelect: 'none',
55+
WebkitTouchCallout: 'none',
56+
WebkitUserSelect: 'none',
57+
msUserSelect: 'none',
58+
userSelect: 'none',
59+
}

giraffe/src/types/index.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import CSS from 'csstype'
21
import {CSSProperties, ReactNode} from 'react'
32
import {TimeZone} from './timeZones'
43
import {GeoLayerConfig} from './geo'
@@ -295,7 +294,7 @@ export interface AnnotationLayerConfig {
295294
hoverDimension?: LineHoverDimension | 'auto'
296295
hoverMargin?: number
297296
svgAttributes?: SVGAttributes
298-
svgStyle?: CSS.Properties
297+
svgStyle?: CSSProperties
299298
lineWidth?: number
300299
handleAnnotationClick?: (id: string) => void
301300
}
@@ -364,12 +363,12 @@ export interface SingleStatLayerConfig {
364363
textOpacity?: number
365364
backgroundColor?: string
366365
testID?: string
367-
style?: CSS.Properties
368-
resizerStyle?: CSS.Properties
366+
style?: CSSProperties
367+
resizerStyle?: CSSProperties
369368
svgAttributes?: SVGAttributes
370-
svgStyle?: CSS.Properties
369+
svgStyle?: CSSProperties
371370
svgTextAttributes?: SVGAttributes
372-
svgTextStyle?: CSS.Properties
371+
svgTextStyle?: CSSProperties
373372
}
374373

375374
export type SVGAttributeFunction = (stat: string) => string

stories/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@influxdata/giraffe-stories",
3-
"version": "2.36.1",
3+
"version": "2.37.0",
44
"license": "MIT",
55
"repository": {
66
"type": "git",

stories/src/singleStat.stories.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import * as React from 'react'
1+
import React from 'react'
22
import {storiesOf} from '@storybook/react'
33
import {boolean, number, select, text, withKnobs} from '@storybook/addon-knobs'
44
import {
55
Config,
6-
Plot,
7-
LayerConfig,
86
LASER,
7+
LayerConfig,
8+
Plot,
9+
SINGLE_STAT_SVG_NO_USER_SELECT,
910
timeFormatter,
1011
} from '../../giraffe/src'
1112

@@ -247,6 +248,7 @@ storiesOf('Single Stat', module)
247248
viewBox: stat =>
248249
`${viewBoxX} ${viewBoxY} ${stat.length * viewBoxWidth} 100`,
249250
},
251+
svgStyle: SINGLE_STAT_SVG_NO_USER_SELECT,
250252
})
251253
}
252254

0 commit comments

Comments
 (0)