-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GEN-2156]: upgrade code component to enhance readability for describ…
…e odigos & describe source (#2131) This pull request introduces a new feature to toggle between code view and a more human-readable "pretty" view for JSON data, along with some new icons and components to support this functionality. The main changes include the addition of a `ToggleCodeComponent`, updates to the `describe-drawer` and `source-drawer-container` components, and enhancements to the `Code` component to support the pretty view. ### New Components and Icons: * [`frontend/webapp/assets/icons/common/code-brackets-icon.tsx`](diffhunk://#diff-b915df544c6055e9fefb19e39c8cb7f1bed551dc2c397bdf0fbebe08492d9933R1-R16): Added a new `CodeBracketsIcon` component. * [`frontend/webapp/assets/icons/common/list-icon.tsx`](diffhunk://#diff-ac6e9406c5e3485aa9c7ec0bf308a01db7fbd80cd3c0476ebd762263a1dddb86R1-R11): Added a new `ListIcon` component. * [`frontend/webapp/components/common/buttons/toggle-code-component/index.tsx`](diffhunk://#diff-41caeebe24ebfb15cef4fb61e0b64cef8522a865e6da945fd260c5366cc80995R1-R40): Added a new `ToggleCodeComponent` for toggling between code and pretty view. ### Component Updates: * [`frontend/webapp/components/overview/all-drawers/describe-drawer.tsx`](diffhunk://#diff-840f9f31ab7f0b7437b98105569846f658412a1c2ae133dfa36c129ef518a262L1-R6): Updated to include the `ToggleCodeComponent` and handle the pretty view for JSON data. [[1]](diffhunk://#diff-840f9f31ab7f0b7437b98105569846f658412a1c2ae133dfa36c129ef518a262L1-R6) [[2]](diffhunk://#diff-840f9f31ab7f0b7437b98105569846f658412a1c2ae133dfa36c129ef518a262L18-L29) * [`frontend/webapp/containers/main/sources/source-drawer-container/index.tsx`](diffhunk://#diff-d4745da2f63be90cb1f7af8ea29fb2f37cf0a80f0f04a207b6fc9149855ca6d5R6): Updated to include the `ToggleCodeComponent` and handle the pretty view for JSON data. [[1]](diffhunk://#diff-d4745da2f63be90cb1f7af8ea29fb2f37cf0a80f0f04a207b6fc9149855ca6d5R6) [[2]](diffhunk://#diff-d4745da2f63be90cb1f7af8ea29fb2f37cf0a80f0f04a207b6fc9149855ca6d5R53) [[3]](diffhunk://#diff-d4745da2f63be90cb1f7af8ea29fb2f37cf0a80f0f04a207b6fc9149855ca6d5L103-R105) [[4]](diffhunk://#diff-d4745da2f63be90cb1f7af8ea29fb2f37cf0a80f0f04a207b6fc9149855ca6d5R156-L158) ### Code Enhancements: * [`frontend/webapp/reuseable-components/code/index.tsx`](diffhunk://#diff-b2d854039ed7f8b3ce6c2926bf9b37b7a766e688bd6d66819db9488355bd31ecL1-R42): Enhanced the `Code` component to support a pretty view for JSON data, including new helper functions and styled components. [[1]](diffhunk://#diff-b2d854039ed7f8b3ce6c2926bf9b37b7a766e688bd6d66819db9488355bd31ecL1-R42) [[2]](diffhunk://#diff-b2d854039ed7f8b3ce6c2926bf9b37b7a766e688bd6d66819db9488355bd31ecR55-R66) [[3]](diffhunk://#diff-b2d854039ed7f8b3ce6c2926bf9b37b7a766e688bd6d66819db9488355bd31ecR75-R191) ### Utility Functions: * [`frontend/webapp/hooks/describe/useDescribeOdigos.ts`](diffhunk://#diff-f96e0d4e8e6b30c653c21364c7479cd8656417588a42c68aa9346c90e838d4ccR10-R45): Added a `restructureForPrettyMode` function to format JSON data for the pretty view. * [`frontend/webapp/hooks/describe/useDescribeSource.ts`](diffhunk://#diff-d17d5d94f77fc9f854c37f3ff50fe36db633f9a234b0c469533138d6768fcc53R11-R56): Added a `restructureForPrettyMode` function to format JSON data for the pretty view. <img width="657" alt="Screenshot 2025-01-05 at 13 35 41" src="https://github.com/user-attachments/assets/2df38a03-0bc7-4ab8-bda2-95920b9fdf86" /> <img width="657" alt="Screenshot 2025-01-05 at 13 35 32" src="https://github.com/user-attachments/assets/a5857591-18b4-413d-8d5c-b3f2c9d5e475" />
- Loading branch information
1 parent
0ac19a6
commit 4bbc40a
Showing
13 changed files
with
333 additions
and
21 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
frontend/webapp/assets/icons/common/code-brackets-icon.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react'; | ||
import { SVG } from '@/assets'; | ||
import theme from '@/styles/theme'; | ||
|
||
export const CodeBracketsIcon: SVG = ({ size = 16, fill = theme.text.secondary, rotate = 0, onClick }) => { | ||
return ( | ||
<svg width={size} height={size} viewBox='0 0 16 16' xmlns='http://www.w3.org/2000/svg' fill='none' style={{ transform: `rotate(${rotate}deg)` }} onClick={onClick}> | ||
<path | ||
stroke={fill} | ||
strokeLinecap='round' | ||
strokeLinejoin='round' | ||
d='M5.33333 2.66669C4.22876 2.66669 3.33333 3.46263 3.33333 4.44446V6.22224C3.33333 7.20408 2.4379 8.00002 1.33333 8.00002C2.4379 8.00002 3.33333 8.79596 3.33333 9.7778V11.5556C3.33333 12.5374 4.22876 13.3334 5.33333 13.3334M10.6667 2.66669C11.7712 2.66669 12.6667 3.46263 12.6667 4.44446V6.22224C12.6667 7.20408 13.5621 8.00002 14.6667 8.00002C13.5621 8.00002 12.6667 8.79596 12.6667 9.7778V11.5556C12.6667 12.5374 11.7712 13.3334 10.6667 13.3334' | ||
/> | ||
</svg> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from 'react'; | ||
import { SVG } from '@/assets'; | ||
import theme from '@/styles/theme'; | ||
|
||
export const ListIcon: SVG = ({ size = 16, fill = theme.text.secondary, rotate = 0, onClick }) => { | ||
return ( | ||
<svg width={size} height={size} viewBox='0 0 16 16' xmlns='http://www.w3.org/2000/svg' fill='none' style={{ transform: `rotate(${rotate}deg)` }} onClick={onClick}> | ||
<path stroke={fill} strokeLinecap='round' strokeLinejoin='round' d='M2.667 6.001h10.666M2.666 9.335h10.667M2.667 12.668H8m-5.333-10h10.666' /> | ||
</svg> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './toggle-code-component'; |
40 changes: 40 additions & 0 deletions
40
frontend/webapp/components/common/buttons/toggle-code-component/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React from 'react'; | ||
import { FlexRow } from '@/styles'; | ||
import styled from 'styled-components'; | ||
import { CodeIcon, ListIcon } from '@/assets'; | ||
|
||
interface Props { | ||
isCodeMode: boolean; | ||
setIsCodeMode: (isCodeMode: boolean) => void; | ||
} | ||
|
||
const Container = styled(FlexRow)` | ||
gap: 0; | ||
`; | ||
|
||
const Button = styled.button<{ $position: 'left' | 'right'; $selected: boolean }>` | ||
padding: 4px 8px; | ||
background-color: ${({ theme, $selected }) => ($selected ? theme.colors.white_opacity['008'] : 'transparent')}; | ||
border-radius: ${({ $position }) => ($position === 'left' ? '32px 0px 0px 32px' : $position === 'right' ? '0px 32px 32px 0px' : '0')}; | ||
border: 1px solid ${({ theme }) => theme.colors.border}; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
cursor: pointer; | ||
&:hover { | ||
border: 1px solid ${({ theme }) => theme.colors.secondary}; | ||
} | ||
`; | ||
|
||
export const ToggleCodeComponent: React.FC<Props> = ({ isCodeMode, setIsCodeMode }) => { | ||
return ( | ||
<Container> | ||
<Button $position='left' $selected={!isCodeMode} onClick={() => setIsCodeMode(false)}> | ||
<ListIcon /> | ||
</Button> | ||
<Button $position='right' $selected={isCodeMode} onClick={() => setIsCodeMode(true)}> | ||
<CodeIcon /> | ||
</Button> | ||
</Container> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './buttons'; | ||
export * from './dropdowns'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.