-
Notifications
You must be signed in to change notification settings - Fork 4.7k
feat: Collapsible Bottom View #33441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
c44f52e
feat: Collapsible Bottom View
hetunandu 780411c
add comments
hetunandu c689177
add classnames
hetunandu 51c1340
Merge branch 'refs/heads/release' into feat/collapsible-bottom-view
hetunandu e54befb
fix for JS editor
hetunandu 28fd251
fix selector
hetunandu bcafdd1
use tabs instead
hetunandu 30ecce4
Review comments
hetunandu 49fcdc8
min height
hetunandu 5c1add8
Merge branch 'refs/heads/release' into feat/collapsible-bottom-view
hetunandu 72a8ba7
init test
hetunandu c32cea1
add tests
hetunandu 46b8d48
Merge branch 'refs/heads/release' into feat/collapsible-bottom-view
hetunandu 8f3b96e
Fix classname change
hetunandu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,150 @@ | ||
| import React, { | ||
| type CSSProperties, | ||
| type RefObject, | ||
| useEffect, | ||
| useRef, | ||
| useState, | ||
| } from "react"; | ||
| import styled from "styled-components"; | ||
| import Resizer, { | ||
| ResizerCSS, | ||
| } from "components/editorComponents/Debugger/Resizer"; | ||
| import { ActionExecutionResizerHeight } from "pages/Editor/APIEditor/constants"; | ||
| import { CodeEditorWithGutterStyles } from "pages/Editor/JSEditor/constants"; | ||
| import { ViewHideBehaviour } from "../Interfaces/ViewHideBehaviour"; | ||
| import { Button } from "design-system"; | ||
|
|
||
| const VIEW_MIN_HEIGHT = "38px"; | ||
|
hetunandu marked this conversation as resolved.
Outdated
|
||
|
|
||
| const Container = styled.div` | ||
| ${ResizerCSS}; | ||
| width: 100%; | ||
| // Minimum height of bottom tabs as it can be resized | ||
| min-height: ${VIEW_MIN_HEIGHT}; | ||
| background-color: var(--ads-v2-color-bg); | ||
| height: ${ActionExecutionResizerHeight}px; | ||
| border-top: 1px solid var(--ads-v2-color-border); | ||
| `; | ||
|
|
||
| const ViewWrapper = styled.div` | ||
| height: 100%; | ||
| &&& { | ||
| ul.ads-v2-tabs__list { | ||
| margin: 0 ${(props) => props.theme.spaces[11]}px; | ||
| height: ${VIEW_MIN_HEIGHT}; | ||
| } | ||
| } | ||
|
|
||
| & { | ||
| .ads-v2-tabs__list { | ||
| padding: var(--ads-v2-spaces-1) var(--ads-v2-spaces-7); | ||
| } | ||
| } | ||
|
|
||
| & { | ||
| .ads-v2-tabs__panel { | ||
| ${CodeEditorWithGutterStyles}; | ||
| overflow-y: auto; | ||
| height: calc(100% - ${VIEW_MIN_HEIGHT}); | ||
| } | ||
| } | ||
| `; | ||
|
|
||
| const MIN_HEIGHT = { | ||
| [ViewHideBehaviour.COLLAPSE]: VIEW_MIN_HEIGHT, | ||
| [ViewHideBehaviour.CLOSE]: "0px", | ||
| }; | ||
|
|
||
| interface Props { | ||
| className?: string; | ||
| behaviour: ViewHideBehaviour; | ||
| height: number; | ||
| setHeight: (height: number) => void; | ||
| hidden: boolean; | ||
| onHideClick: () => void; | ||
| children: React.ReactNode; | ||
| additionalContainerStyles?: CSSProperties; | ||
| } | ||
|
|
||
| const ViewHideButton = styled(Button)` | ||
| &.view-hide-button { | ||
| position: absolute; | ||
| top: 3px; | ||
| right: 0; | ||
| padding: 9px 11px; | ||
| } | ||
| `; | ||
|
|
||
| const ViewHide = (props: { | ||
| hideBehaviour: ViewHideBehaviour; | ||
| isHidden: boolean; | ||
| onToggle: () => void; | ||
| }) => { | ||
|
hetunandu marked this conversation as resolved.
Outdated
|
||
| const [icon, setIcon] = useState(() => { | ||
| return props.hideBehaviour === ViewHideBehaviour.CLOSE | ||
| ? "close-modal" | ||
| : "arrow-down-s-line"; | ||
| }); | ||
|
|
||
| useEffect(() => { | ||
| if (props.hideBehaviour === ViewHideBehaviour.COLLAPSE) { | ||
| if (props.isHidden) { | ||
| setIcon("arrow-up-s-line"); | ||
| } else { | ||
| setIcon("arrow-down-s-line"); | ||
| } | ||
| } | ||
| }, [props.isHidden]); | ||
|
|
||
| return ( | ||
| <ViewHideButton | ||
| className="view-hide-button t--view-hide-button" | ||
|
hetunandu marked this conversation as resolved.
Outdated
|
||
| isIconButton | ||
| kind="tertiary" | ||
| onClick={props.onToggle} | ||
| size="md" | ||
| startIcon={icon} | ||
| /> | ||
| ); | ||
| }; | ||
|
|
||
| const BottomView = (props: Props) => { | ||
| const panelRef: RefObject<HTMLDivElement> = useRef(null); | ||
|
hetunandu marked this conversation as resolved.
Outdated
|
||
|
|
||
| // Handle the height of the tabs when toggling the hidden state | ||
| useEffect(() => { | ||
| const panel = panelRef.current; | ||
| if (!panel) return; | ||
| if (props.hidden) { | ||
| panel.style.height = MIN_HEIGHT[props.behaviour]; | ||
| } else { | ||
| panel.style.height = `${props.height}px`; | ||
| } | ||
| }, [props.hidden]); | ||
|
hetunandu marked this conversation as resolved.
Outdated
|
||
|
|
||
| return ( | ||
| <Container | ||
| className={`select-text ${props.className}`} | ||
| ref={panelRef} | ||
| style={props.additionalContainerStyles} | ||
|
hetunandu marked this conversation as resolved.
Outdated
|
||
| > | ||
| {!props.hidden && ( | ||
| <Resizer | ||
| initialHeight={props.height} | ||
| onResizeComplete={props.setHeight} | ||
| panelRef={panelRef} | ||
| /> | ||
| )} | ||
| <ViewWrapper> | ||
| {props.children} | ||
| <ViewHide | ||
| hideBehaviour={props.behaviour} | ||
| isHidden={props.hidden} | ||
| onToggle={props.onHideClick} | ||
| /> | ||
| </ViewWrapper> | ||
| </Container> | ||
| ); | ||
| }; | ||
|
|
||
| export default BottomView; | ||
This file contains hidden or 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,14 @@ | ||
| /** | ||
| * Close: | ||
| * - View is not visible at all | ||
| * - View is not interactable till opened again | ||
| * | ||
| * Collapse: | ||
| * - View is visible but can not be resized | ||
| * - Top part of the view is visible with open to reopen it | ||
| * - Children can have extra view that changes when hidden that can have different behaviours | ||
| */ | ||
| export enum ViewHideBehaviour { | ||
| CLOSE = "CLOSE", | ||
| COLLAPSE = "COLLAPSE", | ||
| } |
This file contains hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.