import {Fragment} from 'react';
import styled from '@emotion/styled';
import JSXNode from 'sentry/components/stories/jsxNode';
import JSXProperty from 'sentry/components/stories/jsxProperty';
import SideBySide from 'sentry/components/stories/sideBySide';
import SizingWindow from 'sentry/components/stories/sizingWindow';
import storyBook from 'sentry/stories/storyBook';
import {BigNumberWidget} from 'sentry/views/dashboards/widgets/bigNumberWidget/bigNumberWidget';
export default storyBook(BigNumberWidget, story => {
story('Getting Started', () => {
return (
is a Dashboard Widget Component. It displays
a single large value. Used in places like Dashboards Big Number widgets, Project
Details pages, and Organization Stats pages.
);
});
story('Visualization', () => {
return (
The visualization of a large number, just
like it says on the tin. Depending on the value passed to it, it intelligently
rounds and humanizes the results. If the number is humanized, hovering over the
visualization shows a tooltip with the full value.
also supports string values. This is not
commonly used, but it's capable of rendering timestamps and in fact most fields
defined in our field renderer pipeline
The maximumValue
prop allows setting the maximum displayable value.
e.g., imagine a widget that displays a count. A count of more than a million is
too expensive for the API to compute, so the API returns a maximum of 1,000,000.
If the API returns exactly 1,000,000, that means the actual number is unknown,
something higher than the max. Setting{' '}
will show >1m.
);
});
story('State', () => {
return (
supports the usual loading and error states.
The loading state shows a simple placeholder. The error state also shows an
optional "Retry" button.
{}}
/>
The contents of the error adjust slightly as the widget gets bigger.
{}}
/>
);
});
story('Previous Period Data', () => {
return (
shows the difference of the current value and
the previous period value as the difference between the two values, in small
text next to the main value.
The preferredPolarity
prop controls the color of the comparison
string. Setting mean that a
higher number is better and will paint increases in the value green. Vice
versa with negative polarity. Omitting a preferred polarity will prevent
colorization.
);
});
story('Thresholds', () => {
const meta = {
fields: {
'eps()': 'rate',
},
units: {
'eps()': '1/second',
},
};
const thresholds = {
max_values: {
max1: 20,
max2: 50,
},
unit: '1/second',
};
return (
supports a thresholds
prop. If
specified, the value in the widget will be evaluated against these thresholds,
and indicated using a colorful circle next to the value.
The thresholds respect the preferred polarity. By default, the preferred
polarity is positive (higher numbers are good).
);
});
});
const SmallSizingWindow = styled(SizingWindow)`
width: auto;
height: 200px;
`;
const SmallWidget = styled('div')`
width: 250px;
`;
const MediumWidget = styled('div')`
width: 420px;
`;