Skip to content

Commit 528f14f

Browse files
committed
[DUPLICATE-STEP-7] PLU-564: improve ui for reorder step (#1103)
### TL;DR Improved the UI for flow steps and drag handles. Improved display of flow step name and buttons. ### What changed? - Fixed flex layout in `StepCaptionAndDemo` by replacing `maxW="70%"` with `flex={1} minW={0}` to prevent overflow issues - Aligned nested flow steps to have the same width and display drag handle on the right - Updated the drag handle component to have different padding based on whether it's in a nested context - Modified the `getFlowStepHeaderWidth` function to account for drag handle presence - Reduced padding in the IfThen component from `px={4}` to `px={2}` and in branch styles from `px={4}` to `px={3}` ### How to test? - [ ] Drag and reorder still works - [ ] Flow step duplicate step and delete button still appear on hover in different screen sizes and are not squished by step name ### Screenshots ![image.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/Wrwhm8Mmhv1Z2GwlSb7V/d5841419-1a7b-4870-875c-abef6fa2439a.png) ![image.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/Wrwhm8Mmhv1Z2GwlSb7V/24041ad9-e7dd-445c-b0e7-b7e7aace3f83.png)
1 parent 8716d2c commit 528f14f

File tree

7 files changed

+30
-14
lines changed

7 files changed

+30
-14
lines changed

packages/frontend/src/components/FlowStep/components/StepCaptionAndDemo.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default function StepCaptionAndDemo(props: StepCaptionProps) {
1111
const { caption } = props
1212
return (
1313
<>
14-
<Flex direction="column" align="start" maxW="70%" flexShrink={1}>
14+
<Flex direction="column" align="start" flex={1} flexShrink={1} minW={0}>
1515
<Flex alignItems="center" gap={2} maxW="100%">
1616
<Text
1717
textStyle="subhead-1"
@@ -66,7 +66,7 @@ export default function StepCaptionAndDemo(props: StepCaptionProps) {
6666

6767
// return (
6868
// <>
69-
// <Flex direction="column" align="start" maxW="80%" flexShrink={1}>
69+
// <Flex direction="column" align="start" flex={1} flexShrink={1} minW={0}>
7070
// <Flex alignItems="center" gap={2} maxW="100%">
7171
// <Text
7272
// textStyle="subhead-1"

packages/frontend/src/components/FlowStep/index.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import EmptyFlowStepHeader from '../EmptyFlowStepHeader'
1919
import ErrorFlowStepHeader from '../ErrorFlowStepHeader'
2020
import FlowStepConfigurationModal from '../FlowStepConfigurationModal'
2121
import { infoboxMdComponents } from '../MarkdownRenderer/CustomMarkdownComponents'
22-
import { SortableList } from '../SortableList'
22+
import { DragHandle } from '../SortableList/components'
2323

2424
import DeleteStepButton from './components/DeleteStepButton'
2525
import DuplicateStepButton from './components/DuplicateStepButton'
@@ -140,7 +140,6 @@ export default function FlowStep(
140140
}
141141
}
142142

143-
const headerWidth = getFlowStepHeaderWidth(isDrawerOpen, isMobile, isNested)
144143
/**
145144
* NOTE: there are various conditions that determine whether the drag handle
146145
* should be shown.
@@ -154,6 +153,13 @@ export default function FlowStep(
154153
const shouldShowDragHandle =
155154
!readOnly && !isTrigger && !isMobile && !isIfThenStep && allowReorder
156155

156+
const headerWidth = getFlowStepHeaderWidth(
157+
isDrawerOpen,
158+
isMobile,
159+
isNested,
160+
shouldShowDragHandle,
161+
)
162+
157163
// generate help message only if template config exists
158164
const stepAppEventKey = `${step?.appKey}_${step?.key}`
159165
const templateStepAppEventKey = step.config.templateConfig?.appEventKey
@@ -190,7 +196,9 @@ export default function FlowStep(
190196
) : (
191197
<Flex flexDir="row" w="100%">
192198
<Flex
193-
alignItems="center"
199+
alignItems={
200+
isNested && !shouldShowDragHandle ? 'flex-start' : 'center'
201+
}
194202
justifyContent="center"
195203
flexDir="column"
196204
flex="1"
@@ -266,10 +274,10 @@ export default function FlowStep(
266274
</Flex>
267275
{shouldShowDragHandle &&
268276
(isNested ? (
269-
<SortableList.DragHandle onWarningOpen={onWarningOpen} />
277+
<DragHandle isNested={isNested} onWarningOpen={onWarningOpen} />
270278
) : (
271279
<Box position="absolute" left="100%" alignSelf="center">
272-
<SortableList.DragHandle onWarningOpen={onWarningOpen} />
280+
<DragHandle onWarningOpen={onWarningOpen} />
273281
</Box>
274282
))}
275283
</Flex>

packages/frontend/src/components/FlowStepGroup/Content/IfThen/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export default function IfThen(props: IfThenProps): JSX.Element {
9999

100100
return (
101101
<Flex flexDir="column" alignItems="center" gap={4} w="100%" mt={2}>
102-
<Flex flexDir="column" w="100%" px={4} gap={4}>
102+
<Flex flexDir="column" w="100%" px={2} gap={4}>
103103
{groupedSteps.map((branchSteps) => {
104104
return (
105105
<Branch

packages/frontend/src/components/FlowStepGroup/Content/IfThen/styles.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const branchStyles = {
3636
borderRadius: 'lg',
3737
direction: 'column' as FlexProps['direction'],
3838
overflow: 'hidden',
39-
px: 4,
39+
px: 3,
4040
py: 3,
4141
w: '100%',
4242
},

packages/frontend/src/components/SortableList/components/SortableItem/SortableItem.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
.DragHandle {
1616
display: flex;
1717
width: 12px;
18-
padding: 15px;
1918
align-items: center;
2019
justify-content: center;
2120
flex: 0 0 auto;

packages/frontend/src/components/SortableList/components/SortableItem/index.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import './SortableItem.css'
22

33
import type { CSSProperties, PropsWithChildren } from 'react'
4-
import React, { createContext, useContext, useMemo } from 'react'
4+
import { createContext, useContext, useMemo } from 'react'
55
import type {
66
DraggableSyntheticListeners,
77
UniqueIdentifier,
@@ -65,8 +65,11 @@ export function SortableItem({ children, id }: PropsWithChildren<Props>) {
6565
)
6666
}
6767

68-
export function DragHandle(props: { onWarningOpen?: () => void }) {
69-
const { onWarningOpen } = props
68+
export function DragHandle(props: {
69+
isNested?: boolean
70+
onWarningOpen?: () => void
71+
}) {
72+
const { isNested, onWarningOpen } = props
7073
const { attributes, listeners, ref } = useContext(SortableItemContext)
7174
const { shouldWarnOnLeave } = useContext(EditorContext)
7275

@@ -77,6 +80,7 @@ export function DragHandle(props: { onWarningOpen?: () => void }) {
7780
{...listeners}
7881
ref={ref}
7982
{...(shouldWarnOnLeave && { onPointerDown: onWarningOpen })}
83+
style={{ padding: isNested ? '8px' : '12px' }}
8084
>
8185
<svg viewBox="0 0 20 20" width="12">
8286
<path d="M7 2a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 2zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 8zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 14zm6-8a2 2 0 1 0-.001-4.001A2 2 0 0 0 13 6zm0 2a2 2 0 1 0 .001 4.001A2 2 0 0 0 13 8zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 13 14z"></path>

packages/frontend/src/helpers/editor.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export const getFlowStepHeaderWidth = (
1919
isDrawerOpen: boolean,
2020
isMobile?: boolean,
2121
isNested?: boolean,
22+
shouldShowDragHandle?: boolean,
2223
) => {
2324
if (isDrawerOpen) {
2425
if (isMobile) {
@@ -31,7 +32,11 @@ export const getFlowStepHeaderWidth = (
3132
return '100%'
3233
}
3334

34-
return isNested ? 'full' : '600px'
35+
return isNested
36+
? shouldShowDragHandle
37+
? 'full'
38+
: 'calc(100% - 16px)' // 16px is the width of the drag handle
39+
: '600px'
3540
}
3641

3742
function isValidArgValue(value: IJSONValue): boolean {

0 commit comments

Comments
 (0)