Skip to content

Commit 282e65b

Browse files
authored
Widget improvements (#16)
* [widget-improvements] Update widget * [widget-improvements] Add custom styles property * [widget-improvements] Add custom styles * [widget-improvements] Add custom styles * [widget-improvements] Add custom styles * [widget-improvements] Add custom styles * [widget-improvements] Add referrer config * [widget-improvements] Add jest timeout comment
1 parent 0ff1169 commit 282e65b

File tree

41 files changed

+3379
-248
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+3379
-248
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (C) 2021 StakeWise Labs
1+
Copyright (C) 2022 StakeWise Labs
22
33

44

packages/stakewise-dev/LICENSE

Lines changed: 665 additions & 0 deletions
Large diffs are not rendered by default.

packages/stakewise-dev/scss/text.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
line-height: 14rem;
44
}
55

6+
.text-16 {
7+
font-size: 16rem;
8+
line-height: 20rem;
9+
}
10+
611
.text-18 {
712
font-size: 18rem;
813
line-height: 20rem;

packages/stakewise-dev/src/App/App.scss

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
.container {
2-
height: 100vh;
3-
}
4-
51
.dark {
62
color: $color-rush;
73
background-color: $color-titanic;
@@ -29,6 +25,10 @@
2925
.monaco-editor {
3026
padding-top: 4px;
3127

28+
.monaco-hover {
29+
display: none !important;
30+
}
31+
3232
.margin,
3333
.lines-content {
3434
background-color: transparent !important;
@@ -45,11 +45,19 @@
4545
.container {
4646
min-height: 940px;
4747
}
48+
49+
.textContainer {
50+
min-height: calc(100vh - 106px);
51+
}
4852
}
4953

5054
@media (max-width: 639px) {
5155

5256
.container {
5357
min-height: 420px;
5458
}
59+
60+
.textContainer {
61+
min-height: calc(100vh - 170px);
62+
}
5563
}

packages/stakewise-dev/src/App/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ const App = () => {
2424

2525
return (
2626
<div
27-
className={cx(s.container, 'flex flex-col items-center justify-center')}
27+
className={s.container}
2828
>
29-
<div className="flex-1 w-full flex flex-col items-center justify-center">
29+
<div className={cx(s.textContainer, 'w-full flex flex-col items-center justify-center py-24')}>
3030
<Content
3131
className="mw-618 w-full px-16"
3232
form={form}

packages/stakewise-dev/src/App/components/Button/Button.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.button {
1+
.mw200 {
22
min-width: 200rem;
33
}
44

packages/stakewise-dev/src/App/components/Button/Button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const Button: React.FC<ButtonProps> = (props) => {
1717

1818
return (
1919
<button
20-
className={cx(className, s.button, s[color], 'cursor-pointer radius-8 px-20 py-24', {
20+
className={cx(className, s.mw200, s[color], 'cursor-pointer radius-8 px-20 py-24', {
2121
'opacity-48': disabled,
2222
'cursor-disabled': disabled,
2323
})}

packages/stakewise-dev/src/App/components/Config/Config.tsx

Lines changed: 78 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import React from 'react'
2-
import cx from 'classnames'
32
import { Form, useFieldState } from 'formular'
43

54
import { options, useDevice } from '../../util'
65

76
import Switch from '../Switch/Switch'
87
import DropdownMenu from '../Select/Select'
8+
import Input from '../Input/Input'
9+
import { useMemo } from 'preact/compat'
910

1011

1112
type ConfigProps = {
@@ -22,42 +23,86 @@ const Config: React.FC<ConfigProps> = (props) => {
2223
const { value: overlay } = useFieldState(form.fields.overlay)
2324
const { value: network } = useFieldState(form.fields.network)
2425
const { value: currency } = useFieldState(form.fields.currency)
26+
const { value: withReferrer } = useFieldState(form.fields.withReferrer)
27+
const { value: customStyles } = useFieldState(form.fields.customStyles)
28+
29+
const isReferrerEnabled = useMemo(() => {
30+
if (typeof window !== 'undefined') {
31+
return window.location?.search?.includes('withReferrer')
32+
}
33+
34+
return false
35+
}, [])
2536

2637
return (
27-
<div className={cx(className, isMobile ? '' : 'flex items-start')}>
28-
<div className="flex-1">
29-
<Switch
30-
label="Dark theme"
31-
labelClassName="ml-20"
32-
checked={theme === 'dark'}
33-
onChange={() => form.fields.theme.set(theme === 'dark' ? 'light' : 'dark')}
34-
/>
35-
<Switch
36-
className="mt-20"
37-
label="Blur overlay"
38-
labelClassName="ml-20"
39-
checked={overlay === 'blur'}
40-
onChange={() => form.fields.overlay.set(overlay === 'dark' ? 'blur' : 'dark')}
41-
/>
42-
</div>
43-
<div className={isMobile ? 'mt-20' : 'ml-20 flex-1'}>
44-
<div className="flex items-center">
45-
<DropdownMenu
46-
items={options.currency}
47-
onChange={(value) => form.fields.currency.set(value)}
48-
>
49-
<div>{currency}</div>
50-
</DropdownMenu>
51-
<label className="ml-20" htmlFor="headlessui-menu-button-5">Currency</label>
38+
<div className={className}>
39+
<div className={isMobile ? '' : 'flex items-start'}>
40+
<div className="flex-1">
41+
<Switch
42+
label="Dark theme"
43+
labelClassName="ml-20"
44+
checked={theme === 'dark'}
45+
onChange={() => form.fields.theme.set(theme === 'dark' ? 'light' : 'dark')}
46+
/>
47+
<Switch
48+
className="mt-20"
49+
label="Blur overlay"
50+
labelClassName="ml-20"
51+
checked={overlay === 'blur'}
52+
onChange={() => form.fields.overlay.set(overlay === 'dark' ? 'blur' : 'dark')}
53+
/>
54+
{
55+
!isMobile && (
56+
<Switch
57+
className="mt-20"
58+
label="Custom styles"
59+
labelClassName="ml-20"
60+
checked={customStyles}
61+
onChange={() => form.fields.customStyles.set(!customStyles)}
62+
/>
63+
)
64+
}
65+
</div>
66+
<div className={isMobile ? 'mt-20' : 'ml-20 flex-1'}>
67+
<div className="flex items-center">
68+
<DropdownMenu
69+
items={options.currency}
70+
onChange={(value) => form.fields.currency.set(value)}
71+
>
72+
<div>{currency}</div>
73+
</DropdownMenu>
74+
<label className="ml-20" htmlFor="headlessui-menu-button-5">Currency</label>
75+
</div>
76+
<Switch
77+
className="mt-20"
78+
label="Testnet (for testing only)"
79+
labelClassName="ml-20"
80+
checked={network === 'goerli'}
81+
onChange={() => form.fields.network.set(network === 'goerli' ? 'mainnet' : 'goerli')}
82+
/>
83+
{
84+
isReferrerEnabled && (
85+
<Switch
86+
className="mt-20"
87+
label="With referrer"
88+
labelClassName="ml-20"
89+
checked={withReferrer}
90+
onChange={() => form.fields.withReferrer.set(!withReferrer)}
91+
/>
92+
)
93+
}
5294
</div>
53-
<Switch
54-
className="mt-20"
55-
label="Testnet (for testing only)"
56-
labelClassName="ml-20"
57-
checked={network === 'goerli'}
58-
onChange={() => form.fields.network.set(network === 'goerli' ? 'mainnet' : 'goerli')}
59-
/>
6095
</div>
96+
{
97+
withReferrer && (
98+
<Input
99+
className="mt-20"
100+
label="Referrer address"
101+
field={form.fields.referrer}
102+
style={theme}
103+
/>
104+
)
105+
}
61106
</div>
62107
)
63108
}

0 commit comments

Comments
 (0)