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
9c84dc96
Commit
9c84dc96
authored
7 years ago
by
Aanand Prasad
Committed by
Jure
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
feat(ui): convert Button to a styled component
parent
ca281cc1
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/Button.js
+97
-23
97 additions, 23 deletions
packages/ui/src/atoms/Button.js
packages/ui/src/atoms/Button.local.scss
+0
-102
0 additions, 102 deletions
packages/ui/src/atoms/Button.local.scss
with
97 additions
and
125 deletions
packages/ui/src/atoms/Button.js
+
97
−
23
View file @
9c84dc96
import
React
from
'
react
'
import
classnames
from
'
classnames
'
import
classes
from
'
./Button.local.scss
'
const
Button
=
({
className
,
children
,
type
=
'
button
'
,
disabled
,
primary
,
onClick
,
})
=>
(
<
button
className
=
{
classnames
(
className
,
classes
.
root
,
{
[
classes
.
disabled
]:
disabled
,
[
classes
.
primary
]:
primary
,
})}
disabled
=
{
disabled
}
onClick
=
{
onClick
}
type
=
{
type
}
>
{
children
}
<
/button
>
)
import
styled
from
'
styled-components
'
const
BaseButton
=
styled
.
button
.
attrs
({
type
:
'
button
'
,
})
`
background: #ddd;
border: none;
cursor: pointer;
font-family: var(--font-interface);
font-size: inherit;
letter-spacing: 0.05em;
padding: 10px 20px;
position: relative;
text-transform: uppercase;
&:hover,
&:focus {
background: #777;
color: white;
outline: 1px solid transparent;
}
&:active {
transform: scale(0.8);
}
& ::after {
animation: 1s warning;
opacity: 1;
}
`
const
PrimaryButton
=
BaseButton
.
extend
`
background-color: var(--color-primary);
border: 2px solid transparent;
border-bottom: 4px solid var(--color-primary);
color: white;
&:hover {
background: white;
border: 2px solid var(--color-primary);
border-bottom: 4px solid var(--color-primary);
color: var(--color-primary);
outline: 1px solid transparent;
}
&:focus {
background: white;
border: 2px solid var(--color-primary);
border-bottom: 4px solid var(--color-primary);
box-shadow: 0 2px 0 0 var(--color-primary);
color: var(--color-primary);
outline: 1px solid transparent;
}
`
const
DisabledButton
=
BaseButton
.
extend
.
attrs
({
disabled
:
true
,
})
`
background: white;
border: 2px solid transparent;
border-bottom: 2px solid #bbb;
color: #bbb;
&:hover {
background: transparent;
border: 2px solid transparent;
border-bottom: 2px solid #bbb;
color: #aaa;
cursor: not-allowed;
}
&:hover::after {
color: var(--color-danger);
content: 'sorry, this action is not possible';
display: inline;
font-size: 0.9em;
font-style: italic;
left: 115%;
letter-spacing: 0;
opacity: 1;
position: absolute;
text-align: left;
text-transform: lowercase;
top: 30%;
}
`
const
Button
=
({
children
,
disabled
,
primary
,
...
props
})
=>
{
if
(
disabled
)
{
return
<
DisabledButton
{...
props
}
>
{
children
}
<
/DisabledButton
>
}
if
(
primary
)
{
return
<
PrimaryButton
{...
props
}
>
{
children
}
<
/PrimaryButton
>
}
return
<
BaseButton
{...
props
}
>
{
children
}
<
/BaseButton
>
}
export
default
Button
This diff is collapsed.
Click to expand it.
packages/ui/src/atoms/Button.local.scss
deleted
100644 → 0
+
0
−
102
View file @
ca281cc1
.root
{
background
:
#ddd
;
border
:
none
;
cursor
:
pointer
;
font-family
:
var
(
--
font-interface
);
font-size
:
inherit
;
letter-spacing
:
0
.05em
;
padding
:
10px
20px
;
position
:
relative
;
text-transform
:
uppercase
;
}
.root
:hover
,
.root
:focus
{
background
:
#777
;
color
:
white
;
outline
:
1px
solid
transparent
;
}
// this will be added to the button that need a feedback to the user.
// &::after {
// content: "Saved!";
// top: 20%;
// left: 115%;
// position: absolute;
// background: var(--color-primary);
// color: white;
// padding: 0.1em 0.3em;
// opacity: 0;
// }
.root
:active
{
transform
:
scale
(
0
.8
);
}
.
root
:
:
after
{
animation
:
1s
warning
;
opacity
:
1
;
}
.primary
{
background-color
:
var
(
--
color-primary
);
border
:
2px
solid
transparent
;
border-bottom
:
4px
solid
var
(
--
color-primary
);
color
:
white
;
}
.primary
:hover
{
background
:
white
;
border
:
2px
solid
var
(
--
color-primary
);
border-bottom
:
4px
solid
var
(
--
color-primary
);
color
:
var
(
--
color-primary
);
outline
:
1px
solid
transparent
;
}
.primary
:focus
{
background
:
white
;
border
:
2px
solid
var
(
--
color-primary
);
border-bottom
:
4px
solid
var
(
--
color-primary
);
box-shadow
:
0
2px
0
0
var
(
--
color-primary
);
color
:
var
(
--
color-primary
);
outline
:
1px
solid
transparent
;
}
.disabled
{
background
:
white
;
border
:
2px
solid
transparent
;
border-bottom
:
2px
solid
#bbb
;
color
:
#bbb
;
}
.disabled
:hover
{
background
:
transparent
;
border
:
2px
solid
transparent
;
border-bottom
:
2px
solid
#bbb
;
color
:
#aaa
;
cursor
:
not
-
allowed
;
}
.disabled
:hover::after
{
color
:
var
(
--
color-danger
);
content
:
'sorry, this action is not possible'
;
display
:
inline
;
font-size
:
0
.9em
;
font-style
:
italic
;
left
:
115%
;
letter-spacing
:
0
;
opacity
:
1
;
position
:
absolute
;
text-align
:
left
;
text-transform
:
lowercase
;
top
:
30%
;
// width: 30ch;
}
.addFile
{
background
:
none
;
border
:
none
;
font-style
:
normal
;
letter-spacing
:
0
;
padding
:
0
;
text-transform
:
none
;
}
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