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 {
...
@@ -17,7 +17,7 @@ export interface State {
export
class
Switch
extends
PureComponent
<
Props
,
State
>
{
export
class
Switch
extends
PureComponent
<
Props
,
State
>
{
state
=
{
state
=
{
id
:
_
.
uniqueId
(),
id
:
_
.
uniqueId
(
'check-'
),
};
};
internalOnChange
=
(
event
:
React
.
FormEvent
<
HTMLInputElement
>
)
=>
{
internalOnChange
=
(
event
:
React
.
FormEvent
<
HTMLInputElement
>
)
=>
{
...
@@ -29,18 +29,20 @@ export class Switch extends PureComponent<Props, State> {
...
@@ -29,18 +29,20 @@ export class Switch extends PureComponent<Props, State> {
render
()
{
render
()
{
const
{
labelClass
=
''
,
switchClass
=
''
,
label
,
checked
,
transparent
,
className
}
=
this
.
props
;
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
labelClassName
=
`gf-form-label
${
labelClass
}
${
transparent
?
'gf-form-label--transparent'
:
''
}
pointer`
;
const
switchClassName
=
`gf-form-switch
${
switchClass
}
${
transparent
?
'gf-form-switch--transparent'
:
''
}
`
;
const
switchClassName
=
`gf-form-switch
${
switchClass
}
${
transparent
?
'gf-form-switch--transparent'
:
''
}
`
;
return
(
return
(
<
label
htmlFor=
{
labelId
}
className=
{
`gf-form gf-form-switch-container ${className}`
}
>
<
div
className=
"gf-form-switch-container-react"
>
{
label
&&
<
div
className=
{
labelClassName
}
>
{
label
}
</
div
>
}
<
label
htmlFor=
{
labelId
}
className=
{
`gf-form gf-form-switch-container ${className || ''}`
}
>
<
div
className=
{
switchClassName
}
>
{
label
&&
<
div
className=
{
labelClassName
}
>
{
label
}
</
div
>
}
<
input
id=
{
labelId
}
type=
"checkbox"
checked=
{
checked
}
onChange=
{
this
.
internalOnChange
}
/>
<
div
className=
{
switchClassName
}
>
<
span
className=
"gf-form-switch__slider"
/>
<
input
id=
{
labelId
}
type=
"checkbox"
checked=
{
checked
}
onChange=
{
this
.
internalOnChange
}
/>
</
div
>
<
span
className=
"gf-form-switch__slider"
/>
</
label
>
</
div
>
</
label
>
</
div
>
);
);
}
}
}
}
public/sass/components/_switch.scss
View file @
3f1c4c3e
...
@@ -13,6 +13,10 @@ gf-form-switch[disabled] {
...
@@ -13,6 +13,10 @@ gf-form-switch[disabled] {
}
}
}
}
.gf-form-switch-container-react
{
display
:
flex
;
}
.gf-form-switch-container
{
.gf-form-switch-container
{
display
:
flex
;
display
:
flex
;
cursor
:
pointer
;
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