Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
paragon
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
paragon
Commits
da8908e5
Commit
da8908e5
authored
Jun 08, 2017
by
Sarah Fischmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
setting up checkbox, cleaning up code
parent
a6b371b2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
24 deletions
+25
-24
src/CheckBox.jsx
+15
-14
stories/index.jsx
+10
-10
No files found.
src/CheckBox.jsx
View file @
da8908e5
import
React
from
'react'
;
import
React
from
'react'
;
import
{
Input
}
from
'reactstrap'
;
import
PropTypes
from
'prop-types'
;
import
PropTypes
from
'prop-types'
;
import
asInput
,
{
inputProps
}
from
'./utils/asInput'
;
import
{
inputProps
}
from
'./utils/asInput'
;
class
CheckBox
extends
React
.
Component
{
class
CheckBox
extends
React
.
Component
{
constructor
(
props
)
{
constructor
(
props
)
{
super
(
props
);
super
(
props
);
this
.
state
=
{
this
.
state
=
{
pressed
:
"false"
pressed
:
'false'
,
};
};
}
}
handleClick
()
{
handleClick
()
{
if
(
this
.
state
.
pressed
==
"true"
)
{
if
(
this
.
state
.
pressed
==
=
'true'
)
{
this
.
setState
({
this
.
setState
({
pressed
:
"false"
,
pressed
:
'false'
,
})
}
else
{
});
}
else
{
this
.
setState
({
this
.
setState
({
pressed
:
"true"
pressed
:
'true'
,
});
});
}
}
}
}
render
()
{
render
()
{
const
props
=
{
...
this
.
props
};
const
props
=
{
...
this
.
props
};
return
(
return
(
<
form
>
<
form
>
<
label
class
=
"form-check-label"
>
<
label
htmlFor=
{
props
.
checkLabel
}
className
=
"form-check-label"
>
<
input
<
input
type=
"checkbox"
type=
"checkbox"
class=
"form-check-input"
class
Name
=
"form-check-input"
name=
{
props
.
name
}
name=
{
props
.
name
}
aria
-
descri
v
edby=
{
props
.
describedby
}
aria
-
descri
b
edby=
{
props
.
describedby
}
aria
-
checked=
{
this
.
state
.
pressed
}
aria
-
checked=
{
this
.
state
.
pressed
}
tab
i
ndex=
"0"
tab
I
ndex=
"0"
onClick=
{
()
=>
this
.
handleClick
()
}
onClick=
{
()
=>
this
.
handleClick
()
}
/>
/>
{
props
.
checkLabel
}
{
props
.
checkLabel
}
</
label
>
</
label
>
</
form
>
</
form
>
...
@@ -48,7 +49,7 @@ class CheckBox extends React.Component {
...
@@ -48,7 +49,7 @@ class CheckBox extends React.Component {
CheckBox
.
propTypes
=
{
CheckBox
.
propTypes
=
{
...
inputProps
,
...
inputProps
,
checkLabel
:
PropTypes
.
string
.
isRequired
checkLabel
:
PropTypes
.
string
.
isRequired
,
};
};
export
default
CheckBox
;
export
default
CheckBox
;
stories/index.jsx
View file @
da8908e5
...
@@ -4,7 +4,7 @@ import { storiesOf, linkTo } from '@kadira/storybook';
...
@@ -4,7 +4,7 @@ import { storiesOf, linkTo } from '@kadira/storybook';
import
TextInput
from
'../src/TextInput'
;
import
TextInput
from
'../src/TextInput'
;
import
SelectInput
from
'../src/SelectInput'
;
import
SelectInput
from
'../src/SelectInput'
;
import
CheckBox
from
'../src/CheckBox'
import
CheckBox
from
'../src/CheckBox'
;
import
Welcome
from
'./Welcome'
;
import
Welcome
from
'./Welcome'
;
storiesOf
(
'Welcome'
,
module
)
storiesOf
(
'Welcome'
,
module
)
...
@@ -126,12 +126,12 @@ storiesOf('SelectInput', module)
...
@@ -126,12 +126,12 @@ storiesOf('SelectInput', module)
/>
/>
));
));
storiesOf
(
'CheckBox'
,
module
)
storiesOf
(
'CheckBox'
,
module
)
.
add
(
'basic usage'
,
()
=>
(
.
add
(
'basic usage'
,
()
=>
(
<
CheckBox
<
CheckBox
name=
"checkbox"
name=
"checkbox"
label=
"CheckBox"
label=
"CheckBox"
describedBy=
"checkbox"
describedBy=
"checkbox"
checkLabel=
"check me out"
checkLabel=
"check me out"
/>
/>
));
));
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