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
20adf82c
Commit
20adf82c
authored
Feb 16, 2021
by
ianlapham
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add dynamic toggle
parent
0ec6cad6
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
99 additions
and
10 deletions
+99
-10
index.tsx
src/components/Card/index.tsx
+2
-2
index.tsx
src/components/Header/index.tsx
+3
-0
MultiToggle.stories.tsx
src/components/Toggle/MultiToggle.stories.tsx
+35
-0
MultiToggle.tsx
src/components/Toggle/MultiToggle.tsx
+53
-0
AppBody.tsx
src/pages/AppBody.tsx
+1
-1
index.tsx
src/theme/index.tsx
+3
-6
styled.d.ts
src/theme/styled.d.ts
+1
-0
tsconfig.json
tsconfig.json
+1
-1
No files found.
src/components/Card/index.tsx
View file @
20adf82c
...
@@ -49,9 +49,9 @@ const BlueCardStyled = styled(Card)`
...
@@ -49,9 +49,9 @@ const BlueCardStyled = styled(Card)`
width: fit-content;
width: fit-content;
`
`
export
const
BlueCard
=
({
children
,
...
rest
}:
CardProps
)
=>
{
export
const
BlueCard
=
({
children
}:
CardProps
)
=>
{
return
(
return
(
<
BlueCardStyled
{
...
rest
}
>
<
BlueCardStyled
>
<
Text
fontWeight=
{
500
}
color=
"#2172E5"
>
<
Text
fontWeight=
{
500
}
color=
"#2172E5"
>
{
children
}
{
children
}
</
Text
>
</
Text
>
...
...
src/components/Header/index.tsx
View file @
20adf82c
...
@@ -44,6 +44,9 @@ const HeaderFrame = styled.div`
...
@@ -44,6 +44,9 @@ const HeaderFrame = styled.div`
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
padding: 1rem;
padding: 1rem;
z-index: 2;
z-index: 2;
background-color:
${({
theme
})
=>
theme
.
bg0
}
;
${({
theme
})
=>
theme
.
mediaWidth
.
upToMedium
`
${({
theme
})
=>
theme
.
mediaWidth
.
upToMedium
`
grid-template-columns: 1fr;
grid-template-columns: 1fr;
padding: 0 1rem;
padding: 0 1rem;
...
...
src/components/Toggle/MultiToggle.stories.tsx
0 → 100644
View file @
20adf82c
import
{
Story
}
from
'
@storybook/react/types-6-0
'
import
styled
from
'
styled-components
'
import
React
,
{
useState
}
from
'
react
'
import
MultiToggle
from
'
./MultiToggle
'
const
wrapperCss
=
styled
.
main
`
font-size: 2em;
margin: 3em;
max-width: 300px;
`
export
default
{
title
:
'
Toggles
'
,
argTypes
:
{
width
:
{
control
:
{
type
:
'
string
'
}
},
},
decorators
:
[
(
Component
:
Story
)
=>
(
<
div
css=
{
wrapperCss
}
>
<
Component
/>
</
div
>
),
],
}
export
const
MultiToggleExample
=
()
=>
{
const
[
active
,
setActive
]
=
useState
(
0
)
function
doSomethingWithIndex
(
index
:
number
)
{
// here's where youd update state based on index choice
// switch(index){} ...
setActive
(
index
)
}
return
<
MultiToggle
toggle=
{
doSomethingWithIndex
}
activeIndex=
{
active
}
options=
{
[
'
option1
'
,
'
option2
'
,
'
option3
'
]
}
/>
}
src/components/Toggle/MultiToggle.tsx
0 → 100644
View file @
20adf82c
import
React
from
'
react
'
import
styled
from
'
styled-components
'
const
ToggleElement
=
styled
.
span
<
{
isActive
?:
boolean
;
isOnSwitch
?:
boolean
}
>
`
width: 100%;
padding: 0.25rem 0.5rem;
border-radius: 8px;
background:
${({
theme
,
isActive
})
=>
(
isActive
?
theme
.
bg2
:
'
none
'
)}
;
color:
${({
theme
,
isActive
})
=>
(
isActive
?
theme
.
text1
:
theme
.
text3
)}
;
font-size: 1rem;
font-weight: 400;
padding: 0.35rem 0.6rem;
:hover {
user-select: initial;
color:
${({
theme
,
isActive
})
=>
(
isActive
?
theme
.
text2
:
theme
.
text3
)}
;
}
`
const
StyledToggle
=
styled
.
button
<
{
isActive
?:
boolean
;
activeElement
?:
boolean
;
width
?:
string
}
>
`
display: flex;
width:
${({
width
})
=>
width
??
'
100%
'
}
padding
:
2
px
;
background
:
$
{({
theme
})
=>
theme
.
bg0
};
border
-
radius
:
8
px
;
border
:
$
{({
theme
})
=>
'
2px solid
'
+
theme
.
bg2
};
cursor
:
pointer
;
outline
:
none
;
`
export interface ToggleProps {
options: string[]
activeIndex: number
toggle: (index: number) => void
id?: string
width?: string
}
export default function MultiToggle({ id, options, activeIndex, toggle, width }: ToggleProps) {
return (
<StyledToggle id={id} isActive={activeIndex === 0} width={width}>
{options.map((option, index) => (
<ToggleElement
key={id + '-' + index}
isActive={index === activeIndex}
isOnSwitch={true}
onClick={() => toggle(index)}
>
{option}
</ToggleElement>
))}
</StyledToggle>
)
}
src/pages/AppBody.tsx
View file @
20adf82c
...
@@ -5,7 +5,7 @@ export const BodyWrapper = styled.div`
...
@@ -5,7 +5,7 @@ export const BodyWrapper = styled.div`
position: relative;
position: relative;
max-width: 420px;
max-width: 420px;
width: 100%;
width: 100%;
background:
${({
theme
})
=>
theme
.
bg
1
}
;
background:
${({
theme
})
=>
theme
.
bg
0
}
;
box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.01), 0px 4px 8px rgba(0, 0, 0, 0.04), 0px 16px 24px rgba(0, 0, 0, 0.04),
box-shadow: 0px 0px 1px rgba(0, 0, 0, 0.01), 0px 4px 8px rgba(0, 0, 0, 0.04), 0px 16px 24px rgba(0, 0, 0, 0.04),
0px 24px 32px rgba(0, 0, 0, 0.01);
0px 24px 32px rgba(0, 0, 0, 0.01);
border-radius: 30px;
border-radius: 30px;
...
...
src/theme/index.tsx
View file @
20adf82c
...
@@ -48,6 +48,7 @@ export function colors(darkMode: boolean): Colors {
...
@@ -48,6 +48,7 @@ export function colors(darkMode: boolean): Colors {
text5
:
darkMode
?
'
#2C2F36
'
:
'
#EDEEF2
'
,
text5
:
darkMode
?
'
#2C2F36
'
:
'
#EDEEF2
'
,
// backgrounds / greys
// backgrounds / greys
bg0
:
darkMode
?
'
#191B1F
'
:
'
#FFFFFF
'
,
bg1
:
darkMode
?
'
#212429
'
:
'
#FFFFFF
'
,
bg1
:
darkMode
?
'
#212429
'
:
'
#FFFFFF
'
,
bg2
:
darkMode
?
'
#2C2F36
'
:
'
#F7F8FA
'
,
bg2
:
darkMode
?
'
#2C2F36
'
:
'
#F7F8FA
'
,
bg3
:
darkMode
?
'
#40444F
'
:
'
#EDEEF2
'
,
bg3
:
darkMode
?
'
#40444F
'
:
'
#EDEEF2
'
,
...
@@ -219,17 +220,13 @@ html {
...
@@ -219,17 +220,13 @@ html {
export
const
ThemedGlobalStyle
=
createGlobalStyle
`
export
const
ThemedGlobalStyle
=
createGlobalStyle
`
html {
html {
color:
${({
theme
})
=>
theme
.
text1
}
;
color:
${({
theme
})
=>
theme
.
text1
}
;
background-color:
${({
theme
})
=>
theme
.
bg
2
}
;
background-color:
${({
theme
})
=>
theme
.
bg
1
}
;
}
}
body {
body {
min-height: 100vh;
min-height: 100vh;
background-position: 0 -30vh;
background-position: 0 -30vh;
background-repeat: no-repeat;
background-repeat: no-repeat;
background-image:
${({
theme
})
=>
`radial-gradient(50% 50% at 50% 50%,
${
transparentize
(
0.9
,
theme
.
primary1
)}
0%,
${
transparentize
(
1
,
theme
.
bg1
)}
100%)`
}
;
}
}
`
`
src/theme/styled.d.ts
View file @
20adf82c
...
@@ -14,6 +14,7 @@ export interface Colors {
...
@@ -14,6 +14,7 @@ export interface Colors {
text5
:
Color
text5
:
Color
// backgrounds / greys
// backgrounds / greys
bg0
:
Color
bg1
:
Color
bg1
:
Color
bg2
:
Color
bg2
:
Color
bg3
:
Color
bg3
:
Color
...
...
tsconfig.json
View file @
20adf82c
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
"strict"
:
true
,
"strict"
:
true
,
"alwaysStrict"
:
true
,
"alwaysStrict"
:
true
,
"strictNullChecks"
:
true
,
"strictNullChecks"
:
true
,
"noUnusedLocals"
:
tru
e
,
"noUnusedLocals"
:
fals
e
,
"noFallthroughCasesInSwitch"
:
true
,
"noFallthroughCasesInSwitch"
:
true
,
"noImplicitAny"
:
true
,
"noImplicitAny"
:
true
,
"noImplicitThis"
:
true
,
"noImplicitThis"
:
true
,
...
...
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