Skip to content

Commit 5018caa

Browse files
authored
fix: put Single Stat default styles into stylesheet to prevent font flashing (#822)
1 parent a88b2fb commit 5018caa

14 files changed

+104
-29
lines changed

giraffe/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ TableGraphLayerConfig uses the `fluxResponse` property from `config` as the data
838838
</div>
839839
</pre>
840840

841-
- **style**: _Object. Optional. Recommendation: do not include._ An object containing the key-value pairs used for inline styling `.giraffe-layer-single-stat` by setting its [style property](https://developer.mozilla.org/en-US/docs/Web/API/ElementCSSInlineStyle/style). If used, please be aware of existing default styles that may need to be overridden. `backgroundColor` cannot be overridden and is controlled by the **backgroundColor** option (see above). See the `SINGLE_STAT_DEFAULT_STYLE` [here](./src/constants/singleStatStyles.ts).
841+
- **style**: _Object. Optional. Recommendation: do not include._ An object containing the key-value pairs used for inline styling `.giraffe-layer-single-stat` by setting its [style property](https://developer.mozilla.org/en-US/docs/Web/API/ElementCSSInlineStyle/style). If used, please be aware of existing default styles that may need to be overridden. `backgroundColor` cannot be overridden and is controlled by the **backgroundColor** option (see above).
842842

843843
- **resizerStyle**: _Object. Optional. Recommendation: do not include._ An object containing the key-value pairs used for inline styling `.giraffe-single-stat--resizer` by setting its [style property](https://developer.mozilla.org/en-US/docs/Web/API/ElementCSSInlineStyle/style). If used, please be aware of existing default styles that may need to be overridden. See the `SINGLE_STAT_RESIZER_DEFAULT_STYLE` [here](./src/constants/singleStatStyles.ts).
844844

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.37.1",
3+
"version": "2.38.0",
44
"main": "dist/index.js",
55
"module": "dist/index.js",
66
"license": "MIT",
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
@import '../../style/variables.scss';
2+
3+
@font-face {
4+
font-family: 'Proxima Nova';
5+
font-style: normal;
6+
font-weight: 300;
7+
src: url('../../fonts/ProximaNova-Light.woff2') format('woff2');
8+
font-display: block;
9+
}
10+
@font-face {
11+
font-family: 'Proxima Nova';
12+
font-style: normal;
13+
font-weight: 400;
14+
src: url('../../fonts/ProximaNova-Regular.woff2') format('woff2');
15+
font-display: block;
16+
}
17+
@font-face {
18+
font-family: 'Proxima Nova';
19+
font-style: normal;
20+
font-weight: 500;
21+
src: url('../../fonts/ProximaNova-Medium.woff2') format('woff2');
22+
font-display: block;
23+
}
24+
@font-face {
25+
font-family: 'Proxima Nova';
26+
font-style: normal;
27+
font-weight: 700;
28+
src: url('../../fonts/ProximaNova-Bold.woff2') format('woff2');
29+
font-display: block;
30+
}
31+
@font-face {
32+
font-family: 'Proxima Nova';
33+
font-style: normal;
34+
font-weight: 900;
35+
src: url('../../fonts/ProximaNova-Black.woff2') format('woff2');
36+
font-display: block;
37+
}
38+
39+
.giraffe-layer-single-stat {
40+
align-items: center;
41+
border-radius: 4px;
42+
bottom: 0;
43+
color: $c-laser;
44+
cursor: text;
45+
display: flex;
46+
font-family: 'Proxima Nova', Helvetica, Arial, Tahoma, Verdana, sans-serif;
47+
height: 100%;
48+
justify-content: center;
49+
left: 0;
50+
overflow: hidden;
51+
padding: 8px;
52+
position: absolute;
53+
right: 0;
54+
top: 0;
55+
width: 100%;
56+
-moz-user-select: text;
57+
-ms-user-select: text;
58+
-webkit-user-select: text;
59+
user-select: text;
60+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// This file is automatically generated.
2+
// Please do not change this file!
3+
interface CssExports {
4+
'giraffe-layer-single-stat': string;
5+
}
6+
export const cssExports: CssExports;
7+
export default cssExports;

giraffe/src/components/SingleStat/SingleStatLayer.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, {FunctionComponent} from 'react'
2+
import classnames from 'classnames'
23
import {
3-
SINGLE_STAT_DEFAULT_STYLE,
44
SINGLE_STAT_DEFAULT_TEST_ID,
55
SINGLE_STAT_RESIZER_DEFAULT_STYLE,
66
SINGLE_STAT_SVG_DEFAULT_ATTRIBUTES,
@@ -10,6 +10,10 @@ import {
1010
import {SingleStatLayerConfig} from '../../types'
1111
import {formatStatValue} from '../../utils/formatStatValue'
1212

13+
import styles from './SingleStatLayer.scss'
14+
15+
import {styleReducer} from '../../utils/styleReducer'
16+
1317
interface Props {
1418
stat: number
1519
config: SingleStatLayerConfig
@@ -36,6 +40,12 @@ export const SingleStatLayer: FunctionComponent<Props> = props => {
3640
textOpacity = 1,
3741
} = config
3842

43+
const singleStatLayerClasses = styleReducer(
44+
styles,
45+
'giraffe-layer giraffe-layer-single-stat',
46+
classnames('giraffe-layer-single-stat')
47+
)
48+
3949
const formattedValue = formatStatValue(stat, {decimalPlaces, prefix, suffix})
4050

4151
let viewBox = getDefaultViewBox(formattedValue)
@@ -49,10 +59,9 @@ export const SingleStatLayer: FunctionComponent<Props> = props => {
4959

5060
return (
5161
<div
52-
className="giraffe-layer giraffe-layer-single-stat"
62+
className={singleStatLayerClasses}
5363
data-testid={testID}
5464
style={{
55-
...SINGLE_STAT_DEFAULT_STYLE,
5665
...style,
5766
backgroundColor: `${backgroundColor}`,
5867
}}
50.5 KB
Binary file not shown.
52.9 KB
Binary file not shown.
50.4 KB
Binary file not shown.
52.7 KB
Binary file not shown.
52.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)