Skip to content

Commit fbbad35

Browse files
committed
Add donation links and about section to the donations panel
1 parent 6e21cad commit fbbad35

3 files changed

Lines changed: 92 additions & 6 deletions

File tree

‎packages/ui/src/components/editor/panel/Donations/Donations.module.scss‎

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,56 @@
55
gap: 8px;
66
}
77

8+
.about {
9+
padding: 3px 12px 0 12px;
10+
font-size: 12px;
11+
color: var(--cwc-text-color-dimmed);
12+
}
13+
14+
.links {
15+
display: flex;
16+
flex-direction: column;
17+
padding: 0 12px;
18+
19+
&__content {
20+
display: flex;
21+
flex-direction: column;
22+
gap: 6px;
23+
}
24+
25+
&__item {
26+
display: flex;
27+
flex-direction: column;
28+
gap: 2px;
29+
cursor: default;
30+
31+
&:hover {
32+
text-decoration: none;
33+
}
34+
35+
& > strong {
36+
align-self: flex-start;
37+
cursor: pointer;
38+
39+
&:hover {
40+
text-decoration: underline;
41+
}
42+
}
43+
44+
&__url {
45+
font-size: 11px;
46+
color: var(--cwc-text-color-dimmed);
47+
white-space: nowrap;
48+
text-overflow: ellipsis;
49+
overflow: hidden;
50+
}
51+
}
52+
}
53+
854
.wallets {
955
display: flex;
1056
flex-direction: column;
11-
margin: 0 12px;
57+
padding: 0 12px;
1258

1359
&__wallet {
1460
display: flex;
@@ -19,7 +65,7 @@
1965
&__right {
2066
display: flex;
2167
align-items: center;
22-
gap: 2px;
68+
gap: 4px;
2369
min-width: 0;
2470
flex: 1;
2571
justify-content: flex-end;

‎packages/ui/src/components/editor/panel/Donations/Donations.tsx‎

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export type DonationsProps = {
8585
export const Donations: React.FC<DonationsProps> = (props) => {
8686
const observer_target = useRef<HTMLDivElement>(null)
8787
const [is_wallets_collapsed, set_wallets_collapsed] = useState(true)
88+
const [is_links_collapsed, set_links_collapsed] = useState(true)
8889

8990
useEffect(() => {
9091
if (!observer_target.current) return
@@ -104,6 +105,11 @@ export const Donations: React.FC<DonationsProps> = (props) => {
104105
return () => observer.unobserve(target)
105106
}, [props.on_fetch_next_page])
106107

108+
const links = [
109+
{ label: 'Buy Me A Coffee', url: 'https://buymeacoffee.com/robertpiosik' },
110+
{ label: 'PayPal', url: 'https://www.paypal.com/paypalme/robertpiosik' }
111+
]
112+
107113
const wallets = [
108114
{
109115
name: 'Bitcoin',
@@ -120,14 +126,48 @@ export const Donations: React.FC<DonationsProps> = (props) => {
120126
}
121127
]
122128

129+
const format_url_for_display = (url: string) => {
130+
return url.replace(/^(https?:\/\/)/, '').replace(/^www\./, '')
131+
}
132+
123133
return (
124134
<>
125135
<Scrollable>
126136
<div className={styles.container}>
137+
<div className={styles.about}>
138+
Hi there! By donating to Code Web Chat, you’re supporting my mission
139+
to independently build the world’s best free and open-source AI coding tools.
140+
<br />
141+
Thank you for your support!
142+
</div>
143+
<div className={styles.links}>
144+
<Fieldset
145+
is_collapsed={is_links_collapsed}
146+
label="Links"
147+
on_toggle_collapsed={() =>
148+
set_links_collapsed(!is_links_collapsed)
149+
}
150+
>
151+
<div className={styles.links__content}>
152+
{links.map((link) => (
153+
<a
154+
href={link.url}
155+
className={styles.links__item}
156+
key={link.url}
157+
>
158+
<strong>{link.label}</strong>
159+
<span className={styles.links__item__url}>
160+
{format_url_for_display(link.url)}
161+
</span>
162+
</a>
163+
))}
164+
</div>
165+
</Fieldset>
166+
</div>
127167
<div className={styles.wallets}>
128168
<Fieldset
129169
is_collapsed={is_wallets_collapsed}
130-
label="Crypto wallets"
170+
label="Wallets"
131171
on_toggle_collapsed={() =>
132172
set_wallets_collapsed(!is_wallets_collapsed)
133173
}
@@ -143,7 +183,7 @@ export const Donations: React.FC<DonationsProps> = (props) => {
143183
is_small
144184
on_click={() => props.on_show_qr_code(wallet)}
145185
>
146-
Show QR
186+
Scan QR
147187
</Button>
148188
</div>
149189
</div>

‎packages/vscode/src/views/panel/frontend/Panel.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { ResponseHistoryItem } from '@shared/types/response-history-item'
2222
import { Layout } from './components/Layout/Layout'
2323
import { ResponsePreviewFooter as UiResponsePreviewFooter } from '@ui/components/editor/panel/ResponsePreviewFooter'
2424
import { EditPresetFormFooter } from './components/edit-preset-form/EditPresetFormFooter'
25-
import { Donations } from '@ui/components/editor/panel/Donations/Donations'
25+
import { Donations as UiDonations } from '@ui/components/editor/panel/Donations/Donations'
2626
import { use_latest_donations } from './hooks/latest-donations'
2727
import { DonationsFooter } from './components/donations/DonationsFooter'
2828

@@ -398,7 +398,7 @@ export const Panel = () => {
398398
/>
399399
}
400400
>
401-
<Donations
401+
<UiDonations
402402
donations={donations_state.donations}
403403
is_fetching={donations_state.is_fetching}
404404
is_revalidating={donations_state.is_revalidating}

0 commit comments

Comments
 (0)