Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
LuckySwap
interface
Commits
31da6cdb
Unverified
Commit
31da6cdb
authored
Jun 18, 2021
by
Justin Domingue
Committed by
GitHub
Jun 18, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: new toggle theme (#1782)
* new toggle theme * moved trans to default * update radius * fianlize styles
parent
4079d8a5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
22 deletions
+27
-22
index.tsx
src/components/Toggle/index.tsx
+23
-20
index.tsx
src/pages/Pool/index.tsx
+4
-2
No files found.
src/components/Toggle/index.tsx
View file @
31da6cdb
import
{
Trans
}
from
'
@lingui/macro
'
import
React
from
'
react
'
import
{
darken
}
from
'
polished
'
import
React
,
{
ReactNode
}
from
'
react
'
import
styled
from
'
styled-components/macro
'
const
ToggleElement
=
styled
.
span
<
{
isActive
?:
boolean
;
isOnSwitch
?:
boolean
}
>
`
padding: 0.25rem 0.5rem;
border-radius: 14px;
background:
${({
theme
,
isActive
,
isOnSwitch
})
=>
(
isActive
?
(
isOnSwitch
?
theme
.
primary1
:
theme
.
text4
)
:
'
none
'
)}
;
color:
${({
theme
,
isActive
,
isOnSwitch
})
=>
(
isActive
?
(
isOnSwitch
?
theme
.
white
:
theme
.
text2
)
:
theme
.
text3
)}
;
font-size: 1rem;
font-weight: 400;
padding: 0.35rem 0.6rem;
border-radius: 12px;
background:
${({
theme
,
isActive
,
isOnSwitch
})
=>
(
isActive
?
(
isOnSwitch
?
theme
.
primary1
:
theme
.
text5
)
:
'
none
'
)}
;
color:
${({
theme
,
isActive
,
isOnSwitch
})
=>
(
isActive
?
(
isOnSwitch
?
theme
.
white
:
theme
.
text2
)
:
theme
.
text2
)}
;
padding: 0.25rem 0.6rem;
border-radius: 9px;
background:
${({
theme
,
isActive
,
isOnSwitch
})
=>
(
isActive
?
(
isOnSwitch
?
theme
.
primary1
:
theme
.
bg4
)
:
'
none
'
)}
;
color:
${({
theme
,
isActive
})
=>
(
isActive
?
theme
.
white
:
theme
.
text2
)}
;
font-size: 1rem;
font-weight:
${({
isOnSwitch
})
=>
(
isOnSwitch
?
'
500
'
:
'
400
'
)}
;
:hover {
user-select:
${({
isOnSwitch
})
=>
(
isOnSwitch
?
'
none
'
:
'
initial
'
)}
;
background:
${({
theme
,
isActive
,
isOnSwitch
})
=>
isActive
?
(
isOnSwitch
?
theme
.
primary1
:
theme
.
text5
)
:
'
none
'
}
;
color:
${({
theme
,
isActive
,
isOnSwitch
})
=>
(
isActive
?
(
isOnSwitch
?
theme
.
white
:
theme
.
text3
)
:
theme
.
text3
)}
;
isActive
?
(
isOnSwitch
?
darken
(
0.05
,
theme
.
primary1
)
:
darken
(
0.05
,
theme
.
bg4
)
)
:
'
none
'
}
;
color:
${({
theme
,
isActive
,
isOnSwitch
})
=>
(
isActive
?
(
isOnSwitch
?
theme
.
white
:
theme
.
white
)
:
theme
.
text3
)}
;
}
`
const
StyledToggle
=
styled
.
button
<
{
isActive
?:
boolean
;
activeElement
?:
boolean
}
>
`
border-radius: 12px;
border: none;
background:
${({
theme
})
=>
theme
.
bg3
}
;
border: 2px solid;
border-color:
${({
theme
,
isActive
})
=>
(
isActive
?
theme
.
primary1
:
theme
.
bg3
)}
;
background:
${({
theme
})
=>
theme
.
bg1
}
;
display: flex;
width: fit-content;
cursor: pointer;
outline: none;
padding:
0
;
padding:
2px
;
`
export
interface
ToggleProps
{
id
?:
string
isActive
:
boolean
toggle
:
()
=>
void
checked
?:
ReactNode
unchecked
?:
ReactNode
}
export
default
function
Toggle
({
id
,
isActive
,
toggle
}:
ToggleProps
)
{
export
default
function
Toggle
({
id
,
isActive
,
toggle
,
checked
=
<
Trans
>
On
</
Trans
>,
unchecked
=
<
Trans
>
Off
</
Trans
>,
}:
ToggleProps
)
{
return
(
<
StyledToggle
id=
{
id
}
isActive=
{
isActive
}
onClick=
{
toggle
}
>
<
ToggleElement
isActive=
{
isActive
}
isOnSwitch=
{
true
}
>
<
Trans
>
On
</
Trans
>
{
checked
}
</
ToggleElement
>
<
ToggleElement
isActive=
{
!
isActive
}
isOnSwitch=
{
false
}
>
<
Trans
>
Off
</
Trans
>
{
unchecked
}
</
ToggleElement
>
</
StyledToggle
>
)
...
...
src/pages/Pool/index.tsx
View file @
31da6cdb
...
...
@@ -204,11 +204,13 @@ export default function Pool() {
{
closedPositions
.
length
>
0
?
(
<
ShowInactiveToggle
>
<
TYPE
.
darkGray
>
<
Trans
>
Hide c
losed positions
</
Trans
>
<
Trans
>
C
losed positions
</
Trans
>
</
TYPE
.
darkGray
>
<
Toggle
isActive=
{
userHideClosedPositions
}
isActive=
{
!
userHideClosedPositions
}
toggle=
{
()
=>
setUserHideClosedPositions
(
!
userHideClosedPositions
)
}
checked=
{
<
Trans
>
Show
</
Trans
>
}
unchecked=
{
<
Trans
>
Hide
</
Trans
>
}
/>
</
ShowInactiveToggle
>
)
:
null
}
...
...
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