doThings}
+ variant='primary'
+ size='md'
+ />
+```
+
+
+
diff --git a/packages/grafana-ui/src/components/ValuePicker/ValuePicker.story.tsx b/packages/grafana-ui/src/components/ValuePicker/ValuePicker.story.tsx
index a2b4362558d..4ef9d815ab2 100644
--- a/packages/grafana-ui/src/components/ValuePicker/ValuePicker.story.tsx
+++ b/packages/grafana-ui/src/components/ValuePicker/ValuePicker.story.tsx
@@ -1,22 +1,47 @@
-import { text } from '@storybook/addon-knobs';
-import { withCenteredStory } from '../../utils/storybook/withCenteredStory';
-import { ValuePicker } from '@grafana/ui';
import React from 'react';
+import { boolean, select, text } from '@storybook/addon-knobs';
+import { ButtonVariant, ValuePicker } from '@grafana/ui';
import { generateOptions } from '../Select/mockOptions';
+import { getIconKnob } from '../../utils/storybook/knobs';
+import { withCenteredStory } from '../../utils/storybook/withCenteredStory';
+import { ComponentSize } from '../../types/size';
+import mdx from './ValuePicker.mdx';
export default {
title: 'Pickers and Editors/ValuePicker',
component: ValuePicker,
decorators: [withCenteredStory],
+ parameters: {
+ docs: {
+ page: mdx,
+ },
+ },
};
-
+const VISUAL_GROUP = 'Visual options';
+const variants = ['primary', 'secondary', 'destructive', 'link'];
+const sizes = ['sm', 'md', 'lg'];
const options = generateOptions();
export const simple = () => {
- const label = text('Label', 'Pick an option');
+ const label = text('Label', 'Pick an option', VISUAL_GROUP);
+ const variant = select('Variant', variants, 'primary', VISUAL_GROUP);
+ const size = select('Size', sizes, 'md', VISUAL_GROUP);
+ const isFullWidth = boolean('Is full width', false, VISUAL_GROUP);
+ const icon = getIconKnob();
+ const menuPlacement = select('Menu placement', ['auto', 'bottom', 'top'], 'auto', VISUAL_GROUP);
+
return (
- console.log(v)} />
+ console.log(v)}
+ variant={variant as ButtonVariant}
+ icon={icon}
+ isFullWidth={isFullWidth}
+ size={size as ComponentSize}
+ menuPlacement={menuPlacement}
+ />
);
};
diff --git a/packages/grafana-ui/src/components/ValuePicker/ValuePicker.tsx b/packages/grafana-ui/src/components/ValuePicker/ValuePicker.tsx
index cae6b5d608e..530612ef060 100644
--- a/packages/grafana-ui/src/components/ValuePicker/ValuePicker.tsx
+++ b/packages/grafana-ui/src/components/ValuePicker/ValuePicker.tsx
@@ -14,10 +14,15 @@ interface ValuePickerProps {
icon?: IconName;
/** ValuePicker options */
options: Array>;
+ /** Callback to handle selected option */
onChange: (value: SelectableValue) => void;
+ /** Which ButtonVariant to render */
variant?: ButtonVariant;
+ /** Size of button */
size?: ComponentSize;
+ /** Should the picker cover the full width of its parent */
isFullWidth?: boolean;
+ /** Control where the menu is rendered */
menuPlacement?: 'auto' | 'bottom' | 'top';
}