Skip to content

Commit c698b71

Browse files
committed
Refactor the Checkbox component to a common UI location and implement a new modal for staging unstaged Git files before commit generation
1 parent 403bc25 commit c698b71

19 files changed

Lines changed: 284 additions & 36 deletions

File tree

packages/ui/src/components/editor/panel/Checkbox/Checkbox.module.scss renamed to packages/ui/src/components/editor/common/Checkbox/Checkbox.module.scss

File renamed without changes.

packages/ui/src/components/editor/panel/Checkbox/Checkbox.stories.tsx renamed to packages/ui/src/components/editor/common/Checkbox/Checkbox.stories.tsx

File renamed without changes.

packages/ui/src/components/editor/panel/Checkbox/Checkbox.tsx renamed to packages/ui/src/components/editor/common/Checkbox/Checkbox.tsx

File renamed without changes.

packages/ui/src/components/editor/panel/Checkbox/index.ts renamed to packages/ui/src/components/editor/common/Checkbox/index.ts

File renamed without changes.

‎packages/ui/src/components/editor/panel/Field/Field.stories.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useState } from 'react'
22
import { Field } from './Field'
33
import { Input } from '../../common/Input'
4-
import { Checkbox } from '../Checkbox'
4+
import { Checkbox } from '../../common/Checkbox'
55

66
export default {
77
component: Field

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import styles from './Presets.module.scss'
22
import { IconButton } from '../IconButton/IconButton'
3-
import { Checkbox } from '../Checkbox'
3+
import { Checkbox } from '../../common/Checkbox'
44
import cn from 'classnames'
55
import { ReactSortable } from 'react-sortablejs'
66
import { Icon } from '../../common/Icon'

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { FileInReview } from '@shared/types/file-in-review'
33
import cn from 'classnames'
44
import styles from './ResponseReview.module.scss'
55
import { Button } from '../Button'
6-
import { Checkbox } from '../Checkbox'
6+
import { Checkbox } from '../../common/Checkbox'
77
import { IconButton } from '../IconButton/IconButton'
88

99
type Props = {

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,23 @@ import cn from 'classnames'
66
type Props = {
77
children: ReactNode
88
scroll_to_top_key?: any
9+
max_height?: string
910
}
1011

11-
export const Scrollable: React.FC<Props> = ({
12-
children,
13-
scroll_to_top_key
14-
}) => {
12+
export const Scrollable: React.FC<Props> = (props) => {
1513
const [has_top_shadow, set_has_top_shadow] = useState(false)
1614
const simplebar_ref = useRef<any>(null)
1715

1816
useEffect(() => {
19-
if (scroll_to_top_key === undefined) return
17+
if (props.scroll_to_top_key === undefined) return
2018

2119
const simplebar_instance = simplebar_ref.current
2220
if (!simplebar_instance) return
2321

2422
const scroll_element = simplebar_instance.getScrollElement()
2523
if (!scroll_element) return
2624
scroll_element.scrollTop = 0
27-
}, [scroll_to_top_key])
25+
}, [props.scroll_to_top_key])
2826

2927
useEffect(() => {
3028
const simplebar_instance = simplebar_ref.current
@@ -65,10 +63,11 @@ export const Scrollable: React.FC<Props> = ({
6563
<SimpleBar
6664
ref={simplebar_ref}
6765
style={{
68-
height: '100%'
66+
height: '100%',
67+
maxHeight: props.max_height
6968
}}
7069
>
71-
{children}
70+
{props.children}
7271
</SimpleBar>
7372
</div>
7473
)
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
.title {
2+
text-align: center;
3+
font-weight: 500;
4+
font-size: var(--font-size-14px);
5+
}
6+
7+
.container {
8+
display: flex;
9+
flex-direction: column;
10+
gap: var(--padding-8px);
11+
}
12+
13+
.files {
14+
margin: 0 -12px;
15+
16+
&__inner {
17+
display: flex;
18+
flex-direction: column;
19+
gap: var(--padding-4px);
20+
padding: 0 var(--padding-12px);
21+
}
22+
23+
&__item {
24+
display: flex;
25+
align-items: center;
26+
gap: var(--padding-8px);
27+
cursor: pointer;
28+
font-size: var(--vscode-font-size);
29+
}
30+
}
31+
32+
.actions {
33+
display: flex;
34+
justify-content: flex-end;
35+
gap: var(--padding-8px);
36+
37+
> button {
38+
flex: 1;
39+
}
40+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { useState } from 'react'
2+
import { StageFilesModal } from './StageFilesModal'
3+
4+
export default {
5+
component: StageFilesModal
6+
}
7+
8+
const mock_files = [
9+
'packages/ui/src/components/Button.tsx',
10+
'packages/ui/src/components/Modal.tsx',
11+
'packages/vscode/src/utils/helpers.ts',
12+
'packages/shared/src/index.ts',
13+
'README.md'
14+
]
15+
16+
export const Default = () => {
17+
const [visible, set_visible] = useState(true)
18+
19+
const handle_stage = (files: string[]) => {
20+
alert(`Staging ${files.length} files:\n${files.join('\n')}`)
21+
set_visible(false)
22+
}
23+
24+
const handle_cancel = () => {
25+
set_visible(false)
26+
}
27+
28+
return visible ? (
29+
<StageFilesModal
30+
files={mock_files}
31+
on_stage={handle_stage}
32+
on_cancel={handle_cancel}
33+
/>
34+
) : null
35+
}

0 commit comments

Comments
 (0)