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
dc0bfb26
Unverified
Commit
dc0bfb26
authored
Sep 12, 2019
by
Peter Holmberg
Committed by
GitHub
Sep 12, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix: Align buttons and label in ToggleButtonGroup (#19036)
parent
e4e77194
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
7 deletions
+56
-7
packages/grafana-ui/src/components/ToggleButtonGroup/ToggleButtonGroup.story.tsx
+49
-0
packages/grafana-ui/src/components/ToggleButtonGroup/ToggleButtonGroup.tsx
+2
-2
public/sass/components/_gf-form.scss
+4
-0
public/sass/components/_toggle_button_group.scss
+1
-1
public/sass/pages/_explore.scss
+0
-4
No files found.
packages/grafana-ui/src/components/ToggleButtonGroup/ToggleButtonGroup.story.tsx
0 → 100644
View file @
dc0bfb26
import
React
from
'react'
;
import
{
storiesOf
}
from
'@storybook/react'
;
import
{
action
}
from
'@storybook/addon-actions'
;
import
{
ToggleButton
,
ToggleButtonGroup
}
from
'./ToggleButtonGroup'
;
import
{
UseState
}
from
'../../utils/storybook/UseState'
;
import
{
withCenteredStory
}
from
'../../utils/storybook/withCenteredStory'
;
const
ToggleButtonGroupStories
=
storiesOf
(
'UI/ToggleButtonGroup'
,
module
);
const
options
=
[
{
value
:
'first'
,
label
:
'First'
},
{
value
:
'second'
,
label
:
'Second'
},
{
value
:
'third'
,
label
:
'Third'
},
];
ToggleButtonGroupStories
.
addDecorator
(
withCenteredStory
);
ToggleButtonGroupStories
.
add
(
'default'
,
()
=>
{
return
(
<
UseState
initialState=
{
{
value
:
'first'
,
}
}
>
{
(
value
,
updateValue
)
=>
{
return
(
<
ToggleButtonGroup
label=
"Options"
>
{
options
.
map
((
option
,
index
)
=>
{
return
(
<
ToggleButton
key=
{
`${option.value}-${index}`
}
value=
{
option
.
value
}
onChange=
{
newValue
=>
{
action
(
'on change'
)(
newValue
);
updateValue
({
value
:
newValue
});
}
}
selected=
{
value
.
value
===
option
.
value
}
>
{
option
.
label
}
</
ToggleButton
>
);
})
}
</
ToggleButtonGroup
>
);
}
}
</
UseState
>
);
});
packages/grafana-ui/src/components/ToggleButtonGroup/ToggleButtonGroup.tsx
View file @
dc0bfb26
...
...
@@ -12,7 +12,7 @@ export class ToggleButtonGroup extends PureComponent<ToggleButtonGroupProps> {
const
{
children
,
label
,
transparent
}
=
this
.
props
;
return
(
<
div
className=
"gf-form"
>
<
div
className=
"gf-form
gf-form--align-center
"
>
{
label
&&
<
label
className=
{
`gf-form-label ${transparent ? 'gf-form-label--transparent' : ''}`
}
>
{
label
}
</
label
>
}
<
div
className=
{
`toggle-button-group ${transparent ? 'toggle-button-group--transparent' : ''}`
}
>
{
children
}
</
div
>
</
div
>
...
...
@@ -44,7 +44,7 @@ export const ToggleButton: FC<ToggleButtonProps> = ({
}
};
const
btnClassName
=
`btn
${
className
}
${
selected
?
'
active'
:
''
}
`
;
const
btnClassName
=
`btn
${
className
}
${
selected
?
'
active'
:
''
}
`
;
const
button
=
(
<
button
className=
{
btnClassName
}
onClick=
{
onClick
}
>
<
span
>
{
children
}
</
span
>
...
...
public/sass/components/_gf-form.scss
View file @
dc0bfb26
...
...
@@ -20,6 +20,10 @@ $input-border: 1px solid $input-border-color;
justify-content
:
flex-end
;
}
&
--align-center
{
align-content
:
center
;
}
&
--alt
{
flex-direction
:
column
;
align-items
:
flex-start
;
...
...
public/sass/components/_toggle_button_group.scss
View file @
dc0bfb26
.toggle-button-group
{
display
:
flex
;
padding-top
:
5px
;
.btn
{
@include
buttonBackground
(
$btn-inverse-bg
,
$btn-inverse-bg-hl
,
$btn-inverse-text-color
,
$btn-inverse-text-shadow
);
height
:
$input-height
;
padding
:
7px
10px
;
font-weight
:
$font-weight-semi-bold
;
font-size
:
$font-size-sm
;
...
...
public/sass/pages/_explore.scss
View file @
dc0bfb26
...
...
@@ -349,10 +349,6 @@
.query-type-toggle
{
margin-left
:
5px
;
.toggle-button-group
{
padding-top
:
2px
;
}
.btn.active
{
background-color
:
$input-bg
;
background-image
:
none
;
...
...
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