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
3f1c4c3e
Unverified
Commit
3f1c4c3e
authored
Feb 19, 2019
by
Torkel Ödegaard
Committed by
GitHub
Feb 19, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #15531 from grafana/hugoh/react-switch-works-outside-switch
Surrounded Switch with div to restrict size
parents
baddf42c
d2893c2d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
9 deletions
+15
-9
packages/grafana-ui/src/components/Switch/Switch.tsx
+11
-9
public/sass/components/_switch.scss
+4
-0
No files found.
packages/grafana-ui/src/components/Switch/Switch.tsx
View file @
3f1c4c3e
...
...
@@ -17,7 +17,7 @@ export interface State {
export
class
Switch
extends
PureComponent
<
Props
,
State
>
{
state
=
{
id
:
_
.
uniqueId
(),
id
:
_
.
uniqueId
(
'check-'
),
};
internalOnChange
=
(
event
:
React
.
FormEvent
<
HTMLInputElement
>
)
=>
{
...
...
@@ -29,18 +29,20 @@ export class Switch extends PureComponent<Props, State> {
render
()
{
const
{
labelClass
=
''
,
switchClass
=
''
,
label
,
checked
,
transparent
,
className
}
=
this
.
props
;
const
labelId
=
`check-
${
this
.
state
.
id
}
`
;
const
labelId
=
this
.
state
.
id
;
const
labelClassName
=
`gf-form-label
${
labelClass
}
${
transparent
?
'gf-form-label--transparent'
:
''
}
pointer`
;
const
switchClassName
=
`gf-form-switch
${
switchClass
}
${
transparent
?
'gf-form-switch--transparent'
:
''
}
`
;
return
(
<
label
htmlFor=
{
labelId
}
className=
{
`gf-form gf-form-switch-container ${className}`
}
>
{
label
&&
<
div
className=
{
labelClassName
}
>
{
label
}
</
div
>
}
<
div
className=
{
switchClassName
}
>
<
input
id=
{
labelId
}
type=
"checkbox"
checked=
{
checked
}
onChange=
{
this
.
internalOnChange
}
/>
<
span
className=
"gf-form-switch__slider"
/>
</
div
>
</
label
>
<
div
className=
"gf-form-switch-container-react"
>
<
label
htmlFor=
{
labelId
}
className=
{
`gf-form gf-form-switch-container ${className || ''}`
}
>
{
label
&&
<
div
className=
{
labelClassName
}
>
{
label
}
</
div
>
}
<
div
className=
{
switchClassName
}
>
<
input
id=
{
labelId
}
type=
"checkbox"
checked=
{
checked
}
onChange=
{
this
.
internalOnChange
}
/>
<
span
className=
"gf-form-switch__slider"
/>
</
div
>
</
label
>
</
div
>
);
}
}
public/sass/components/_switch.scss
View file @
3f1c4c3e
...
...
@@ -13,6 +13,10 @@ gf-form-switch[disabled] {
}
}
.gf-form-switch-container-react
{
display
:
flex
;
}
.gf-form-switch-container
{
display
:
flex
;
cursor
:
pointer
;
...
...
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