Skip to content

Commit 13288ae

Browse files
committed
Move Discord and donate links to the footer and convert the apply button into a compactable action button
- 'apply from' should use compactable action button with 'check' icon. 'history' 'undo' 'apply from' should all be on the right side. on the left place 'hi' - rename 'apply from...' to 'apply...' - 'undo' should compact first, then history, 'apply' be last one. - in footer, in bottom left corner duplicate 'discord' aĻnd 'buy me coffee' - but don't use lables (use `packages/ui/src/components/editor/common/IconButton/IconButton.tsx`) - in footer, for 'discord' and 'donate', don't use any pre-made components, but local styles. make these buttons follow brand color: e.g. purple/yellow bg. - discord icon in footer is too big - the discord, donate buttons should have 'alt' styles: dimmed border instead of purple/yellow background, icon dimmed. Put it in alt mode when cursor is not in the Footer, with 2s delay. once cursor is placed back in footer, restore the non alt styles. - use this slow transition [Fragment] only on out phase (color->dimmed) ├── apps │ └── editor │ └── src │ └── views │ └── prompt │ └── frontend │ ├── Home │ │ └── Home.tsx │ ├── Main │ │ └── MainView │ │ └── components │ │ └── Header │ │ ├── Header.module.scss │ │ └── Header.tsx │ ├── Prompt.tsx │ ├── components │ │ └── Layout │ │ ├── Footer │ │ │ ├── Footer.module.scss │ │ │ └── Footer.tsx │ │ ├── Layout.module.scss │ │ └── Layout.tsx │ └── i18n │ └── translations │ └── footer.ts └── packages └── ui └── src ├── components │ └── editor │ ├── common │ │ └── IconButton │ │ ├── IconButton.module.scss │ │ └── IconButton.tsx │ └── prompt-view │ └── CompactableActionButton │ ├── CompactableActionButton.module.scss │ └── CompactableActionButton.tsx └── styles └── foundation └── _colors.scss
1 parent 45f1324 commit 13288ae

7 files changed

Lines changed: 169 additions & 61 deletions

File tree

‎apps/editor/src/views/prompt/frontend/Home/Home.tsx‎

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@ import { post_message } from '../utils/post-message'
1010
import { BackendMessage } from '@/views/prompt/types/messages'
1111
import { Spacer as UiSpacer } from '@ui/components/editor/prompt-view/Spacer'
1212
import { Translation, use_translation } from '../i18n/use-translation'
13-
import { CompactableActionButton } from '@ui/components/editor/prompt-view/CompactableActionButton'
1413
import { Tasks as UiTasks } from '@ui/components/editor/prompt-view/Tasks'
1514
import { use_tasks } from './hooks/use-tasks'
1615
import { use_has_scrolled_past_target_button } from './hooks/use-has-scrolled-past-mode-button'
1716
import { use_keyboard_shortcuts } from './hooks/use-keyboard-shortcuts'
18-
import { use_compacting } from '@shared/hooks'
1917
import {
2018
ApiPromptType,
2119
WebPromptType,
@@ -73,15 +71,8 @@ export const Home: React.FC<Props> = (props) => {
7371
? active_workspace_root
7472
: roots[0] || active_workspace_root || ''
7573

76-
const { container_ref, compact_step } = use_compacting({
77-
is_disabled: is_landscape
78-
})
79-
8074
const header_targets_ref = useRef<HTMLDivElement>(null)
8175

82-
const discord_label = 'Discord'
83-
const coffee_label = t('header.buy-me-a-coffee')
84-
8576
useEffect(() => {
8677
const handle_message = (event: MessageEvent<BackendMessage>) => {
8778
const message = event.data
@@ -142,13 +133,12 @@ export const Home: React.FC<Props> = (props) => {
142133
className={cn(styles.header__normal, {
143134
[styles['header__normal--hidden']]: has_scrolled_past_target_button
144135
})}
145-
ref={container_ref}
146136
>
147137
<div className={styles.header__icon}>
148138
<span className="codicon codicon-home" />
149139
</div>
150140
<div className={styles.header__links}>
151-
<CompactableActionButton
141+
{/* <CompactableActionButton
152142
label={discord_label}
153143
href="https://discord.gg/KJySXsrSX5"
154144
icon="DISCORD"
@@ -159,7 +149,7 @@ export const Home: React.FC<Props> = (props) => {
159149
on_click={props.on_donate_click}
160150
codicon="coffee"
161151
is_compact={is_landscape || compact_step >= 2}
162-
/>
152+
/> */}
163153
{is_landscape && (
164154
<div
165155
style={{

‎apps/editor/src/views/prompt/frontend/Prompt.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,10 @@ export const Prompt = () => {
282282
[styles['slot--hidden']]: is_main_slot_hidden
283283
})}
284284
>
285-
<Layout on_history_click={handle_history_click}>
285+
<Layout
286+
on_history_click={handle_history_click}
287+
on_donate_click={() => set_viewing_donations(true)}
288+
>
286289
<div
287290
className={cn(styles.content, {
288291
[styles['content--hidden']]: active_view !== 'main'

‎apps/editor/src/views/prompt/frontend/components/Layout/Footer/Footer.module.scss‎

Lines changed: 68 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,77 @@
1313

1414
&__left {
1515
display: flex;
16+
align-items: center;
17+
gap: 4px;
1618
}
17-
}
1819

19-
.apply-button {
20-
height: 24px;
21-
color: inherit;
22-
border-radius: 4px;
23-
align-items: center;
24-
padding: 0 6px;
25-
font-size: 12px;
26-
white-space: nowrap;
27-
28-
&:hover:not(:disabled) {
29-
background-color: var(--vscode-toolbar-hoverBackground);
20+
&__discord-button,
21+
&__donate-button {
22+
--size: 24px;
23+
box-sizing: border-box;
24+
display: flex;
25+
align-items: center;
26+
justify-content: center;
27+
width: var(--size);
28+
height: var(--size);
29+
border: 1px solid transparent;
30+
border-radius: 4px;
31+
cursor: pointer;
32+
text-decoration: none;
33+
transition:
34+
background-color 0.2s ease,
35+
color 0.2s ease;
36+
37+
&:focus {
38+
outline: none;
39+
}
40+
41+
&:hover {
42+
filter: brightness(1.08);
43+
text-decoration: none;
44+
}
3045
}
3146

32-
&:disabled {
33-
opacity: var(--disabled-opacity);
34-
cursor: default;
47+
&__discord-button {
48+
background-color: #5865f2;
49+
color: #ffffff;
50+
51+
> svg {
52+
width: 16px;
53+
fill: currentColor;
54+
}
55+
56+
&--alt {
57+
background-color: transparent;
58+
border-color: var(--cwc-border-color-dimmed);
59+
color: var(--cwc-text-color-dimmed);
60+
transition:
61+
background-color 0.7s ease,
62+
border-color 0.7s ease,
63+
color 0.7s ease;
64+
}
65+
}
66+
67+
&__donate-button {
68+
background-color: #ffdd00;
69+
color: #000000;
70+
71+
&:hover {
72+
filter: brightness(0.95);
73+
}
74+
75+
&--alt {
76+
background-color: transparent;
77+
border-color: var(--cwc-border-color-dimmed);
78+
color: var(--cwc-text-color-dimmed);
79+
transition:
80+
background-color 0.7s ease,
81+
border-color 0.7s ease,
82+
color 0.7s ease;
83+
}
84+
}
85+
86+
&__right {
87+
display: flex;
3588
}
3689
}

‎apps/editor/src/views/prompt/frontend/components/Layout/Footer/Footer.tsx‎

Lines changed: 67 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1-
import { useContext } from 'react'
1+
import { useContext, useEffect, useRef, useState } from 'react'
22
import styles from './Footer.module.scss'
33
import { use_compacting } from '@shared/hooks'
44
import { LayoutContext } from '../../../contexts/LayoutContext'
55
import { use_translation } from '../../../i18n/use-translation'
6+
import cn from 'classnames'
67
import { CompactableActionButton } from '@ui/components/editor/prompt-view/CompactableActionButton'
8+
import { Icon as UiIcon } from '@ui/components/editor/common/Icon'
9+
10+
const DIMMED_ICONS_TIMEOUT = 10000
711

812
type Props = {
913
on_history_click?: () => void
14+
on_donate_click?: () => void
1015
}
1116

1217
export const Footer: React.FC<Props> = (props) => {
@@ -16,17 +21,70 @@ export const Footer: React.FC<Props> = (props) => {
1621

1722
const history_label = t('footer.action.history')
1823
const undo_label = t('footer.action.undo')
19-
const apply_label = t('footer.action.apply-from')
24+
const apply_label = t('footer.action.apply')
2025

2126
const { container_ref, compact_step } = use_compacting()
27+
const [is_alt, set_is_alt] = useState(true)
28+
const leave_timeout_ref = useRef<ReturnType<typeof setTimeout> | null>(null)
29+
30+
const handle_mouse_enter = () => {
31+
if (leave_timeout_ref.current) {
32+
clearTimeout(leave_timeout_ref.current)
33+
leave_timeout_ref.current = null
34+
}
35+
set_is_alt(false)
36+
}
37+
38+
const handle_mouse_leave = () => {
39+
leave_timeout_ref.current = setTimeout(() => {
40+
set_is_alt(true)
41+
}, DIMMED_ICONS_TIMEOUT)
42+
}
43+
44+
useEffect(() => {
45+
return () => {
46+
if (leave_timeout_ref.current) {
47+
clearTimeout(leave_timeout_ref.current)
48+
}
49+
}
50+
}, [])
2251

2352
const handle_apply_click = () => {
2453
on_apply_click()
2554
}
2655

2756
return (
28-
<div className={styles.footer} ref={container_ref}>
57+
<div
58+
className={styles.footer}
59+
ref={container_ref}
60+
onMouseEnter={handle_mouse_enter}
61+
onMouseLeave={handle_mouse_leave}
62+
>
2963
<div className={styles.footer__left}>
64+
<a
65+
href="https://discord.gg/KJySXsrSX5"
66+
className={cn(styles['footer__discord-button'], {
67+
[styles['footer__discord-button--alt']]: is_alt
68+
})}
69+
title="Discord"
70+
target="_blank"
71+
rel="noopener noreferrer"
72+
>
73+
<UiIcon variant="DISCORD" />
74+
</a>
75+
<button
76+
type="button"
77+
className={cn(styles['footer__donate-button'], {
78+
[styles['footer__donate-button--alt']]: is_alt
79+
})}
80+
onClick={props.on_donate_click}
81+
title={t('header.buy-me-a-coffee')}
82+
>
83+
<span className={cn('codicon', 'codicon-coffee')} />
84+
</button>
85+
</div>
86+
87+
<div className={styles.footer__right}>
3088
<CompactableActionButton
3189
is_compact={compact_step >= 2}
3290
on_click={props.on_history_click}
@@ -42,16 +100,13 @@ export const Footer: React.FC<Props> = (props) => {
42100
codicon="discard"
43101
label={undo_label}
44102
/>
45-
</div>
46-
47-
<div>
48-
<button
49-
className={styles['apply-button']}
50-
onClick={handle_apply_click}
103+
<CompactableActionButton
104+
is_compact={compact_step >= 3}
105+
on_click={handle_apply_click}
51106
title={t('footer.apply-title')}
52-
>
53-
{apply_label}
54-
</button>
107+
codicon="check-all"
108+
label={apply_label}
109+
/>
55110
</div>
56111
</div>
57112
)

‎apps/editor/src/views/prompt/frontend/components/Layout/Layout.tsx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@ import { Footer } from './Footer'
44
type Props = {
55
children: React.ReactNode
66
on_history_click?: () => void
7+
on_donate_click?: () => void
78
}
89

910
export const Layout: React.FC<Props> = (props) => {
1011
return (
1112
<div className={styles.container}>
1213
<div className={styles.content}>{props.children}</div>
13-
<Footer on_history_click={props.on_history_click} />
14+
<Footer
15+
on_history_click={props.on_history_click}
16+
on_donate_click={props.on_donate_click}
17+
/>
1418
</div>
1519
)
1620
}

‎apps/editor/src/views/prompt/frontend/i18n/translations/footer.ts‎

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -55,26 +55,24 @@ export const footer = {
5555
hu: 'Integrálja a másolt csevegési választ vagy egy aktív terminál-munkamenet CLI-módosításait',
5656
bg: 'Интегрирайте копиран отговор от чата или редакции на CLI от активна терминална сесия'
5757
},
58-
59-
'footer.action.apply-from': {
60-
en: 'Apply from...',
61-
pl: 'Integruj z...',
62-
'zh-cn': '从…应用',
63-
ja: '…から適用',
64-
'zh-tw': '從…套用',
65-
de: 'Anwenden von...',
66-
es: 'Aplicar desde...',
67-
fr: 'Appliquer depuis...',
68-
'pt-br': 'Aplicar de...',
69-
ru: 'Применить из...',
70-
ko: '적용 위치...',
71-
it: 'Applica da...',
72-
tr: 'Şuradan uygula...',
73-
cs: 'Použít z...',
58+
'footer.action.apply': {
59+
en: 'Apply...',
60+
pl: 'Integruj...',
61+
'zh-cn': '应用…',
62+
ja: '適用…',
63+
'zh-tw': '套用…',
64+
de: 'Anwenden...',
65+
es: 'Aplicar...',
66+
fr: 'Appliquer...',
67+
'pt-br': 'Aplicar...',
68+
ru: 'Применить...',
69+
ko: '적용...',
70+
it: 'Applica...',
71+
tr: 'Uygula...',
72+
cs: 'Použít...',
7473
hu: 'Alkalmazás...',
75-
bg: 'Приложи от...'
74+
bg: 'Приложи...'
7675
},
77-
7876
'footer.action.undo': {
7977
en: 'Undo',
8078
pl: 'Cofnij',

‎packages/ui/src/components/editor/common/IconButton/IconButton.tsx‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import styles from './IconButton.module.scss'
22
import cn from 'classnames'
3+
import { Icon as UiIcon } from '../Icon'
34

45
type Props = {
5-
codicon_icon: string
6+
codicon_icon?: string
7+
icon?: React.ComponentProps<typeof UiIcon>['variant']
68
on_click?: (e: any) => void
79
on_mouse_down?: (e: any) => void
810
href?: string
@@ -15,7 +17,10 @@ type Props = {
1517
export const IconButton: React.FC<Props> = (props) => {
1618
const icon_element = (
1719
<span className={styles['icon-wrapper']}>
18-
<span className={cn('codicon', `codicon-${props.codicon_icon}`)} />
20+
{props.codicon_icon && (
21+
<span className={cn('codicon', `codicon-${props.codicon_icon}`)} />
22+
)}
23+
{props.icon && <UiIcon variant={props.icon} />}
1924
</span>
2025
)
2126

0 commit comments

Comments
 (0)