Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pubsweet
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Giorgio Sironi
pubsweet
Commits
6928c316
Commit
6928c316
authored
7 years ago
by
Aanand Prasad
Committed by
Jure
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
feat(ui): convert Radio to styled component
parent
7b9239b6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
packages/ui/src/atoms/Radio.js
+90
-18
90 additions, 18 deletions
packages/ui/src/atoms/Radio.js
packages/ui/src/atoms/Radio.local.scss
+0
-87
0 additions, 87 deletions
packages/ui/src/atoms/Radio.local.scss
with
90 additions
and
105 deletions
packages/ui/src/atoms/Radio.js
+
90
−
18
View file @
6928c316
import
React
from
'
react
'
import
React
from
'
react
'
import
classnames
from
'
classnames
'
import
styled
,
{
keyframes
}
from
'
styled-components
'
import
classes
from
'
./Radio.local.scss
'
const
Input
=
styled
.
input
`
display: none;
`
const
PseudoInput
=
styled
.
span
`
--local-border-size: 2px;
--local-borderTwo-size: 1px;
display: inline-block;
content: ' ';
width: 0.6em;
height: 0.6em;
vertical-align: center;
margin-left: 0.2em;
margin-right: 0.6em;
border: var(--local-border-size) solid white;
border-radius: 50%;
transition: border 0.2s ease;
`
const
Label
=
styled
.
span
`
display: inline-block;
font-family: inherit;
font-size: 1em;
font-style: italic;
`
const
checking
=
keyframes
`
0% {
transform: scale(0.8);
}
20% {
transform: scale(1.2);
}
80% {
transform: scale(1);
}
100% {
transform: scale(1);
}
`
const
Root
=
styled
.
label
`
align-items: center;
cursor: pointer;
display:
${
props
=>
(
props
.
inline
?
'
inline-flex
'
:
'
flex
'
)}
;
transition: all 2s;
&:not(:last-child) {
margin-right:
${
props
=>
(
props
.
inline
?
'
2.7em
'
:
'
0
'
)}
;
margin-bottom:
${
props
=>
(
props
.
inline
?
'
0
'
:
'
0.5rem
'
)}
;
}
${
PseudoInput
}
{
background:
${
props
=>
(
props
.
checked
?
'
currentcolor
'
:
'
transparent
'
)}
;
box-shadow: 0 0 0 var(--local-borderTwo-size) currentcolor;
}
&:hover {
${
Label
}
{
color:
${
props
=>
(
props
.
checked
?
'
inherit
'
:
'
var(--color-primary)
'
)}
;
}
${
PseudoInput
}
{
animation-name:
${
props
=>
(
props
.
checked
?
'
none
'
:
checking
)}
;
animation-duration: 0.5s;
box-shadow: 0 0 0 var(--local-borderTwo-size)
${
props
=>
(
props
.
checked
?
'
currentcolor
'
:
'
var(--color-primary)
'
)}
;
}
}
`
/* Not used for now
.root.author {
font-family: var(--font-author);
}
.root.author span {
font-size: 1.3em;
text-transform: lowercase;
}
*/
const
Radio
=
({
const
Radio
=
({
className
,
className
,
...
@@ -14,20 +98,9 @@ const Radio = ({
...
@@ -14,20 +98,9 @@ const Radio = ({
onChange
,
onChange
,
readonly
,
readonly
,
})
=>
(
})
=>
(
<
label
<
Root
checked
=
{
checked
}
style
=
{{
color
}}
>
className
=
{
classnames
(
<
Input
classes
.
root
,
{
[
classes
.
inline
]:
inline
,
[
classes
.
checked
]:
checked
,
},
className
,
)}
style
=
{{
color
}}
>
<
input
checked
=
{
checked
}
checked
=
{
checked
}
className
=
{
classes
.
input
}
disabled
=
{
readonly
}
disabled
=
{
readonly
}
name
=
{
name
}
name
=
{
name
}
onChange
=
{
onChange
}
onChange
=
{
onChange
}
...
@@ -35,9 +108,8 @@ const Radio = ({
...
@@ -35,9 +108,8 @@ const Radio = ({
type
=
"
radio
"
type
=
"
radio
"
value
=
{
value
}
value
=
{
value
}
/>{' '
}
/>{' '
}
<
span
className
=
{
classes
.
pseudoInput
}
style
=
{{
color
}}
/>{' '
}
<
PseudoInput
style
=
{{
color
}}
/> <Label> {label} </
Label
>
{
'
'
}
<
span
className
=
{
classes
.
label
}
>
{
label
}
<
/span>{' '
}
<
/Root
>
<
/label
>
)
)
export
default
Radio
export
default
Radio
This diff is collapsed.
Click to expand it.
packages/ui/src/atoms/Radio.local.scss
deleted
100644 → 0
+
0
−
87
View file @
7b9239b6
.root
{
align-items
:
center
;
cursor
:
pointer
;
display
:
flex
;
transition
:
all
2s
;
}
.root.inline
{
display
:
inline-flex
;
}
.root.inline
:not
(
:last-child
)
{
margin-right
:
2
.7em
;
}
.root
:not
(
.inline
)
:not
(
:last-child
)
{
margin-bottom
:
0
.5rem
;
}
.label
{
display
:
inline-block
;
font-family
:
inherit
;
font-size
:
1em
;
font-style
:
italic
;
}
.root
:not
(
.checked
)
:hover
.label
{
color
:
var
(
--
color-primary
);
}
.input
{
display
:
none
;
}
.pseudoInput
{
--local-border-size
:
2px
;
--local-borderTwo-size
:
1px
;
border
:
var
(
--
local-border-size
)
solid
white
;
border-radius
:
50%
;
box-shadow
:
0
0
0
var
(
--
local-borderTwo-size
)
currentcolor
;
content
:
' '
;
display
:
inline-block
;
height
:
0
.6em
;
margin-left
:
0
.2em
;
margin-right
:
0
.6em
;
transition
:
border
0
.2s
ease
;
vertical-align
:
center
;
width
:
0
.6em
;
}
.root.checked
.pseudoInput
{
background
:
currentcolor
;
box-shadow
:
0
0
0
var
(
--
local-borderTwo-size
)
currentcolor
;
}
.root
:not
(
.checked
)
:hover
.pseudoInput
{
animation
:
checking
0
.5s
;
background
:
var
(
--
color-primary
);
box-shadow
:
0
0
0
var
(
--
local-borderTwo-size
)
var
(
--
color-primary
);
}
/* Not used for now
.root.author {
font-family: var(--font-author);
}
.root.author span {
font-size: 1.3em;
text-transform: lowercase;
}
*/
@keyframes
checking
{
0
%
{
transform
:
scale
(
0
.8
);
}
20
%
{
transform
:
scale
(
1
.2
);
}
80
%
{
transform
:
scale
(
1
);
}
100
%
{
transform
:
scale
(
1
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment