Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
fb516ecf
Unverified
Commit
fb516ecf
authored
Oct 17, 2020
by
Peter Holmberg
Committed by
GitHub
Oct 17, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Docs: Add docs for valuepicker (#28327)
parent
0c09dd35
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
6 deletions
+73
-6
packages/grafana-ui/src/components/ValuePicker/ValuePicker.mdx
+37
-0
packages/grafana-ui/src/components/ValuePicker/ValuePicker.story.tsx
+31
-6
packages/grafana-ui/src/components/ValuePicker/ValuePicker.tsx
+5
-0
No files found.
packages/grafana-ui/src/components/ValuePicker/ValuePicker.mdx
0 → 100644
View file @
fb516ecf
import { Meta, Story, Preview, Props } from '@storybook/addon-docs/blocks';
import { ValuePicker } from './ValuePicker';
<Meta title="MDX|Button" component={ValuePicker} />
# ValuePicker
A component that looks like a button but transforms into a select when clicked.
### Example usage
This component is currently used when adding [FieldOverrides](https://grafana.com/docs/grafana/latest/panels/field-options/) in the panel edit mode.
```tsx
<ValuePicker
label='Choose an option'
options={[
{
value: 'option1',
label: 'Option 1'
},
{
value: 'option2',
label: 'Option 2'
},
{
value: 'option3',
label: 'Option 3'
}
]}
onChange={(value) => doThings}
variant='primary'
size='md'
/>
```
<Props of={ValuePicker} />
packages/grafana-ui/src/components/ValuePicker/ValuePicker.story.tsx
View file @
fb516ecf
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
(
<
div
style=
{
{
width
:
'200px'
}
}
>
<
ValuePicker
options=
{
options
}
label=
{
label
}
onChange=
{
v
=>
console
.
log
(
v
)
}
/>
<
ValuePicker
options=
{
options
}
label=
{
label
}
onChange=
{
v
=>
console
.
log
(
v
)
}
variant=
{
variant
as
ButtonVariant
}
icon=
{
icon
}
isFullWidth=
{
isFullWidth
}
size=
{
size
as
ComponentSize
}
menuPlacement=
{
menuPlacement
}
/>
</
div
>
);
};
packages/grafana-ui/src/components/ValuePicker/ValuePicker.tsx
View file @
fb516ecf
...
...
@@ -14,10 +14,15 @@ interface ValuePickerProps<T> {
icon
?:
IconName
;
/** ValuePicker options */
options
:
Array
<
SelectableValue
<
T
>>
;
/** Callback to handle selected option */
onChange
:
(
value
:
SelectableValue
<
T
>
)
=>
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'
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment